yi-hack-MStar icon indicating copy to clipboard operation
yi-hack-MStar copied to clipboard

[Question] Create time lapse

Open joekerna opened this issue 5 years ago • 21 comments

I have a quick question: Is it possible to create a time lapse using the Yi camera?

I would like to take a picture every ~30 seconds for about 8h using only the camera and a USB Powerbank?!

joekerna avatar Dec 07 '20 13:12 joekerna

I think ffmpeg is able to do time lapse. But the binary is too big to fit into this hack.

roleoroleo avatar Dec 07 '20 16:12 roleoroleo

Do you think I could put it on the SD card?

joekerna avatar Dec 08 '20 09:12 joekerna

Yes, copy it in /tmp/sd/yi-hack/bin ffmpeg.gz

roleoroleo avatar Dec 08 '20 13:12 roleoroleo

Pls. provide tutorial of how to create timelapse. Thanks in further an am merry christmas!

Rushmed avatar Dec 25 '20 23:12 Rushmed

I didn't try it but this page sould solve your question. https://superuser.com/questions/1499968/creating-timelapse-from-still-images-jpg-to-mp4-using-ffmpeg

roleoroleo avatar Dec 27 '20 13:12 roleoroleo

Thanks, I've seen that. This page describes how to generate a movie from JPEGs using ffmpeg.

I am still looking for a way to tell the camera to automatically take a photo every x seconds after booting. Creating a film from those photos I can still do later.

joekerna avatar Dec 27 '20 18:12 joekerna

Create your own directory on the SD card and schedule this command with crontab:

/home/yi-hack/bin/imggrabber -r high -w > /tmp/MY_DIR/ss_`date +"%H_%M`.jpg

roleoroleo avatar Dec 29 '20 16:12 roleoroleo

Do I have to activate cron somehow? I've added

26 10 * * * /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_date +"%H_%M_%S".jpg

to my crontab but after 10:26 no photo was taken?! I don't know if the cronjob is being executed.

joekerna avatar Jan 03 '21 10:01 joekerna

I manually started crond and after that the cronjob was executed. Now I only have to autostart crond

joekerna avatar Jan 03 '21 10:01 joekerna

crond should start automatically starting from 0.3.9. Simply add your command to the crontab section in configuration page and reboot the cam.

roleoroleo avatar Jan 03 '21 12:01 roleoroleo

I didn't know about that feature in the web-config. Thanks!

I've entered

* * * * * /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg

but it is not working quite yet. There is an issue with the timestamp. If I assign the same name every time it works.

joekerna avatar Jan 03 '21 13:01 joekerna

You are right, I found a bug with quote char. Apply the following changes: https://github.com/roleoroleo/yi-hack-MStar/commit/fb1c8c1f18b021aa6429cf4df75681d8223ec272

roleoroleo avatar Jan 03 '21 17:01 roleoroleo

Awesome! That's working. Now I will try to get a granularity smaller than 1 minute by doing something like this

joekerna avatar Jan 03 '21 19:01 joekerna

I'm running the following script every minute using cron:

#!/bin/sh

          date >> /tmp/sd/cron_test
sleep 10; date >> /tmp/sd/cron_test
sleep 20; date >> /tmp/sd/cron_test
sleep 30; date >> /tmp/sd/cron_test
sleep 40; date >> /tmp/sd/cron_test
sleep 50; date >> /tmp/sd/cron_test

However a cat /tmp/sd/cron_test shows:

cat /tmp/sd/cron_test 
Sun Jan  3 21:08:10 CET 2021
Sun Jan  3 21:08:30 CET 2021
Sun Jan  3 21:09:00 CET 2021
Sun Jan  3 21:09:40 CET 2021
Sun Jan  3 21:10:30 CET 2021
Sun Jan  3 21:11:10 CET 2021
Sun Jan  3 21:11:30 CET 2021
Sun Jan  3 21:12:00 CET 2021
Sun Jan  3 21:12:40 CET 2021
Sun Jan  3 21:13:30 CET 2021
Sun Jan  3 21:14:00 CET 2021
Sun Jan  3 21:14:10 CET 2021
Sun Jan  3 21:14:30 CET 2021
Sun Jan  3 21:15:00 CET 2021
Sun Jan  3 21:15:00 CET 2021
Sun Jan  3 21:15:10 CET 2021
Sun Jan  3 21:15:30 CET 2021
Sun Jan  3 21:15:40 CET 2021
Sun Jan  3 21:16:00 CET 2021
Sun Jan  3 21:16:30 CET 2021

It is skipping quite a few executions?!

joekerna avatar Jan 03 '21 20:01 joekerna

#!/bin/sh

(          date >> /tmp/sd/cron_test) &
(sleep 10; date >> /tmp/sd/cron_test) &
(sleep 20; date >> /tmp/sd/cron_test) &
(sleep 30; date >> /tmp/sd/cron_test) &
(sleep 40; date >> /tmp/sd/cron_test) &
(sleep 50; date >> /tmp/sd/cron_test) &

This is working like it's supposed to:

cat /tmp/sd/cron_test 
Mon Jan  4 14:25:00 CET 2021
Mon Jan  4 14:25:10 CET 2021
Mon Jan  4 14:25:20 CET 2021
Mon Jan  4 14:25:30 CET 2021
Mon Jan  4 14:25:40 CET 2021
Mon Jan  4 14:25:50 CET 2021
Mon Jan  4 14:26:00 CET 2021
Mon Jan  4 14:26:10 CET 2021
Mon Jan  4 14:26:20 CET 2021
Mon Jan  4 14:26:30 CET 2021
Mon Jan  4 14:26:40 CET 2021
Mon Jan  4 14:26:50 CET 2021
Mon Jan  4 14:27:00 CET 2021
Mon Jan  4 14:27:10 CET 2021
Mon Jan  4 14:27:20 CET 2021
Mon Jan  4 14:27:30 CET 2021
Mon Jan  4 14:27:40 CET 2021
Mon Jan  4 14:27:50 CET 2021
Mon Jan  4 14:28:00 CET 2021
Mon Jan  4 14:28:10 CET 2021
Mon Jan  4 14:28:20 CET 2021
Mon Jan  4 14:28:30 CET 2021
Mon Jan  4 14:28:40 CET 2021
Mon Jan  4 14:28:50 CET 2021
Mon Jan  4 14:29:00 CET 2021
Mon Jan  4 14:29:10 CET 2021
Mon Jan  4 14:29:20 CET 2021
Mon Jan  4 14:29:30 CET 2021
Mon Jan  4 14:29:40 CET 2021
Mon Jan  4 14:29:50 CET 2021
Mon Jan  4 14:30:00 CET 2021
Mon Jan  4 14:30:10 CET 2021
Mon Jan  4 14:30:20 CET 2021
Mon Jan  4 14:30:30 CET 2021
Mon Jan  4 14:30:40 CET 2021
Mon Jan  4 14:30:50 CET 2021
Mon Jan  4 14:31:00 CET 2021
Mon Jan  4 14:31:10 CET 2021
Mon Jan  4 14:31:20 CET 2021

joekerna avatar Jan 04 '21 13:01 joekerna

It is working:

* * * * * /home/yi-hack/timelapse.sh


#!/bin/sh

(          /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg) &
(sleep 10; /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg) &
(sleep 20; /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg) &
(sleep 30; /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg) &
(sleep 40; /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg) &
(sleep 50; /home/yi-hack/bin/imggrabber -r high -w > /tmp/sd/ss_`/bin/date +'%H_%M_%S'`.jpg) &

I will try a longrun tomorrow and then create an actual film from the JPEGs using ffmpeg

joekerna avatar Jan 04 '21 19:01 joekerna

The whole timelapse process is working fine. I wanted to use it to make a timelapse of a building construction.

However not a single photo was taken at the construction side because there is no WIFI. All my tests were run at home where the is wifi

Why does the camera require wifi to store photos onto the SD card?

joekerna avatar Jan 19 '21 07:01 joekerna

I have never tested this scenario. Probably the yi processes don't start if a connection is not available. I will check it.

roleoroleo avatar Jan 19 '21 08:01 roleoroleo

Have you been able to check it? We could take really cool timelapse videos with this if the wifi connection wasn't required

joekerna avatar Mar 26 '21 08:03 joekerna

I didn't test it because I need to reconnect serial cable. And the cam is in use in this moment.

roleoroleo avatar Mar 26 '21 09:03 roleoroleo

Do you want to try this solution? https://github.com/roleoroleo/yi-hack-Allwinner/issues/234

Try to add a record in /etc/hosts: echo "127.0.0.1 api.eu.xiaoyi.com" > /etc/hosts

roleoroleo avatar Apr 02 '21 07:04 roleoroleo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 06 '24 01:04 github-actions[bot]