Friday, May 20, 2005

Video Encoding from frames in Linux

I knew I had to learn this someday and the day arrived. What I needed to do was to encode multiple image frames in to a Video.
I was told the ffmpeg is generally used for such things so I tried searching on web. I got this as the command to be used
ffmpeg -i frame%03d.ppm output.avi
in general if you want to convert some video format in to other the ffmpeg may be a good tool.. complete documentation can be found here.
But the command somehow didn't work as desired I was getting a video but the frames inside were distorted by some god-knows-what-function. After trying a lot I thought of searching for the same using mencoder, my favourite video editing program till now.
I finally used this command which worked for me as I wanted.
mencoder "mf://frame*.jpg" -mf w=300:h=380:type=jpeg:fps=25 -o output.avi -ovc copy


Some example usage of ffmpeg/mencoder:
*Converting a mp3 song to wav
ffmpeg -i Frozen.mp3 Frozen.wav
*You can transcode decrypted VOBs (Example from manpage, When I tried it didn't work for my vob file)
ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
*Very comprehensive example from excamera
This example converts a avi file to a 3gp file for viewing in Nokia 3650 cell phone. (cool na?)

./ffmpeg -i foo.avi
-s qcif -r 12 # convert video to 176x144 at 12 fps
-ac 1 -ar 8000 # convert audio to mono, 8000 Hz
-b 30 # video rate 30kbps
-ab 12 # audio rate 12kbps
-t 60 # first 60 seconds only
foo.3gp # output file
Some useful options are (helpful for cutting/clipping videos)
`-t duration'

set the recording time in seconds. hh:mm:ss[.xxx] syntax is also supported.
`-ss position'
<>
seek to given time position. hh:mm:ss[.xxx] syntax is also supported.
I will trying more examples as an when I come to use/need them :)

Mencoder someone already has a better page than my current Info.Link

More examples will be added soon. I wish to finally have a how do I list of things, if you want to suggest something please do so.

1 comment: