I’ve been experimenting with video codecs and formats for uploading video to the web (Facebook, Youtube, etc.).
Encoding for the Web
To make a tiny file, you can encode files this way:
For better quality output, there are a number of variables you can control. I’m starting with two assumptions for the time being: I’m using the h264 codec and my target output format is mp4. For YouTube, flv would be better.
“-i foo.dv” just identifies the input file, and the rest of the options apply to the output file.
For my own future benefit, I will break down the options I’ve used: “-ab 128k” is the audio bitrate, “-ar 44100″ is the audio sampling frequency (44100 is the default anyhow); “-b 1200k” is the video bitrate; “-vc h264″ is the video codec; “-qscale 1″ sets the video quantizer scale (lower is better quality, use “-sameq” for the same quality); “-s 480×360″ is the target width and height. All of these variables can be changed to create a higher/lower quality file which is smaller/larger in size. These settings create a decent output file for people to download, but it will be resampled on uploading to websites for streaming.
If you just want to do a quick trim of the clip before uploading, I’ve found this is an easy way to do it. First play the video:
Note the start and end points you want, then run the ffmpeg command with “-ss NN” for the starting point in seconds and “-t NN” for the duration. That allows you to trim either the start or end of the clip without having to break out Cinelerra or Kino. By the way, I’ve got a pile of switches enabled on mplayer, but the only one that really matters is “-osdlevel 3″ so you can see the counter.
Some Youtube guidance on formats here: http://www.google.com/support/youtube/bin/answer.py?answer=132460&safe=off
Facebook format details are found here. You could use this command and vary the qscale and bitrate to get a reasonable file size:
Vimeo format recommendations give specific values for bit rates and codecs as follows for high quality:
For HD video on Vimeo:
“-s hd720″ tells ffmpeg to create 1280×720 output.
Sources of Information
This video is a good ffmpeg intro: http://www.linuxjournal.com/video/linux-howto-video-editing-magic-ffmpeg
For Youtube uploads, they use the following command. The presenter explains that these parameters are good for Youtube because they will not be re-encoded on upload:
He also shows how to crop and letterbox using ffmpeg and even creates a moving spotlight. He also uses the “-loop_input” ffmpeg switch in order to make a 10 second clip of a still frame. Very handy!
Here is an explanation of how to use ffmpeg for screencasting.
Comments are closed.