Converting video formats in unix
I give no explanations. You can consult your man page for that. My aim is to write quick and dirty hacks, not an entire book on the topic.
We will be using 3 tools: transcode, mplayer’s mencoder and ffmpeg — all commandline tools. Anybody who has been keeping track of this journal should by now be aware that if I can, I avoid GUI point-n-click apps like the plague. Lastly, this mini howto is by no means exhaustive.
Basics
mencoder
-ovc codec for video output
-oac codec for audio output
-o outfile.avi
mencoder infile.avi -ovc lavc -oac lavc -o outfile.avi
transcode
-i input_filename.mpg
-y codec for audio/video output
-o output_filename.avi
transcode -i infile.mpg -o outfile.avi -y divx
ffmpeg
ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
Video CD
ffmpeg -i infile.avi -target ntsc-vcd outfile.mpg
Flash Videos
ffmpeg -i infile.mpg -ab 256 outfile.flv
*note:
XviD
First, something about video bitrates.
- Crummy youtube-like video is around 80-150.
- VCD quality is around 400-500.
- DVD quality is approx 800.
- Default bitrate for mencoder is 687kbps.
mencoder infile.avi -ovc xvid -oac mp3lame -xvidencopts bitrate=687 -o outfile.avi
*notes:
-bitrate=-700000 – will give you a ~700mb avi file.
mencoder infile.wmv -ofps 23.976 -oac mp3lame -lameopts abr:br=92 -ovc xvid -xvidencopts pass=2:bitrate=150 -o audiofix-150bit-xvid.avi
-lameopts switch if you’re using mp3lame (-oac mp3lame) for the audio format:mencoder infile.avi -ovc xvid -oac mp3lame -lameopts abr:br=256 -xvidencopts bitrate=800 -o outfile.avi
Microsoft media files (*.wmv, *.asf, *.wmx)
Just follow the howto for Xvid and replace the infile.avi with any M$.wmv file you have. There’s an issue regarding some players (Xine) not being able to play wmv->xvid files converted using mencoder. Just use the -ofps 23.976 switch for that.
DivX
transcode -i infile.mpg -o outfile.avi -y divx
DVD
ffmpeg -i infile.avi -target ntsc-dvd dvd.mpg
You can now use any of the hoardes of dvd authoring tools that your favorite distro has in its repository to make a dvd out of the output mpegs you create here.
That’s all for now. If I missed anything or something doesn’t work I’m just here.





