phamthanhnam
Posts: 10
Joined: Sat Jul 27, 2013 4:31 pm

[Tutorial] Making time-lapse video with Raspberry Pi

Tue Mar 18, 2014 2:28 pm

Hi all,
Making time-lapse videos is one of fun things you can do with Raspberry Pi. I bet you have found many solutions somewhere out there for this technique. However I write this tutorial because my solution has many advantages that don't exist in other tutorials, for example:
- You can use Raspberry Pi camera module or a USB camera
- No programming skills required, just use existing applications/utilities
- Easy-to-find hardware, nothing special
- The most important advantage: hardware accelerated video encoding, so you don't need to transfer images to another computer to render video, just let Raspberry Pi do this hard work, and get your final video fast, even faster than what you can expect (using this tutorial, your Raspberry Pi itself can render video faster than a MacBook, really!)
- Easy to customize for your time-lapse settings
- And finally, reverse time-lapse, as a bonus
Let's start!

Introduction
Following Wikipedia, time-lapse photography is a technique whereby the frequency at which film frames are captured (the frame rate) is much lower than that used to view the sequence. When played at normal speed, time appears to be moving faster and thus lapsing. The idea to make a time-lapse video is so simple: instead of recording or capturing frames at normal rate (24, 25 or 30 fps are standards for cinema, PAL television or NTSC television), you capture frames at much lower rate, and then assembly them into a video at normal rate. Time-lapse technique is usually used to film events which last for a long time in reality.
As an example, suppose that we want to make a 1-minute time-lapse video for an event which lasts an hour in reality. We choose 24 fps for the video. So we need to capture 24 x 60 = 1440 frames (images). So the frame rate for capturing is 1440 frames/hour or 0.4 fps, i.e. we take an image after every 2.5 seconds.
The resolution for the video is determined by our camera's capability and also by our intention. Suppose that it is 1280x720.

Hardware requirement
About hardware, first, we need Raspberry Pi version B (version A may work, but you need a USB network adapter). Then, Raspberry Pi camera module is a good choice, but because we only use camera to capture still images at low frame rate, so a USB camera (webcam) is still OK. Many webcams can connect directly into Raspberry Pi's USB port, otherwise use an powered USB hub. This tutorial will cover both cases (Raspberry Pi camera module and USB camera).
If you need to film outdoor, a simple and economic solution to power up Raspberry Pi is 4 AA-size rechargeable batteries (each battery has 1.2V voltage) via GPIO pins (+5V and GND pins). I use 4 rechargeble batteries (2700mAh each) for my Raspberry Pi-powered mobile robot.
We need Internet connection to install some required software on Raspberry Pi before capturing images. Suppose that you have already accessed into Raspberry Pi (by using keyboard/monitor, or through ssh). If you use ssh, you can copy command lines in this tutorial and paste them into terminal.
And finally, SD card with installed Linux OS. I use Raspbian in this tutorial. The capacity for SD card depends on how long you want your video will be, its resolution and its frame rate (24/25 or 30 fps), so how many images you will capture and their resolution. If we choose uncompressed format for images (.ppm), each image will be (3 x width x height + 16) bytes, so about 2.8 MB for each 1280x720 image. If we choose compressed format (.jpeg in this tutorial), each image reduces to less than 100 KB. 4GB SD card is usually enough for most cases.
That's all about hardware.

Software preparation
We need to take 2 steps to make a time-lapse video directly on Raspberry Pi:
- Step 1: Capture still images at predetemined frame rate
- Step 2: Render still images into video file using Raspberry Pi's hardware video encoder
There are already many ways in many tutorials to do step 1. But step 2, no way found yet... until you read this tutorial ;)
To do step 1, this tutorial will use raspistill for Raspberry Pi camera module or streamer for USB camera. raspistill is already included in Raspbian. So we install streamer:

Code: Select all

sudo apt-get install streamer
To do step 2, we won't use mencoder, ffmpeg, avconv... simply they don't support Raspberry Pi's GPU (yet). If you use those applications on Raspberry Pi, it will take a very long time to finish rendering video and nearly 100% CPU. The only solution to get hardware encoding is using OpenMAX plugin in gstreamer. The video codec for final time-lapse video will be H264.
We need to add another repository for Raspbian to get OpenMAX plugin. Paste these 3 following commands into Raspberry Pi terminal:

Code: Select all

sudo sh -c 'echo deb http://vontaene.de/raspbian-updates/ . main >> /etc/apt/sources.list'

sudo apt-get update

sudo apt-get install libgstreamer1.0-0 liborc-0.4-0 gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-alsa gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-x libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base1.0-0
Let's check our installation result:

Code: Select all

gst-inspect-1.0 | grep omx
You will see something like that:

Code: Select all

omx:  omxh264enc: OpenMAX H.264 Video Encoder
omx:  omxvc1dec: OpenMAX WMV Video Decoder
omx:  omxmjpegdec: OpenMAX MJPEG Video Decoder
omx:  omxvp8dec: OpenMAX VP8 Video Decoder
omx:  omxtheoradec: OpenMAX Theora Video Decoder
omx:  omxh264dec: OpenMAX H.264 Video Decoder
omx:  omxh263dec: OpenMAX H.263 Video Decoder
omx:  omxmpeg4videodec: OpenMAX MPEG4 Video Decoder
omx:  omxmpeg2videodec: OpenMAX MPEG2 Video Decoder
Note the first line omxh264enc, that's the encoder we will use (and the only one as well)

Step 1: Capture still images at predetemined frame rate
- For Raspberry Pi camera module:
As calculated in introduction part, for 1 hour (3600000 ms) we take a shot every 2.5 seconds (2500 ms), so

Code: Select all

raspistill -o timelapse%04d.jpeg -tl 2500 -t 3600000
will create 1440 still images (from timelapse0001.jpeg to timelapse1440.jpeg). Because we need 1440 images, so we use %04d (4 digits integer).
- For USB camera:

Code: Select all

streamer -t 1440 -r 0.4 -s 1280x720 -o timelapse0000.jpeg
where -t: number of frames, -r: frame rate (0.4 fps means 2.5 seconds per frame), -s: resolution
will create 1440 still images (from timelapse0000.jpeg to timelapse1439.jpeg)

Step 2: Render still images into video file using Raspberry Pi's hardware video encoder
Now you have still images. You don't need to transfer them to another computer. Raspberry Pi can do video encoding faster than that computer! Raspberry Pi CPU is weak, but Raspberry Pi GPU is strong.

Code: Select all

