Useful video transcoding commands
One of the handiest tools in my Linux toolchest is FFMPEG, the universal media transcoder. I'm pretty sure this fantastically useful piece of software runs in the background of every service that converts audio or video from one format to another (Google video, YouTube, Archive.org, etc). Over the years I've amassed a small collection of commands that will allow me to take media from one source and convert it for use in another - for example ripping video from a DVD or the web and then editing it and burning it back to DVD.
If you encounter problems running any of these commands be sure to install the full (restricted) version of ffmpeg as per this thread. If you are looking for instructions on how to convert video for the Google Nexus One running Android read this post!. Hopefully these will prove to be of use to you:
1) Converting any video to DVD-compatible MPEG2:
ffmpeg -y -i inputfile.xyz -vcodec mpeg2video -target ntsc-dvd -r ntsc -deinterlace -aspect 4:3 outputfile.m2v
2) Converting video for the web (w/o frame size reduction):
ffmpeg -i inputfile.xyz -f avi -vcodec mpeg4 -ab 128 output.avi
3) Convert DVD (MPEG2) files to MPEG4:
ffmpeg -i inputfile.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 outputfile.avi
4) Prepare Cinelerra edited .DV (from Canon GL1*) for Google video upload:
ffmpeg -i inputfile.dv -f avi -vcodec mpeg4 -cropleft 8 -cropright 4 -s 640x480 -b 1200 -g 300 -bf 2 -acodec mp3 -ab 128 outputfile.avi
5) Convert electric sheep for Resiloom:
ffmpeg -i inputfile.mpg -f avi -vcodec mpeg4 -s 640x480 -b 6000 -g 300 -bf 2 -acodec mp3 -ab 128 outputfile.avi
6) Convert to raw DV (eg. for editing in Cinelerra or similar):
ffmpeg -i inputfile.xyz -target ntsc-dv outputfile.dv
7) Batch convert a directory of files (eg. from .mp3 to .wav):
for f in *.mp3; do ffmpeg -i "$f" "${f%.mp3}.wav"; done
8) Downsample mp3 audio file to 22050hz**:
ffmpeg -i inputfile.mp3 -acodec mp3 -ab 128 -ar 22050 outputfile.mp3
* The Canon GL1 does not shoot a full 720x480. This command include the options to remove the black bands that the GL1 adds to the sides of DV video during the transcode.
** This requires a versionn of FFMpeg that has been compiled with Lame (MP3) support.

I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful.
oh yeah, one more thing ---do you use cinelerra then? When I first used ubuntu and was trying to encode that Inconvenient Truth CAM I used it but it fscked up my disk. It seems it was kind of unstable. I haven't used it since but the guy who makes it sure is a character eh?
Greetings Rusl,
So nice to hear from you! I actually haven't done any video editing lately. The latest one that I've heard good things about is KDEnlive. Ben West was giving it a try but I haven't heard a report back from him on how it's going.
metta.
hey, nice blog! But it needs more bikes ;p
have you ever done it with mkv files? I find support for mkv a little thin but the files are usually good quality. It think its more popular format in japan.
anyway the dvd compatable one I am going to use. I allways find dvd authoring stuff too confusing so I don't bother and just burn it as avi and tell people to get a dvd player with better software :D
Steal this film 2 is out now http://isohunt.com/torrent_details/31007092/steal+this+film+ii?tab=summary have you seen the first one? That one is about the piratebay raid and stuff. This new one is more philosophical.
I just installed ubuntu 8 on my computer at home because ubuntu 7 was crashing a lot!! Its an amd64 version bug but it sucks. I just installed it and didn't use it yet though as we are right now in victoria with finnegann.
see you soon!
Hey,
It'll have more bikes soon as I'm working on something geeky and fun for Car Free Day on June 15.
I picked up a new laptop and I'm runing the AMD64 version of Hardy and it's pretty good for me. Getlibs is a great way to bridge the gap to older 32 bit program versions while we wait for the the 64 bit version to come out.
hugs (and to jane and finnegan),
~s
Post new comment