Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video from photos using mencoder?

Tags:

video

mencoder

During the day I take pictures from the camera every minute. I would like to make a video from the images. 1 day -> 1 video

I use mencoder to do that at the end of the day like this: mencoder "mf://*.jpg" -mf fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:vbitrate=7000 -vf scale=1024:768 -oac copy -o movie.avi It works fine, BUT:

The problem is that i need to do it on Raspberry Pi (700MHz ARM) and it takes him about an hour to make the video from 1500 photos taken during the day (it works at about 0.5 fps).

Is there any way how to make the video "continuously" - how to pass each picture to the mencoder right after it is taken - and stop making the video every day at midnight? It would then just take a picture, process it for a 2-3 seconds and wait for another minute to do it again.

Thanks.

like image 454
user2193024 Avatar asked Nov 04 '22 01:11

user2193024


1 Answers

This does not provide the answer for mencoder, but for ffmpeg as allowed in the comments.

Requirements:

  • All pictures must be consecutively numbered (i.e. picName1.png, picName2.png, etc.)
  • All pictures must be in the same folder.
  • You must have the latest version of ffmpeg since the options recently changed

To create your video use:

ffmpeg -r fps -f image2 -i '/path/to/your/picName%d.png' -qscale 0 '/path/to/your/new/video.avi'
  • Replace fps by the desired frame rate (10, 25, 30, etc) fps.
  • Replace /path/to/your/picName by the actual path, but leave the %d which tells ffmpeg to put a number there.
  • Replace /path/to/your/new/video.avi by your selected destination.

The video created this way will be of the highest quality. You can adapt the quality to match your video size requirements using the -q option.

See the man page for ffmpeg for more explanations.

Unfortunately, to my knowledge, there is no way to pass one picture every few minutes or so. I would suggest one of the solutions below:

  • Compile the video once a day, at midnight. You get it at 1 am.
  • Compile the video several time a day, if you need to look at it. That's a lot of wasted processing, since you process the whole lot each time.
  • Compile the video by chunks (every 2 hours for instance) and merge all videos at the end of the day.

If you don't need to look at the video during the day, then the first solution is the easiest.


Below is a quote from the man page:

For creating a video from many images:

ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi The syntax "foo-%03d.jpeg" specifies to use a decimal number composed of three digits padded with zeroes to express the sequence number. It is the same syntax supported by the C printf function, but only formats accepting a normal integer are suitable.

like image 109
Jean Avatar answered Dec 28 '22 07:12

Jean