gst-launch-1.0 multifilesrc location=timelapse%04d.jpeg index=1 caps="image/jpeg,framerate=24/1" ! jpegdec ! omxh264enc ! avimux ! filesink location=timelapse.avi
will encode images from timelapse0001.jpeg to the end into timelapse.avi. If you want to count from timelapse0100.jpeg, for example, use index=100. You can change frame rate 24/1 to 25/1, 30/1 or your own frame rate. Your time-lapse video will be available after a few minutes!
In my test, rendering .avi file (1280x720, 24 fps, H264 codec) from 1500 images on a computer with Core Duo 2.0 GHz CPU, 1 GB RAM takes 4 minutes 15 seconds. The same on Raspberry Pi takes 2 minutes 15 seconds only!
Flush all data to SD card, to avoid data corruption:

Code: Select all

sync
Now you can copy timelapse.avi to your computer through ssh with scp, or simply power off your Raspberry Pi and get your video file out from SD card.
You can put commands in step 1 and step 2 into a single .sh file to automate all the process.
Check out my time-lapse demo video from Raspberry Pi, you will see the time lapsing.

Bonus: Reverse time-lapse
- Make a new directory for images at reversed order:

Code: Select all

mkdir timelapse_reverse
- Reverse order in file names:

Code: Select all

for i in {0..1439}; do ri=`expr 1439 - $i`; cp timelapse`printf %04d $i`.jpeg timelapse_reverse/timelapse`printf %04d $ri`.jpeg; done
- Render reverse time-lapse video:

Code: Select all

gst-launch-1.0 multifilesrc location=timelapse_reverse/timelapse%04d.jpeg caps="image/jpeg,framerate=24/1" ! jpegdec ! omxh264enc ! avimux ! filesink location=timelapse_reverse.avi
Check out my reverse time-lapse demo video from Raspberry Pi.

I hope this tutorial will help you deal some technical issues in making time-lapse video with Raspberry Pi. You can combine this tutorial with your own discoveries to make things better. You can film many interesting time-lapse videos, such as blossoming flower, growing tree, slow chemical reaction, butterfly transformation, moving clouds, moving snail... and much more, it's your creativity! Have fun to lapse time!

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Tue Mar 25, 2014 2:14 pm

Looks like a good tutorial, i'm now tempted to buy the camera module and take my Pi to the seafront for a sunset timelapse
Averagemaker.com

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Tue Apr 08, 2014 2:54 am

Thank you for this excellent tutorial! I did as you had said and made some awesome scripts to automate the processes.

Is there any way that you know of to stop streamer from adjusting the brightness of the image captured via a USB cam? I notice than in some of my images that the balance will be off and was wondering if there is any way I can smooth that out. Also how do you deal with a large timelapse is there anything different you suggest doing when it comes to compression or file handling? Right now I have been just having my script rm *.jpeg to cleanup after the conversion but I came to realize that trying to do that on a six hour capture in a directory on a thumb drive taxes a bit. There has to be a better way.

Once again, thanks for the awesome write up. This hardware accelerated encoding is the bees knees.

J

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Fri Apr 11, 2014 8:16 pm

Just trying this now, it seems to be stuck at "Pipeline is PREROLLING"

Any ideas where it's gone wrong?
Averagemaker.com

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Fri Apr 11, 2014 8:58 pm

sav25 wrote:Just trying this now, it seems to be stuck at "Pipeline is PREROLLING"

Any ideas where it's gone wrong?
Did your pictures capture okay? Have you checked your permissions on the folder that you are outputting to? Does it error out or just sit there? How much CPU is it using? It has been working pretty well for me. I have had a few quirks for when the Pi is running off battery. This has caused the streamer binary to become corrupted. If you have issues try removing streamer and then re-installing. If the amperage is too low the camera will end up dropping. It still shows with lsusb but I have to end up doing a reboot to make it work again. Once I stepped up the amperage everything smoothed out and I had no more loss issues.

Here are some pictures of my setup. I have improved upon it based on things I had around the home/office and based on the usage needs that my brain dreams up depending on what moment I am thinking about the Pi :)

I will post a link soon to a folder where you can view my daily time-lapse recordings.

Image
Image

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Fri Apr 11, 2014 9:54 pm

Hi

All I get is:

Code: Select all

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
...and then it just stays there, after 20 mins no movement.,

Did your pictures capture okay?

Yep they're all there, currently moving them over to my windows machine

Have you checked your permissions on the folder that you are outputting to?

I honestly don't know how to do this, but it's a vanilla Raspbian build - and I tried sudo before the command - same result

Does it error out or just sit there?

As above, just sits there. I have to exit manually.

How much CPU is it using?

Not sure how to check, i'm only using SSH. I could VNC in and watch the taskbar icon I guess? Is there a better way to check CPU usage?


Cheers
Averagemaker.com

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Sat Apr 12, 2014 12:29 am

sav25 wrote:Hi

All I get is:

Code: Select all

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
...and then it just stays there, after 20 mins no movement.,

Did your pictures capture okay?

Yep they're all there, currently moving them over to my windows machine

Have you checked your permissions on the folder that you are outputting to?

I honestly don't know how to do this, but it's a vanilla Raspbian build - and I tried sudo before the command - same result

Does it error out or just sit there?

As above, just sits there. I have to exit manually.

How much CPU is it using?

Not sure how to check, i'm only using SSH. I could VNC in and watch the taskbar icon I guess? Is there a better way to check CPU usage?


Cheers
Well I doubt it's permissions or otherwise you would see "permission denied" when trying to access the files. Plus you probably started in your ~home directory so usually that wouldn't be an issue. However just for fun do "sudo ls -al" and then "/path/to/directory/where/files/are/located" what you are looking for is drwx at the beginning of the first line (a directory with read, write, execute permissions.) However just for fun do a "sudo chmod 777 /path/to/your/timelapse" that will give everyone global permissions. Since this folder isn't mission critical we don't care too much about giving that kind of access.

To see if the process is running start another ssh session and login to the same user (or another) while that process is stuck and then type "sudo ps aux|less" to see a list of running processes and scroll through by looking at the CPU category to find it. You can press "q" to exit this screen. My guess is that it's sitting there chugging away with lots of usage but something isn't passing along somewhere.

Is your Pi getting the correct time? I know that shouldn't matter but the next step I see after mine does preroll is some type of clock sync.

We will get this working!

Jesse

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Sat Apr 12, 2014 8:18 am

Hi Jesse

Thanks for continuing to help.

Ok sudo ls -al gives me:

Code: Select all

