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 176×144 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.
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.







Streaming using ffmpeg.
Converting mp3 to amr is simple:
ffmpeg -i temp.mp3 -ac 1 -ab 8 -ar 8000 -f amr -acodec amr_nb temp.amr
I’m using the ffmpeg for converting mp3 to amr files, but I don’t understand what it happening…it is not working…
see the log:
ffmpeg -i temp.mp3 -ac 1 -ab 8 -ar 8000 -f amr -acodec amr_nb temp.amr
ffmpeg: /usr/lib/libtheora.so.0: no version information available (required by /usr/lib/libavcodec.so.0d)
FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
configuration: –enable-gpl –enable-pp –enable-pthreads –enable-vorbis –enable-libogg –enable-theora –enable-a52 –enable-dts –enable-dc1394 –enable-libgsm –disable-debug –prefix=/usr
libavutil version: 0d.49.0.0
libavcodec version: 0d.51.8.0
libavformat version: 0d.50.4.0
built on Jul 3 2006 17:51:39, gcc: 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)
Input #0, mp3, from ‘temp.mp3′:
Duration: 00:00:18.8, start: 0.000000, bitrate: 32 kb/s
Stream #0.0: Audio: mp3, 22050 Hz, mono, 32 kb/s
Unknown input or output format: amr
Help me please?
@Piu: I see u haven’t enabled amr with in ur ffmpeg compilation, due to certain licencing issues ffmpeg’s codebase doesn’t include amr code, you have to download it separately and follow simple intructions to put the directory inside the ffmpeg code base and configure with option –enable-amr or something similar
Hope that helps!