since they’re tearing down the buildings in front of our office and there’s been a cool webcam positioned near the site i wrote a little script to get the images and wanted to convert them into a time-lapse…
here’s the knowledge i gained from this little experiment.
first i thought that image magick could do the trick, i noticed that to create a mpeg2 video i needed a little encode program that i found here.
compiled this and moved it to /usr/bin
then i executed convert in my image directory
convert -delay 10 *.jpg m2v:time_lapse-test.mpg |
the output was a nice little motion jpeg which i couldn’t use in my little video software called open movie editor (there’s probably better stuff out there but this is the first one i found and tried and seemed simple)
so i tried the ffmpeg approach
ffmpeg -r 5 -i %12d.jpg -y -an time_lapse-test.mpg |
which i didn’t get working at all since the regex type image path just didn’t seem to find any images… so i gave up quite quickly.
so the next try was mencoder (should’ve tried this to begin with since mplayer/mencoder can just about do anything)
mencoder -ovc lavc -mf fps=3:type=jpg 'mf://*.jpg' -o time_lapse-test.avi |
the result was a bad quality video… so i started using some params to get this sorted out
using this as help i tried “-ovc copy”, which was great and gave me a 1 to 1 copy of the jpegs
mencoder -ovc copy -mf w=800:h=371:fps=6:type=jpg 'mf://*.jpg' -o time_lapse-test.avi |
great!! … i’m back at the mjpg which i can’t use in open movie editor!
so let’s encode it into some other video codec… i installed x264 and tried:
mencoder mf://*.jpg -mf w=800:h=371:fps=15:type=jpg -ovc x264 -x264encopts subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:qp_constant=26 -o time_lapse-test.avi |
and i just didn’t get it to work without having to compile things… so i gave up once more ;)
some more research and after testing a few different bitrates, this is what gave me good results:
mencoder -nosound mf://*.jpg -mf w=800:h=371:type=jpg:fps=15 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2160000:mbd=2:keyint=132:v4mv:vqmin=3:lumi_mask=0.07:dark_mask=0.2:mpeg_quant:scplx_mask=0.1:tcplx_mask=0.1:naq -o time_lapse-test.avi |
the important things here is setting the frames per second to 15 and the codec to mpeg4 with a bitrate of 2160000. everything else was gathered on different sites and really almost make no difference (in what you see at least)
so then i quickly edited movie… and saved it, it was way too big so encoded it again but this time with 2 passes and a smaller bitrate:
mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=1620000:mbd=2:keyint=132:v4mv:vqmin=3:vlelim=-4:vcelim=7:lumi_mask=0.07:dark_mask=0.10:naq:vqcomp=0.7:vqblur=0.2:mpeg_quant -mf type=sgi:fps=25 -nosound -o /dev/null time_lapse-test.avi |
to generate the divx2pass.log then in the second pass i also added the mp3 music:
mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=1620000:mbd=2:keyint=132:v4mv:vqmin=3:vlelim=-4:vcelim=7:lumi_mask=0.07:dark_mask=0.10:naq:vqcomp=0.7:vqblur=0.2:mpeg_quant -mf type=sgi:fps=25 -audiofile "/home/me/music.mp3" -oac copy -o time-lapse_216k_mp3.avi time_lapse-test.avi |
and there you have the final movie!
delete divx2pass.log and upload to youtube :)
oh yeah… and added some meta tags
ffmpeg -title "destruction time-lapse" -author "munzli" -comment "www.munz.li" -acodec copy -vcodec copy -i time-lapse_162k_mp3.avi time-lapse_162k_mp3_meta.avi |
and here you have it (needs to be high quality because compressed it looks even worse)
[edit]
well youtube blocked my video saying that a copyright owner has claimed it owns some or all of the audio content in my video. oh well the music industry is just something you shouldn’t support! just don’t understand why you can’t have a little video online that even mentions the music at the end and might even bring a song to a wider audience!
i encourage everybody to use riaaradar before purchasing their next album!
Pingback: Recent Links Tagged With "mencoder" - JabberTags
this works with the new youtube HD feature:
ffmpeg -loop_input -f image2 -t -i -vcodec msmpeg4v2 -b 2000k -s hd720 -r 25 -i -acodec copy
Pingback: Timelapse con Canon Rebel (EOS), Arduino, y FFMPEG - DIY - MCCWN
Pingback: Manuel 2.0» Blog Archive » Polternight
Pingback: Fernando.com.ar » Blog Archive » Timelapse con Canon Rebel (EOS), Arduino, y FFMPEG
Hi munzli,
thanks for this article, you helped me find the command for converting images to videos for the second time.
Greetings janusz
Hi…
You know how to make the video taking the images from another directory? I’m working with Windows…
I tried this:
mencoder mf://.\\mydirectory\\*.JPG -mf fps=5:type=JPG -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=3500 -oac copy -o test.avi
It just make a 5 KB video file.
Thank you!
i’m not quite sure since i don’t use windows… but my guess would be something like:
mencoder mf://\mydirectory\*.JPG -mf fps=5:type=JPG -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=3500 -oac copy -o test.avi
and why not just go into the image directory and call mencoder from there?
c:\location\of\mencoder mf://*.JPG -mf fps=5:type=JPG -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=3500 -oac copy -o test.avi
If you use audio which has been recorded from a general broadcast FM or AM USA radio you will have no problems in using such general broadcast music in your videos. You only need to NOT USE that which is not for general dissemination like you find on cable and satellite TV. You have no restrictions on media which was intended for general broadcast. Such media looses any copyright protections. Or at least so indicated within the FCC part of the code of federal regulations. Your answers will lie within the CFR.
Pingback: My first time-lapse. The Linux easy way | Project log