[email protected] ~ $ sudo ls -al
total 3645808
drwxr-xr-x 13 pi   pi     69632 Apr 12 01:51 .
drwxr-xr-x  3 root root    4096 Jan  7 21:10 ..
-rw-------  1 pi   pi      5274 Apr 12 01:50 .bash_history
-rw-r--r--  1 pi   pi       220 Jan  7 21:10 .bash_logout
-rw-r--r--  1 pi   pi      3243 Jan  7 21:10 .bashrc
drwxr-xr-x  7 pi   pi      4096 Apr 11 18:50 .cache
drwxr-xr-x 11 pi   pi      4096 Apr  9 19:47 .config
drwx------  3 pi   pi      4096 Apr  3 20:36 .dbus
drwxr-xr-x  2 pi   pi      4096 Apr  7 15:46 Desktop
-rw-r--r--  1 pi   pi        35 Apr 12 01:50 .dmrc
drwxr-xr-x  2 pi   pi      4096 Apr  3 22:33 .fontconfig
drwx------  2 pi   pi      4096 Apr  3 20:36 .gvfs
drwx------  3 pi   pi      4096 Apr  4 00:31 .local
-rw-r--r--  1 pi   pi      5781 Feb  3  2013 ocr_pi.png
-rw-r--r--  1 pi   pi       675 Jan  7 21:10 .profile
drwxr-xr-x  2 pi   pi      4096 Apr 11 00:23 projects
drwxrwxr-x  2 pi   pi      4096 Mar 10  2013 python_games
-rw-r--r--  1 pi   pi   3967016 Apr  9 19:55 testimage2.jpg
drwx------  4 pi   pi      4096 Apr  3 22:42 .thumbnails
-rw-r--r--  1 pi   pi   2257010 Apr 11 18:55 timelapse0001.jpeg
-rw-r--r--  1 pi   pi   2251189 Apr 11 18:55 timelapse0002.jpeg
-rw-r--r--  1 pi   pi   2236975 Apr 11 18:55 timelapse0003.jpeg
-rw-r--r--  1 pi   pi   2245824 Apr 11 18:55 timelapse0004.jpeg
(I haven't copied all 1400 odd pictures in this list)


Next I did as you said with chmod:

Code: Select all

[email protected] ~ $ sudo chmod 777 /home/pi/

Then I did the sudo ps aux|less (but only had my phone to do it so hopefully this is readable) and this came up with:

Image

I can't see any big numbers there, but I might be looking at the wrong thing?

Either way, with all of the commands above, it's still hanging at the same point. Weird how this works for one person but not another!?

Cheers
Averagemaker.com

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Sat Apr 12, 2014 8:21 am

Oh I managed to copy the SSH code from my phone to an email, so here it is:

Code: Select all

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.3  0.5   2144   712 ?        Ss   08:54   0:01 init [2]
root         2  0.0  0.0      0     0 ?        S    08:54   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    08:54   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   08:54   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/u2:0]
root         7  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_preempt]
root         8  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_sched]
root        10  0.0  0.0      0     0 ?        S<   08:54   0:00 [khelper]
root        11  0.0  0.0      0     0 ?        S    08:54   0:00 [kdevtmpfs]
root        12  0.0  0.0      0     0 ?        S<   08:54   0:00 [netns]
root        13  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/0:1]
root        14  0.0  0.0      0     0 ?        S<   08:54   0:00 [writeback]
root        15  0.0  0.0      0     0 ?        S<   08:54   0:00 [bioset]
root        16  0.0  0.0      0     0 ?        S<   08:54   0:00 [kblockd]
root        17  0.0  0.0      0     0 ?        S    08:54   0:00 [khubd]
root        18  0.0  0.0      0     0 ?        S<   08:54   0:00 [rpciod]
root        19  0.0  0.0      0     0 ?        S    08:54   0:00 [khungtaskd]
root        20  0.0  0.0      0     0 ?        S    08:54   0:00 [kswapd0]
root        21  0.0  0.0      0     0 ?        S    08:54   0:00 [fsnotify_mark]
root        22  0.0  0.0      0     0 ?        S<   08:54   0:00 [nfsiod]
root        23  0.0  0.0      0     0 ?        S<   08:54   0:00 [crypto]
root        29  0.0  0.0      0     0 ?        S<   08:54   0:00 [kthrotld]
root        30  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQ-0]
root        31  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQr-0]
root        32  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQs-0]
root        33  0.0  0.0      0     0 ?        S<   08:54   0:00 [iscsi_eh]
root        34  0.0  0.0      0     0 ?        S<   08:54   0:00 [dwc_otg]
root        35  0.0  0.0      0     0 ?        S<   08:54   0:00 [DWC Notificatio]
root        37  0.0  0.0      0     0 ?        S<   08:54   0:00 [deferwq]
root        38  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/u2:2]
root        39  0.2  0.0      0     0 ?        S    08:54   0:01 [mmcqd/0]
root        40  0.0  0.0      0     0 ?        S    08:54   0:00 [jbd2/mmcblk0p2-]
root        41  0.0  0.0      0     0 ?        S<   08:54   0:00 [ext4-dio-unwrit]
root       156  0.1  1.0   2884  1272 ?        Ss   08:54   0:00 udevd --daemon
root       252  0.0  0.0      0     0 ?        S<   08:54   0:00 [bcm2708_spi.0]
root       280  0.0  0.8   2880   996 ?        S    08:54   0:00 udevd --daemon
root       283  0.0  0.8   2880   996 ?        S    08:54   0:00 udevd --daemon
root      1550  0.0  0.4   1748   528 ?        S    08:54   0:00 /usr/sbin/ifplugd -i wlan0 -q -f -u0 -d10 -w -I
root      1556  0.0  0.4   1748   504 ?        S    08:54   0:00 /usr/sbin/ifplugd -i lo -q -f -u0 -d10 -w -I
root      1557  0.0  0.0      0     0 ?        S    08:54   0:00 [RTW_CMD_THREAD]
root      1566  0.0  1.0   5956  1268 ?        Ss   08:54   0:00 /sbin/wpa_supplicant -s -B -P /var/run/wpa_supplicant.
lan0.pid -i wlan0 -W -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf
root      1592  0.0  0.3   2280   464 ?        Ss   08:54   0:00 /sbin/wpa_cli -B -P /var/run/wpa_action.wlan0.pid -i w
an0 -p /var/run/wpa_supplicant -a /sbin/wpa_action
root      1703  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/0:2]
root      1840  0.0  1.6   4896  1996 ?        Ss   08:55   0:00 dhclient -v -pf /run/dhclient.wlan0.pid -lf /var/lib/d
cp/dhclient.wlan0.leases wlan0
root      1937  0.0  1.2  27972  1544 ?        Sl   08:55   0:00 /usr/sbin/rsyslogd -c5
nobody    1939  0.0  0.5   2016   636 ?        Ss   08:55   0:00 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/tr
ggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user nobody /dev/input/event*
root      1999  0.0  0.6   3796   784 ?        Ss   08:55   0:00 /usr/sbin/cron
104       2010  0.0  0.9   3316  1212 ?        Ss   08:55   0:00 /usr/bin/dbus-daemon --system
root      2063  0.0  2.4  31720  3036 ?        Sl   08:55   0:00 /usr/sbin/lightdm
root      2082  0.2  5.7  13156  7116 tty7     Ss+  08:55   0:01 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten
tcp vt7 -novtswitch
ntp       2095  0.0  1.2   5512  1508 ?        Ss   08:55   0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
root      2132  0.0  0.8   6212  1064 ?        Ss   08:55   0:00 /usr/sbin/sshd
root      2163  0.0  0.6   3744   804 tty1     Ss+  08:55   0:00 /sbin/getty --noclear 38400 tty1
root      2164  0.0  0.6   3744   804 tty2     Ss+  08:55   0:00 /sbin/getty 38400 tty2
root      2165  0.0  0.6   3744   804 tty3     Ss+  08:55   0:00 /sbin/getty 38400 tty3
root      2166  0.0  0.6   3744   804 tty4     Ss+  08:55   0:00 /sbin/getty 38400 tty4
root      2167  0.0  0.6   3744   804 tty5     Ss+  08:55   0:00 /sbin/getty 38400 tty5
root      2168  0.0  0.6   3744   804 tty6     Ss+  08:55   0:00 /sbin/getty 38400 tty6
root      2169  0.0  0.5   2064   732 ttyAMA0  Ss+  08:55   0:00 /sbin/getty -L ttyAMA0 115200 vt100
root      2172  0.0  2.5  14972  3104 ?        Sl   08:55   0:00 lightdm --session-child 12 15
root      2175  0.0  3.0  26524  3712 ?        Sl   08:55   0:00 /usr/sbin/console-kit-daemon --no-daemon
root      2242  0.0  2.4  22288  3028 ?        Sl   08:55   0:00 /usr/lib/policykit-1/polkitd --no-debug
pi        2254  0.0  1.2  12796  1508 ?        Ssl  08:55   0:00 /usr/bin/lxsession -s LXDE -e LXDE
pi        2275  0.0  0.2   3524   352 ?        Ss   08:55   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-se
sion x-session-manager
pi        2278  0.0  0.5   3372   712 ?        S    08:55   0:00 /usr/bin/dbus-launch --exit-with-session x-session-man
ger
pi        2279  0.0  0.7   3308   960 ?        Ss   08:55   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-addr
ss 7 --session
pi        2285  0.1  4.9  14912  6140 ?        S    08:55   0:00 openbox --config-file /home/pi/.config/openbox/lxde-rc
xml
pi        2287  0.4  6.8 105216  8428 ?        S    08:55   0:02 lxpanel --profile LXDE
pi        2289  0.2  8.9 116596 11004 ?        S    08:55   0:01 pcmanfm --desktop --profile LXDE
pi        2294  0.0  3.8  25960  4712 ?        Sl   08:55   0:00 /usr/lib/arm-linux-gnueabihf/lxpolkit
pi        2297  0.0  1.8   8704  2308 ?        S    08:55   0:00 /usr/lib/gvfs/gvfsd
pi        2299  0.0  1.9   6456  2348 ?        S    08:55   0:00 /usr/lib/arm-linux-gnueabihf/libmenu-cache1/libexec/me
u-cached
pi        2305  0.0  2.6   9452  3232 ?        S    08:55   0:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
root      2307  0.0  2.5  14540  3196 ?        Sl   08:55   0:00 /usr/lib/udisks/udisks-daemon
root      2308  0.0  0.6   6188   796 ?        S    08:55   0:00 udisks-daemon: not polling any devices
pi        2311  0.0  1.8   8916  2264 ?        S    08:55   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
pi        2313  0.0  1.8  19136  2292 ?        Sl   08:55   0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
root      2315  0.0  2.2   9204  2804 ?        Ss   08:56   0:00 sshd: pi [priv]
pi        2319  0.0  1.5   9336  1892 ?        S    08:56   0:00 sshd: [email protected]/0
pi        2320  0.3  2.7   6236  3344 pts/0    Ss   08:56   0:01 -bash
pi        2338  0.8 10.1  85156 12532 pts/0    Sl+  09:00   0:01 gst-launch-1.0 multifilesrc location=timelapse%04d.jpe
Averagemaker.com

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Sun Apr 13, 2014 7:11 am

