Open Casalex97 opened 4 years ago
Yes, the cam creates 1 minute *.mp4 videos, put in directories, each for 1 hour. I have the feeling that the recording stops if the sd card is full. So I setup a cron job on the camera.
crontab -e
/usr/bin/find /tmp/sd/record/* -mtime +5 -delete
If you setup your camera with the app, check this settings:
Settings ->MicroSDCard: In good condition (or format...) ->Activity Detection Recording: OFF (record always)
Yes, the cam creates 1 minute *.mp4 videos, put in directories, each for 1 hour. I have the feeling that the recording stops if the sd card is full. So I setup a cron job on the camera.
crontab -e /usr/bin/find /tmp/sd/record/* -mtime +5 -delete
If you setup your camera with the app, check this settings:
Settings ->MicroSDCard: In good condition (or format...) ->Activity Detection Recording: OFF (record always)
Ok thank you, i use this camera with rtsp server to a synology NAS. If the wifi network for some reason fail how can i watch this recorded videos in SD? I have to extract the SD card and view it on a computer or it's possible to copy later the file on NAS? Which app are compatible with Yi-Hack?
Thank you
I use a shell script to copy files from the sd card via ftp to a HDD attached to a raspberry pi
!/bin/bash
HOST='10.0.1.26:21' USER='**' PASS='**' TARGETFOLDER='/mnt/storage/cctv/yicamftp/' SOURCEFOLDER='/tmp/sd/record/' lftp -f " open $HOST user $USER $PASS lcd $SOURCEFOLDER mirror -c --ignore-time --no-empty-dirs --use-cache $SOURCEFOLDER $TARGETFOLDER bye "
I also discovered that if we move ALL the files from the /tmp/sd/record folder, the camera stops recording further, so i created another script to move only files more that 2 days old, making sure some files are left behind on the camera
lftp -f " open $HOST user $USER $PASS lcd $SOURCEFOLDER mirror -c --ignore-time --no-empty-dirs --use-cache $SOURCEFOLDER $TARGETFOLDER bye "
I then created a cron job to run both these scripts every 1 hour. So the first script copies all videos to the HDD and the second script deletes anything more than 2 days old form the camera.
This has been working flawlessly on my yi home 720p. Much more reliable than trying to record from an RTSP stream using motioneye etc..
I have a different approach: If I get a move event via MQTT. Then, I copy the affected files with scp and create some JPEGs right now from the motion-start position for fast examination.
Here are the example commands, login via private key. I tried also to optimize the SSL encryption for this tiny cam hardware but the speed up was marginaly, anyway.
From the host computer:
$ scp -c aes128-cbc -i ./cams root@poopy:/tmp/sd/record/2020Y05M04D07H/25M00S.mp4 work.mp4
$ ffmpeg -v 0 -ss 18.0 -i work.mp4 -t 3 -r 1 -s 480x300 -f image2 img_2020Y05M04D07H25M00S_%0d.jpg
PS: MQTT is buggy, a fix can be found here: https://github.com/TheCrypt0/yi-hack-v4/issues/161#issuecomment-588426905
Yes, the cam creates 1 minute *.mp4 videos, put in directories, each for 1 hour. I have the feeling that the recording stops if the sd card is full. So I setup a cron job on the camera.
crontab -e /usr/bin/find /tmp/sd/record/* -mtime +5 -delete
If you setup your camera with the app, check this settings:
Settings ->MicroSDCard: In good condition (or format...) ->Activity Detection Recording: OFF (record always)
Sorry to ask but i am a noob. Where do i insert this crontab script? And what would be the command if i want to delete all records that are 48 hours and older? For example i want to delete every 2 days the Recordings that are 48+ hours old.
Edit: Right now i am using the YI Home App to view the records. I am recording everything and need to delete the SD-Card manually via YI Home App every 6-7 days because it runs out of space. Sometimes i forget deleting the records and the camera stops recording..
Setup the crontab on the camera.. And adjust the mtime to 48 hours.. google what value is needed for this
Setup the crontab on the camera.. And adjust the mtime to 48 hours.. google what value is needed for this
Well yeah. But where do set the crontab?
ssh into the camera and run crontab -e
On the camera runs a Linux, so any Linux tutorial is useful. Just google for the commands contab and find. Man pages or howtos, what you like. Don't care about Linux distributions (RedHeat, Debian etc), the commands are always the same. Small hint: Its a very tiny Linux on your camera, maybe the command does not support all options related to a desktop linux. Busybox is a good keyword to google for embedded Linux with limited functionality.
When i do crontab -e i cannot edit the file. What do i need to enter before
/usr/bin/find /tmp/sd/record/* -mtime +5 -delete
Google for "vi editor" :-)
I edited the file "root" in "/home/yi-hack-v4/etc/crontabs" but it doesn't change anything. Shouldnt it delete all records that are 5min and older?
Edit: Before that i tried this one without any effect
I sshd into the camera, then ran "crontab -e" it opens the file, can enter a new line then esc,type :wq and enter done check crontab -l for list of crontabs installed
On Thu, May 28, 2020 at 6:20 AM 1onar notifications@github.com wrote:
I edited the file "root" in "/home/yi-hack-v4/etc/crontabs" but it doesn't change anything. Shouldnt it delete all records that are 5min and older?
[image: Unbenannt] https://user-images.githubusercontent.com/52460200/83073345-941e0c80-a070-11ea-9f36-5acb10df594c.jpg
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TheCrypt0/yi-hack-v4/issues/222#issuecomment-634946976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7OFYT36L34RBJT767QHY3RTV72HANCNFSM4MGOLJRQ .
I sshd into the camera, then ran "crontab -e" it opens the file, can enter a new line then esc,type :wq and enter done check crontab -l for list of crontabs installed …
Something isnt working as intended for me then. I cant edit the crontab when i use ssh.
While i browsed via ftp through the files there were some temporarily crontab files like "crontab462619" and "crontab1733" in there. There is always one more if try to edit the file via ssh as root.
I edited the crontab file via ftp like the Screenshots aboth. It doesnt work..
what do you mean with you cannot edit the crontab? can you run crontab -e? errors?
I cant edit it via SSH. It creates a new Crontab File and i cant save it.
I downloaded the file "root" via ftp, edited it and saved it to "/home/yi-hack-v4/etc/crontabs". It seems to be there but doesnt have a effect on the recorded videos.
Edit: Like mentioned above i am a noob.
Yes, well, you haven’t given it a schedule.. see the first command and google how to create a cron schedule . Right now it’s missing
On Thu, May 28, 2020 at 16:44 1onar notifications@github.com wrote:
I cant edit it via SSH. It creates a new Crontab File and i cant save it. [image: 1] https://user-images.githubusercontent.com/52460200/83113172-8c3d8700-a0c7-11ea-8a22-05cc991f04ef.jpg
I downloaded the file "root" via ftp, edited it and saved it to "/home/yi-hack-v4/etc/crontabs". It seems to be there but doesnt have a effect on the recorded videos.
[image: 3] https://user-images.githubusercontent.com/52460200/83113293-c3139d00-a0c7-11ea-946d-0b0c1e7a7845.jpg [image: 4] https://user-images.githubusercontent.com/52460200/83113297-c3ac3380-a0c7-11ea-96c8-4396dc13c6a7.jpg [image: Unbenannt] https://user-images.githubusercontent.com/52460200/83113299-c3ac3380-a0c7-11ea-8437-12b7d99963df.jpg
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TheCrypt0/yi-hack-v4/issues/222#issuecomment-635173125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7OFYUXKZLLQTJPOAAZETDRTYI5HANCNFSM4MGOLJRQ .
Yes, well, you haven’t given it a schedule.. see the first command and google how to create a cron schedule . Right now it’s missing …
Sorry to annoy you. But it's still not working.
I did it with a Crontab Generator.
0 11 * * * /usr/bin/find /tmp/sd/record/* -mtime +1440 -delete >/dev/null 2>&1
It should delete everything that is older than 24hours everyday at 11 UTC.
ok, try trigger /usr/bin/find /tmp/sd/record/* -mtime +1440 -delete manually and see if it works
On Fri, May 29, 2020 at 8:12 PM 1onar notifications@github.com wrote:
Yes, well, you haven’t given it a schedule.. see the first command and google how to create a cron schedule . Right now it’s missing … <#m5301573527659764062>
Sorry to annoy you. But it's still not working.
[image: Bildschirmfoto 2020-05-29 um 13 10 24] https://user-images.githubusercontent.com/52460200/83253779-d9942400-a1ad-11ea-8c91-bee0805fc4c8.png
I did it with a Crontab Generator. 0 11 /usr/bin/find /tmp/sd/record/ -mtime +1440 -delete >/dev/null 2>&1
It should delete everything that is older than 24hours everyday at 11 UTC.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TheCrypt0/yi-hack-v4/issues/222#issuecomment-635916095, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7OFYU67S5F6OBI3GLLOXTRT6KCJANCNFSM4MGOLJRQ .
ok, try trigger /usr/bin/find /tmp/sd/record/* -mtime +1440 -delete manually and see if it works …
I dit it right now. No error but the records 24+ hours are still there.
does /usr/bin/find /tmp/sd/record/* -mtime +1440 show anything? most likely your dates or value are incorrect
On Fri, May 29, 2020 at 8:18 PM 1onar notifications@github.com wrote:
ok, try trigger /usr/bin/find /tmp/sd/record/* -mtime +1440 -delete manually and see if it works … <#m6118381738331098263>
I dit it right now. No error but the records 24+ hours are still there.
[image: Bildschirmfoto 2020-05-29 um 13 16 06] https://user-images.githubusercontent.com/52460200/83254276-d2b9e100-a1ae-11ea-8bb0-071d9e881c2d.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TheCrypt0/yi-hack-v4/issues/222#issuecomment-635918314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7OFYVTCXAXDYNKLBZIFNTRT6KXVANCNFSM4MGOLJRQ .
No, nothing happens when i enter it.
are there any records in /tmp/sd/record/ ??
Could you follow the instructions https://github.com/TheCrypt0/yi-hack-v4/issues/222#issuecomment-634538212 carefully, please?
If you did, you would read in the man page
-mtime n File's data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.
If you don't get it, read it again until you recognize that your variable in n. And n is a day! Please, don't just copy&paste from the internet, it will never work. Yes, copy from the internet is good, I call it learning. But the next step is not paste, the next step must be understand whats going on.
Tip: The plus sign before n is important, it means:
+n More than n.
n Exactly n.
-n Less than n
Could you follow the instructions #222 (comment) carefully, please?
If you did, you would read in the man page
-mtime n File's data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.
If you don't get it, read it again until you recognize that your variable in n. And n is a day! Please, don't just copy&paste from the internet, it will never work. Yes, copy from the internet is good, I call it learning. But the next step is not paste, the next step must be understand whats going on.
Tip: The plus sign before n is important, it means:
+n More than n. n Exactly n. -n Less than n
Thank you. I know you want to teach me. I ran the command
/usr/bin/find "/tmp/sd/record/" -mtime +1 -delete
and i deleted everything more then 1-2 hour ago.
I don't get it to working. I have tried those commands to test it:
/usr/bin/find /tmp/sd/record/* -mtime +1 -delete
/usr/bin/find "/tmp/sd/record/*" -mtime +1 -delete
/usr/bin/find /tmp/sd/record/ -mtime +1 -delete
/usr/bin/find "/tmp/sd/record/" -name "*.mp4" -mtime +1 -delete
find /tmp/sd/record -type f -name '*.mp4' -mtime +1 -delete
find /tmp/sd/record -mtime +1 -delete
Can anybody help me please.
Edit: The Folder isnt empty
Look, if you want help then at least provide more information.. what is not working, what happens and what do you expect, any errors and logs etc? This is NOT a Linux support forum...
On Sun, May 31, 2020 at 3:46 1onar notifications@github.com wrote:
I don't get it to working. I have tried those commands to test it:
/usr/bin/find "/tmp/sd/record/" -name ".mp4" -mtime +1 -delete find /tmp/sd/record -type f -name '.mp4' -mtime +1 -delete find /tmp/sd/record -mtime +1 -delete /usr/bin/find /tmp/sd/record/* -mtime +1 -delete
Can anybody help me please.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TheCrypt0/yi-hack-v4/issues/222#issuecomment-636369510, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7OFYRDRS6LRK2PZTTCQ7DRUFIARANCNFSM4MGOLJRQ .
Look, if you want help then at least provide more information.. what is not working, what happens and what do you expect, any errors and logs etc? This is NOT a Linux support forum... … On Sun, May 31, 2020 at 3:46 1onar @.**> wrote: I don't get it to working. I have tried those commands to test it: /usr/bin/find "/tmp/sd/record/" -name ".mp4" -mtime +1 -delete find /tmp/sd/record -type f -name '.mp4' -mtime +1 -delete find /tmp/sd/record -mtime +1 -delete /usr/bin/find /tmp/sd/record/ -mtime +1 -delete Can anybody help me please. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#222 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7OFYRDRS6LRK2PZTTCQ7DRUFIARANCNFSM4MGOLJRQ .
I want to test the command for the crontab. I was expecting/hoping that all records that are 24h+ hours old are getting deleted.
/usr/bin/find /tmp/sd/record/* -mtime +1 -delete
no error; system needs 1-2 sec to "load" (all records are still there).
/usr/bin/find "/tmp/sd/record/*" -mtime +1 -delete
find: /tmp/sd/record/*: No such file or directory
/usr/bin/find /tmp/sd/record/ -mtime +1 -delete
no error; system needs 1-2 sec to "load" (all records are still there).
/usr/bin/find "/tmp/sd/record/" -name "*.mp4" -mtime +1 -delete
no error; system needs 1-2 sec to "load" (all records are still there).
find /tmp/sd/record -type f -name '*.mp4' -mtime +1 -delete
no error; system needs 1-2 sec to "load" (all records are still there).
find /tmp/sd/record -mtime +1 -delete
no error; system needs 1-2 sec to "load" (all records are still there).
If i do ls -al /tmp/sd/record/*
all files are there with the right dates.
But none of the commands i am trying to use are working. I want to delete every record that is older than 1 day.
find /tmp/sd/record/* -name '*.mp4' -mtime +1 -delete
/usr/bin/find /tmp/sd/record/* -name "*.mp4" -mtime +1 delete
/usr/bin/find /tmp/sd/record/* -mtime +1 delete
find /tmp/sd/record/* -type f -mtime +1 -exec rm -f {} \;
find /tmp/sd/record/ -type f -mtime +1 -exec rm -f {} \;
find /tmp/sd/record/ -type f -mtime +1 -exec rm -f {} \;
find /tmp/sd/record/* -name "*.mp4" -type f -mtime +1 -exec rm -f {} \;
There is no error showing up if use them.
Testing your command interactive, without delete option lists the affected files.
/home/yi-hack-v4 # /usr/bin/find /tmp/sd/record/* -mtime +1
/tmp/sd/record/2020Y05M27D13H
/tmp/sd/record/2020Y05M27D13H/52M00S.mp4
/tmp/sd/record/2020Y05M27D13H/53M00S.mp4
<and more...>
/tmp/sd/record/2020Y05M29D11H/55M00S.mp4
With mtime +1, the newest affected file is ~48h old, how can it be? If you would start reading the man page, you would figure out: -atime n File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.
And I agree: "This is NOT a Linux support forum...". Please ask additional questions, not related to the camera firmware in a linux support forum. Please read man pages and real documentations before post anything!
For completeness, this is my crontab, and it works!
/home/yi-hack-v4 # crontab -l
#12 2 * * * /home/yi-hack-v4/script/check_update.sh
#delete files older +n+1 days
12 2 * * * /usr/bin/find /tmp/sd/record/* -mtime +3 -delete
/home/yi-hack-v4 #
manul excute crond then it will be ok
Would really appreciate some assistance on below: (I have a outdoor YI using all-winner FW)
note : I don;t have the "crontab" command/file in the system so I did the below instead:
1) ps show the below related to crond: 1408 root 864 S /tmp/sd/yi-hack/usr/sbin/crond -c /var/spool/cron/crontabs/
2) I create file /tmp/sd/yi-hack/script/del_morethan4days.sh with below:
*/tmp/sd/yi-hack/usr/bin/find /tmp/sd/record/ -mtime +3 -delete*
3) chmod +x /tmp/sd/yi-hack/script/del_morethan4days.sh
4) I edit /tmp/sd/yi-hack/script/system.sh
Adding below line *echo "12 2 /tmp/sd/yi-hack/script/del_morethan4days.sh" >> /var/spool/cron/crontabs/root**
Q) Can anyone help me figure out how I get it to work, if I run the del_morethan4days.sh manually it works ok.
If I do # cat /var/spool/cron/crontabs/root I see the below: 12 2 * /tmp/sd/yi-hack/script/del_morethan4days.sh
To be it looks like a cron job exists but it doesn't seem like it is executing, have I missed something?
ls /tmp/sd/record/ 2021Y11M13D19H 2021Y11M14D14H 2021Y11M15D18H 2021Y11M15D23H 2021Y11M16D16H 2021Y11M14D03H 2021Y11M14D15H 2021Y11M15D20H 2021Y11M16D01H 2021Y11M16D17H 2021Y11M14D13H 2021Y11M14D16H 2021Y11M15D22H 2021Y11M16D02H
I have yi hack on Yi outdoor 1080 is possible loop recording on 32 GB SD Card on board?
Thank you