Here she is :
pi 2338 0.8 10.1 85156 12532 pts/0 Sl+ 09:00 0:01 gst-launch-1.0 multifilesrc location=timelapse%04d.jpe

It could be your terminal truncating the output but make sure you have this in the command gst-launch-1.0 multifilesrc location=timelapse%04d.jpeg and not timelapse%04d.jpe<---- copy and paste your entire command for me please so I can review it. Have a good day man,

Jesse


sav25 wrote:Oh I managed to copy the SSH code from my phone to an email, so here it is:

Code: Select all

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.3  0.5   2144   712 ?        Ss   08:54   0:01 init [2]
root         2  0.0  0.0      0     0 ?        S    08:54   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    08:54   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   08:54   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/u2:0]
root         7  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_preempt]
root         8  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_sched]
root        10  0.0  0.0      0     0 ?        S<   08:54   0:00 [khelper]
root        11  0.0  0.0      0     0 ?        S    08:54   0:00 [kdevtmpfs]
root        12  0.0  0.0      0     0 ?        S<   08:54   0:00 [netns]
root        13  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/0:1]
root        14  0.0  0.0      0     0 ?        S<   08:54   0:00 [writeback]
root        15  0.0  0.0      0     0 ?        S<   08:54   0:00 [bioset]
root        16  0.0  0.0      0     0 ?        S<   08:54   0:00 [kblockd]
root        17  0.0  0.0      0     0 ?        S    08:54   0:00 [khubd]
root        18  0.0  0.0      0     0 ?        S<   08:54   0:00 [rpciod]
root        19  0.0  0.0      0     0 ?        S    08:54   0:00 [khungtaskd]
root        20  0.0  0.0      0     0 ?        S    08:54   0:00 [kswapd0]
root        21  0.0  0.0      0     0 ?        S    08:54   0:00 [fsnotify_mark]
root        22  0.0  0.0      0     0 ?        S<   08:54   0:00 [nfsiod]
root        23  0.0  0.0      0     0 ?        S<   08:54   0:00 [crypto]
root        29  0.0  0.0      0     0 ?        S<   08:54   0:00 [kthrotld]
root        30  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQ-0]
root        31  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQr-0]
root        32  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQs-0]
root        33  0.0  0.0      0     0 ?        S<   08:54   0:00 [iscsi_eh]
root        34  0.0  0.0      0     0 ?        S<   08:54   0:00 [dwc_otg]
root        35  0.0  0.0      0     0 ?        S<   08:54   0:00 [DWC Notificatio]
root        37  0.0  0.0      0     0 ?        S<   08:54   0:00 [deferwq]
root        38  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/u2:2]
root        39  0.2  0.0      0     0 ?        S    08:54   0:01 [mmcqd/0]
root        40  0.0  0.0      0     0 ?        S    08:54   0:00 [jbd2/mmcblk0p2-]
root        41  0.0  0.0      0     0 ?        S<   08:54   0:00 [ext4-dio-unwrit]
root       156  0.1  1.0   2884  1272 ?        Ss   08:54   0:00 udevd --daemon
root       252  0.0  0.0      0     0 ?        S<   08:54   0:00 [bcm2708_spi.0]
root       280  0.0  0.8   2880   996 ?        S    08:54   0:00 udevd --daemon
root       283  0.0  0.8   2880   996 ?        S    08:54   0:00 udevd --daemon
root      1550  0.0  0.4   1748   528 ?        S    08:54   0:00 /usr/sbin/ifplugd -i wlan0 -q -f -u0 -d10 -w -I
root      1556  0.0  0.4   1748   504 ?        S    08:54   0:00 /usr/sbin/ifplugd -i lo -q -f -u0 -d10 -w -I
root      1557  0.0  0.0      0     0 ?        S    08:54   0:00 [RTW_CMD_THREAD]
root      1566  0.0  1.0   5956  1268 ?        Ss   08:54   0:00 /sbin/wpa_supplicant -s -B -P /var/run/wpa_supplicant.
lan0.pid -i wlan0 -W -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf
root      1592  0.0  0.3   2280   464 ?        Ss   08:54   0:00 /sbin/wpa_cli -B -P /var/run/wpa_action.wlan0.pid -i w
an0 -p /var/run/wpa_supplicant -a /sbin/wpa_action
root      1703  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/0:2]
root      1840  0.0  1.6   4896  1996 ?        Ss   08:55   0:00 dhclient -v -pf /run/dhclient.wlan0.pid -lf /var/lib/d
cp/dhclient.wlan0.leases wlan0
root      1937  0.0  1.2  27972  1544 ?        Sl   08:55   0:00 /usr/sbin/rsyslogd -c5
nobody    1939  0.0  0.5   2016   636 ?        Ss   08:55   0:00 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/tr
ggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user nobody /dev/input/event*
root      1999  0.0  0.6   3796   784 ?        Ss   08:55   0:00 /usr/sbin/cron
104       2010  0.0  0.9   3316  1212 ?        Ss   08:55   0:00 /usr/bin/dbus-daemon --system
root      2063  0.0  2.4  31720  3036 ?        Sl   08:55   0:00 /usr/sbin/lightdm
root      2082  0.2  5.7  13156  7116 tty7     Ss+  08:55   0:01 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten
tcp vt7 -novtswitch
ntp       2095  0.0  1.2   5512  1508 ?        Ss   08:55   0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
root      2132  0.0  0.8   6212  1064 ?        Ss   08:55   0:00 /usr/sbin/sshd
root      2163  0.0  0.6   3744   804 tty1     Ss+  08:55   0:00 /sbin/getty --noclear 38400 tty1
root      2164  0.0  0.6   3744   804 tty2     Ss+  08:55   0:00 /sbin/getty 38400 tty2
root      2165  0.0  0.6   3744   804 tty3     Ss+  08:55   0:00 /sbin/getty 38400 tty3
root      2166  0.0  0.6   3744   804 tty4     Ss+  08:55   0:00 /sbin/getty 38400 tty4
root      2167  0.0  0.6   3744   804 tty5     Ss+  08:55   0:00 /sbin/getty 38400 tty5
root      2168  0.0  0.6   3744   804 tty6     Ss+  08:55   0:00 /sbin/getty 38400 tty6
root      2169  0.0  0.5   2064   732 ttyAMA0  Ss+  08:55   0:00 /sbin/getty -L ttyAMA0 115200 vt100
root      2172  0.0  2.5  14972  3104 ?        Sl   08:55   0:00 lightdm --session-child 12 15
root      2175  0.0  3.0  26524  3712 ?        Sl   08:55   0:00 /usr/sbin/console-kit-daemon --no-daemon
root      2242  0.0  2.4  22288  3028 ?        Sl   08:55   0:00 /usr/lib/policykit-1/polkitd --no-debug
pi        2254  0.0  1.2  12796  1508 ?        Ssl  08:55   0:00 /usr/bin/lxsession -s LXDE -e LXDE
pi        2275  0.0  0.2   3524   352 ?        Ss   08:55   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-se
sion x-session-manager
pi        2278  0.0  0.5   3372   712 ?        S    08:55   0:00 /usr/bin/dbus-launch --exit-with-session x-session-man
ger
pi        2279  0.0  0.7   3308   960 ?        Ss   08:55   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-addr
ss 7 --session
pi        2285  0.1  4.9  14912  6140 ?        S    08:55   0:00 openbox --config-file /home/pi/.config/openbox/lxde-rc
xml
pi        2287  0.4  6.8 105216  8428 ?        S    08:55   0:02 lxpanel --profile LXDE
pi        2289  0.2  8.9 116596 11004 ?        S    08:55   0:01 pcmanfm --desktop --profile LXDE
pi        2294  0.0  3.8  25960  4712 ?        Sl   08:55   0:00 /usr/lib/arm-linux-gnueabihf/lxpolkit
pi        2297  0.0  1.8   8704  2308 ?        S    08:55   0:00 /usr/lib/gvfs/gvfsd
pi        2299  0.0  1.9   6456  2348 ?        S    08:55   0:00 /usr/lib/arm-linux-gnueabihf/libmenu-cache1/libexec/me
u-cached
pi        2305  0.0  2.6   9452  3232 ?        S    08:55   0:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
root      2307  0.0  2.5  14540  3196 ?        Sl   08:55   0:00 /usr/lib/udisks/udisks-daemon
root      2308  0.0  0.6   6188   796 ?        S    08:55   0:00 udisks-daemon: not polling any devices
pi        2311  0.0  1.8   8916  2264 ?        S    08:55   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
pi        2313  0.0  1.8  19136  2292 ?        Sl   08:55   0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
root      2315  0.0  2.2   9204  2804 ?        Ss   08:56   0:00 sshd: pi [priv]
pi        2319  0.0  1.5   9336  1892 ?        S    08:56   0:00 sshd: [email protected]/0
pi        2320  0.3  2.7   6236  3344 pts/0    Ss   08:56   0:01 -bash
pi        2338  0.8 10.1  85156 12532 pts/0    Sl+  09:00   0:01 gst-launch-1.0 multifilesrc location=timelapse%04d.jpe

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Bash script for automation

Sun Apr 13, 2014 7:42 am

Here is a script I made. It's still a work in progress as I am so new to scripting but to use this script as is
1. Make a directory called Timelapse in the root of your file system

Code: Select all

sudo mkdir /Timelapse
(You can make any directory you wish. Just make sure to change the relative variable in the script to reflect the path of your folder)

2. Make the directory have proper permissions

Code: Select all

sudo chmod 777 /Timelapse
(these permissions are pretty insecure but it simplifies things in this case and this folder nor your Pi should be used for sensitive data anyway)

3. Make the following code into a script by typing

Code: Select all

sudo nano /usr/local/bin/onehourtimelapse
and pasting the contents of this

Code: Select all

now=$(date +"%I:%M%P")
day=$(date +"%m-%d")
# relative directory must already exsist!
relative=/Timelapse
echo "Now creating folders and setting up files..."
mkdir $relative/$day/
mkdir $relative/$day/$now/
echo "Beginning timelapse recording for one hour starting at $now "
/usr/bin/streamer -t 1440 -r 0.4 -s 1280x720 -o $relative/$day/$now/timelapse0000.jpeg
echo "Timelapse capture completed `date + "%r"` "
echo
sync
echo
echo
echo "Now converting video (This may take a few minutes...)"
/usr/bin/gst-launch-1.0 multifilesrc location=$relative/$day/$now/timelapse%04d.jpeg index=1 caps="image/jpeg,framerate=24/1" ! jpegdec ! omxh264enc ! avimux ! filesink location =$$
echo "Conversion complete"
echo
echo
echo "Cleaning up...."
sudo rm -rf $relative/$day/$now/
clear
echo "Your timelapse video is ready! You may view your video at $relative/$day/$now.avi"
echo
code into that file. After this you write to the file and close it by pressing "F2 and Y"

4. make the script executible

Code: Select all

sudo chmod +x /usr/local/bin/onehourtimelapse
5. To use this script now all you have to do is type onehourtimelapse and press enter. This will make a folder inside of the directory you created by date and sort the files by time that you started the recording.


What I like about this solution is that I can just setup a cron job to have this run at whatever time I want.
So if I want to capture the morning sunrise I would add this to cron by typing "sudo crontab -e" on the very next line after the comments I added "PATH=/usr/sbin:/usr/bin:/sbin:/bin" this allows me to call commands in a more relative way. Then to setup my sunrise time-lapse on the next line I type " 00 6 * * * /usr/local/bin/onehourtimelapse" or if I want it to be a specific day I would type "00 6 13 4 * /usr/local/bin/onehourtimelapse" to have it record for today at 6:30AM. Imagine what you can do with this kind of ability!

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Check out my daily timelapse here

Mon Apr 14, 2014 7:02 pm

Here is the link for my daily time-lapse recordings (the Sunrise or cloudiness of the Pacific Northwest:)
http://timelapse.smallheart.org/

I haven't setup a page to direct the links so for now just right click on the link (control click on OSX ;) and save the file before opening it. I have setup a script to upload these to my ftp server nightly so check back daily for yesterdays sunrise (and to see if it actually worked.)

J

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Wed Apr 16, 2014 8:58 pm

Cheers both - had my head in other projects but will look at this again tomorrow in preparation for a long car journey time-lapse :)
Averagemaker.com

User avatar
holdmyheadwhileipuke
Posts: 11
Joined: Thu Apr 03, 2014 8:33 pm
Location: Somewhere out west.
Contact: Website

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Thu Apr 17, 2014 2:22 am

sav25 wrote:Cheers both - had my head in other projects but will look at this again tomorrow in preparation for a long car journey time-lapse :)
Yeah I hear you there. My Pi has so many projects going for it. I just need to break down and buy four more! I took a look at your blog and I started out with the same type of project but I ended up using a screen connected via I2C this made things a little bit tricky. I figured out some interesting scrolling solutions though. I'm sure your problem is how do you get one line to scroll and not the other? Or did you solve that.

J

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Thu Apr 17, 2014 6:46 am

Solved that, pretty much got it where I want it but noq I get some odd crash out happening aftwr 30 minutes...could me my internet connection though
Averagemaker.com

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Sat Apr 19, 2014 7:04 am

holdmyheadwhileipuke wrote:Here she is :
pi 2338 0.8 10.1 85156 12532 pts/0 Sl+ 09:00 0:01 gst-launch-1.0 multifilesrc location=timelapse%04d.jpe

It could be your terminal truncating the output but make sure you have this in the command gst-launch-1.0 multifilesrc location=timelapse%04d.jpeg and not timelapse%04d.jpe<---- copy and paste your entire command for me please so I can review it. Have a good day man,

Jesse


sav25 wrote:Oh I managed to copy the SSH code from my phone to an email, so here it is:

Code: Select all

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.3  0.5   2144   712 ?        Ss   08:54   0:01 init [2]
root         2  0.0  0.0      0     0 ?        S    08:54   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    08:54   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   08:54   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/u2:0]
root         7  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_preempt]
root         8  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    08:54   0:00 [rcu_sched]
root        10  0.0  0.0      0     0 ?        S<   08:54   0:00 [khelper]
root        11  0.0  0.0      0     0 ?        S    08:54   0:00 [kdevtmpfs]
root        12  0.0  0.0      0     0 ?        S<   08:54   0:00 [netns]
root        13  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/0:1]
root        14  0.0  0.0      0     0 ?        S<   08:54   0:00 [writeback]
root        15  0.0  0.0      0     0 ?        S<   08:54   0:00 [bioset]
root        16  0.0  0.0      0     0 ?        S<   08:54   0:00 [kblockd]
root        17  0.0  0.0      0     0 ?        S    08:54   0:00 [khubd]
root        18  0.0  0.0      0     0 ?        S<   08:54   0:00 [rpciod]
root        19  0.0  0.0      0     0 ?        S    08:54   0:00 [khungtaskd]
root        20  0.0  0.0      0     0 ?        S    08:54   0:00 [kswapd0]
root        21  0.0  0.0      0     0 ?        S    08:54   0:00 [fsnotify_mark]
root        22  0.0  0.0      0     0 ?        S<   08:54   0:00 [nfsiod]
root        23  0.0  0.0      0     0 ?        S<   08:54   0:00 [crypto]
root        29  0.0  0.0      0     0 ?        S<   08:54   0:00 [kthrotld]
root        30  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQ-0]
root        31  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQr-0]
root        32  0.0  0.0      0     0 ?        S<   08:54   0:00 [VCHIQs-0]
root        33  0.0  0.0      0     0 ?        S<   08:54   0:00 [iscsi_eh]
root        34  0.0  0.0      0     0 ?        S<   08:54   0:00 [dwc_otg]
root        35  0.0  0.0      0     0 ?        S<   08:54   0:00 [DWC Notificatio]
root        37  0.0  0.0      0     0 ?        S<   08:54   0:00 [deferwq]
root        38  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/u2:2]
root        39  0.2  0.0      0     0 ?        S    08:54   0:01 [mmcqd/0]
root        40  0.0  0.0      0     0 ?        S    08:54   0:00 [jbd2/mmcblk0p2-]
root        41  0.0  0.0      0     0 ?        S<   08:54   0:00 [ext4-dio-unwrit]
root       156  0.1  1.0   2884  1272 ?        Ss   08:54   0:00 udevd --daemon
root       252  0.0  0.0      0     0 ?        S<   08:54   0:00 [bcm2708_spi.0]
root       280  0.0  0.8   2880   996 ?        S    08:54   0:00 udevd --daemon
root       283  0.0  0.8   2880   996 ?        S    08:54   0:00 udevd --daemon
root      1550  0.0  0.4   1748   528 ?        S    08:54   0:00 /usr/sbin/ifplugd -i wlan0 -q -f -u0 -d10 -w -I
root      1556  0.0  0.4   1748   504 ?        S    08:54   0:00 /usr/sbin/ifplugd -i lo -q -f -u0 -d10 -w -I
root      1557  0.0  0.0      0     0 ?        S    08:54   0:00 [RTW_CMD_THREAD]
root      1566  0.0  1.0   5956  1268 ?        Ss   08:54   0:00 /sbin/wpa_supplicant -s -B -P /var/run/wpa_supplicant.
lan0.pid -i wlan0 -W -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf
root      1592  0.0  0.3   2280   464 ?        Ss   08:54   0:00 /sbin/wpa_cli -B -P /var/run/wpa_action.wlan0.pid -i w
an0 -p /var/run/wpa_supplicant -a /sbin/wpa_action
root      1703  0.0  0.0      0     0 ?        S    08:54   0:00 [kworker/0:2]
root      1840  0.0  1.6   4896  1996 ?        Ss   08:55   0:00 dhclient -v -pf /run/dhclient.wlan0.pid -lf /var/lib/d
cp/dhclient.wlan0.leases wlan0
root      1937  0.0  1.2  27972  1544 ?        Sl   08:55   0:00 /usr/sbin/rsyslogd -c5
nobody    1939  0.0  0.5   2016   636 ?        Ss   08:55   0:00 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/tr
ggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user nobody /dev/input/event*
root      1999  0.0  0.6   3796   784 ?        Ss   08:55   0:00 /usr/sbin/cron
104       2010  0.0  0.9   3316  1212 ?        Ss   08:55   0:00 /usr/bin/dbus-daemon --system
root      2063  0.0  2.4  31720  3036 ?        Sl   08:55   0:00 /usr/sbin/lightdm
root      2082  0.2  5.7  13156  7116 tty7     Ss+  08:55   0:01 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten
tcp vt7 -novtswitch
ntp       2095  0.0  1.2   5512  1508 ?        Ss   08:55   0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
root      2132  0.0  0.8   6212  1064 ?        Ss   08:55   0:00 /usr/sbin/sshd
root      2163  0.0  0.6   3744   804 tty1     Ss+  08:55   0:00 /sbin/getty --noclear 38400 tty1
root      2164  0.0  0.6   3744   804 tty2     Ss+  08:55   0:00 /sbin/getty 38400 tty2
root      2165  0.0  0.6   3744   804 tty3     Ss+  08:55   0:00 /sbin/getty 38400 tty3
root      2166  0.0  0.6   3744   804 tty4     Ss+  08:55   0:00 /sbin/getty 38400 tty4
root      2167  0.0  0.6   3744   804 tty5     Ss+  08:55   0:00 /sbin/getty 38400 tty5
root      2168  0.0  0.6   3744   804 tty6     Ss+  08:55   0:00 /sbin/getty 38400 tty6
root      2169  0.0  0.5   2064   732 ttyAMA0  Ss+  08:55   0:00 /sbin/getty -L ttyAMA0 115200 vt100
root      2172  0.0  2.5  14972  3104 ?        Sl   08:55   0:00 lightdm --session-child 12 15
root      2175  0.0  3.0  26524  3712 ?        Sl   08:55   0:00 /usr/sbin/console-kit-daemon --no-daemon
root      2242  0.0  2.4  22288  3028 ?        Sl   08:55   0:00 /usr/lib/policykit-1/polkitd --no-debug
pi        2254  0.0  1.2  12796  1508 ?        Ssl  08:55   0:00 /usr/bin/lxsession -s LXDE -e LXDE
pi        2275  0.0  0.2   3524   352 ?        Ss   08:55   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-se
sion x-session-manager
pi        2278  0.0  0.5   3372   712 ?        S    08:55   0:00 /usr/bin/dbus-launch --exit-with-session x-session-man
ger
pi        2279  0.0  0.7   3308   960 ?        Ss   08:55   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-addr
ss 7 --session
pi        2285  0.1  4.9  14912  6140 ?        S    08:55   0:00 openbox --config-file /home/pi/.config/openbox/lxde-rc
xml
pi        2287  0.4  6.8 105216  8428 ?        S    08:55   0:02 lxpanel --profile LXDE
pi        2289  0.2  8.9 116596 11004 ?        S    08:55   0:01 pcmanfm --desktop --profile LXDE
pi        2294  0.0  3.8  25960  4712 ?        Sl   08:55   0:00 /usr/lib/arm-linux-gnueabihf/lxpolkit
pi        2297  0.0  1.8   8704  2308 ?        S    08:55   0:00 /usr/lib/gvfs/gvfsd
pi        2299  0.0  1.9   6456  2348 ?        S    08:55   0:00 /usr/lib/arm-linux-gnueabihf/libmenu-cache1/libexec/me
u-cached
pi        2305  0.0  2.6   9452  3232 ?        S    08:55   0:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
root      2307  0.0  2.5  14540  3196 ?        Sl   08:55   0:00 /usr/lib/udisks/udisks-daemon
root      2308  0.0  0.6   6188   796 ?        S    08:55   0:00 udisks-daemon: not polling any devices
pi        2311  0.0  1.8   8916  2264 ?        S    08:55   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
pi        2313  0.0  1.8  19136  2292 ?        Sl   08:55   0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
root      2315  0.0  2.2   9204  2804 ?        Ss   08:56   0:00 sshd: pi [priv]
pi        2319  0.0  1.5   9336  1892 ?        S    08:56   0:00 sshd: [email protected]/0
pi        2320  0.3  2.7   6236  3344 pts/0    Ss   08:56   0:01 -bash
pi        2338  0.8 10.1  85156 12532 pts/0    Sl+  09:00   0:01 gst-launch-1.0 multifilesrc location=timelapse%04d.jpe
Jesse

Tried the following:

Code: Select all

gst-launch-1.0 multifilesrc location=timelapse%05d.jpeg index=1 caps="image/jpeg,framerate=24/1" ! jpegdec ! omxh264enc ! avimux ! filesink location=timelapsetester.avi
Changed the length of the image names as I used 5 digits, and changed the file name, but that's it. Still doesn't work. So annoying
Averagemaker.com

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Mon Apr 21, 2014 9:02 am

Hey sav25,

Have you made any progress? I am now having the same issue.

Love the tutorial but it is not working. :(

wallarug

User avatar
sav25
Posts: 364
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Mon Apr 21, 2014 9:12 am

Wallarug,

Using the original method I've still had no success. I thought it might be the truncating so I used VNC to access the Pi's Terminal directly, even typing it manually, but still no luck.

I need to try the other method on here, but have had my head in other things this weekend.
Averagemaker.com

jmzhwng
Posts: 1
Joined: Mon May 05, 2014 10:59 pm

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Mon May 05, 2014 11:03 pm

Anyone know how to encode it to .mp4 instead of .avi?
Been having trouble figuring it out

tvjon
Posts: 710
Joined: Mon Jan 07, 2013 9:11 am

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Fri May 09, 2014 11:36 am

Just change .avi to mp4 & it should play with most players that expect mpeg4.


[email protected] /run/shm/4 $ mediainfo timelapse.avi
General
Complete name : timelapse.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 192 KiB
Duration : 6s 125ms
Overall bit rate : 256 Kbps

Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, ReFrames : 1 frame
Codec ID : H264
Duration : 6s 125ms
Bit rate : 251 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 24.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.034
Stream size : 187 KiB (98%)

@ phamthanhnam » 18 Mar 2014, 15:28

"I hope this tutorial will help you deal some technical issues in making time-lapse video with Raspberry Pi. You can combine this tutorial with your own discoveries to make things better. You can film many interesting time-lapse videos, such as blossoming flower, growing tree, slow chemical reaction, butterfly transformation, moving clouds, moving snail... and much more, it's your creativity! Have fun to lapse time!"

Yes, true, & thank you for your tutorial. Your video demonstrates an inexpensive way to make a special effect :)

It's my first successful use of gstreamer on RPi.

Now I need some time to experiment.

User avatar
Mettauk
Posts: 237
Joined: Mon Dec 10, 2012 12:40 pm
Location: Zarg

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Fri May 09, 2014 4:34 pm

Works well, not sure about video quality though? I've been using

Code: Select all

raspistill -w 1280 -h 720 -x -n -tl 1000 -t 720000 -o /tlCAP/tl_%06d.jpg
IF FRAMES ARE DROPPED during timelapse image recording then the video encoding seems to stop at the first dropped frame??

Any sugestions how to allow it to skip from say timelapse0008.jpeg to timelapse0010.jpeg rather than stop?
As humans we have been the same for a very very long time, technology changes how we do... not who we are as people.

allsorts
Posts: 3
Joined: Wed May 14, 2014 4:29 pm
Location: North Pennines, UK

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Wed May 14, 2014 4:44 pm

Just installed this timelapse system and had the "stuck at prerolll" problem. The individual image files were over 3 MB each and fairly high resolution. I'm using a bash script and raspistill (but not its time lapse mode) to create the source files. When I reduced the file size to about 100 KB each and 800 x 450 it flies through generating the .avi. So check what size/resolution the source files are...

Quality is a bit low but then I'm using --quality 15 on raspistill to reduce the filesize. Primary use is a static webcam though this time lapse looks good.

Just above this post is mention of .mp4 rather than .avi, is it really just an extension change?

Thanks for the tutorial, waiting for more images to build up... B-)

Cheers
Dave.
--
Cheers
Dave.

kinokikid
Posts: 10
Joined: Sat Nov 09, 2013 2:01 am

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Sat May 17, 2014 4:34 pm

Thanks Dave,

I have had the same "stuck at preroll" problem. Your suggestion solved the problem. Still I wonder why it is so difficult to create a video from images with the maximum resolution of the camera unit. Every result I got yet was awfull in quality.

allsorts
Posts: 3
Joined: Wed May 14, 2014 4:29 pm
Location: North Pennines, UK

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Mon May 19, 2014 12:13 pm

kinokikid wrote:I have had the same "stuck at preroll" problem. Your suggestion solved the problem.
Great, glad to be of help.
kinokikid wrote:Still I wonder why it is so difficult to create a video from images with the maximum resolution of the camera unit. Every result I got yet was awfull in quality.
Aye, I've managed to kick my system into generating a useable mp4 but the quality is awful. I'd like to fiddle with the control-rate and target-bitrate settings of omxh264enc but it can't open the required libray (Gst 1.0 + omx from the prepackaged German repo). See my post of earlier this morning over in "Gstreamer 1.0 for raspbian" http://www.raspberrypi.org/forums/viewt ... 67#p552767.

The Raspberry Pi camera has a max resolution well above that of "HD" video. HD is 1920x1080, a tad over 2 M pixels, at best. When I get the time I'm going adjust my stills gathering script and remove the "--quality 15" on raspistill so the video source jpg's have only gone through minimal lossy compression before getting encoded by another lossy compression system for the video. Chaining lossy compression methods is not a good idea. As my primary use of stills and video is the web I'm going to retain the 800x448 size.

Cheers
Dave.

deherbs
Posts: 1
Joined: Thu Jun 12, 2014 11:16 pm
Location: Bay Area, CA USA

Re: [Tutorial] Making time-lapse video with Raspberry Pi

Thu Jun 12, 2014 11:30 pm

First, thanks for this tutorial! I really like that you do everything on the rPI.
I currently have the rPI model B with the rPI camera installed and setup in a PiCE case http://elsondesigns.com/
I couldn't get it work properly at first due to skipping/dropping/missing jpegs (the encoder would freeze up while trying to encode)

These are the steps I took to get it working on my setup:

## capture for 10 mins @ 1 image/second ##

Code: Select all

raspistill -rot 90 -w 1280 -h 720 -x -n -tl 1000 -t 600000 -o tl_%06d.jpg
## install gawk if not already installed ##

Code: Select all

sudo apt-get install gawk
## rename all files in sequential order (to fill in missing files so encoder can run properly) ##

Code: Select all

find -name '*.jpg' | gawk 'BEGIN{ a=1 }{ printf "mv %s %06d.jpg\n", $0, a++ }' | bash
## encode images into an .avi file ##

Code: Select all

gst-launch-1.0 multifilesrc location=%06d.jpg index=1 caps="image/jpeg,framerate=30/1" ! jpegdec ! omxh264enc ! avimux ! filesink location=timelapse.avi
Hope this helps anyone who got stuck like I did!
Cheers,

Return to “Graphics, sound and multimedia”