Video Codecs and the Free World
Whether you are encoding video you have produced and want to distribute or are taking video from one source and transcoding it into a format more friendly to your system, there are handy open-source encoders that generate video files playable by many popular consumer content players. The most effective is the FFmpeg program—sometimes wrapped in a GUI and sometimes used strictly on the command line. The FFmpeg man page is extensive but fairly easily to use.
Video encoding is best learned by doing, and although there are many important variables when encoding video, there are no magic settings; they change in relation to the target size of the video as well as the actual content (for example, how frequently pixels change chroma or luma values from one video frame to another).
To encode a video, first make sure you have FFmpeg installed on your system. If not, add it via the command line (sudo apt-get install ffmpeg on Debian systems), or use your distribution's package manager.
The command to encode looks like this:
ffmpeg -i [filename] -vcodec [codec to use] -s [target frame size] ↪-b [target bit rate in kbps] -r [target frames per second] ↪-acodec [audio codec to use] -pass 2 -ar [target audio sample rate] ↪-ab [audio bit rate in kbps] -f [target file format] [output filename]
ffmpeg -i bigmovie.m4v -vcodec xvid -s 720x480 -b 3000k -r 24 ↪-acodec libfaac -pass 2 -ar 128k -f .mp4 freemovie.mp4
The example above transcodes a video from a proprietary MPEG-4 format into the open-source codec of Xvid with libfaac sound, in a standard definition frame size and a fairly high video quality.
The important variables are frame size (-s), as it determines scalability of the video, and bit rate (-b for video and -ar for audio), which determines how much information is being sent per video frame—the higher the bit rate, the sharper and nicer the image will be but also the file size will be larger. Finally, the -pass variable determines how much preprocessing the encoder will do to the video. In one-pass mode, the encoding is done fairly quickly and not always optimally. With two-pass encoding, FFmpeg reviews the video file once, gathers necessary data, and then does the actual encoding on the second pass. The end result is a higher quality compression, but you can expect double or triple the encoding time.
The other popular way of transcoding video is with GUI programs that rip video from encoded DVDs, making them viewable in an unrestricted codec. This also is ideal for creating a home media server, with your entire movie collection digitized and ready to play at any moment. Obviously, the legality of this varies from day to day and from country to country. However, the GUI programs are plentiful and utilize the same variables as FFmpeg. You will need to set the video codec to which you want to save your video, the audio codec, the bit rates of each, frame size and so on.
The great codecs of the Free Software movement, Ogg Vorbis and Ogg Theora, are obviously very well supported on GNU/Linux. Generating them is done easily with ffmpeg2theora. The command-line variables for ffmpeg2theora are similar to those for FFmpeg:
ffmpeg2theora [filename] -x [target horizontal pixel count] ↪-y [target vertical pixel count] -V [target bi trate in kbps] ↪-A [audio bit rate] -c [audio channels] -H [audio sample rate] ↪-o [output filename]
When it became clear to the Open Source movement that video codecs were doomed to remain proprietary and counter-productive, the Ogg format was born. Open to all and freely available to any system, Ogg Vorbis (for sound) and Ogg Theora (for video) are advanced and fully featured codecs.
A common argument against using Ogg is that it requires users of Microsoft and Apple products (or, the majority of computer users) to seek out a suitable player. Yet, it's clear by now that requiring users to download a media player or media plugin is not at all uncommon and will quite probably become even more common as content delivery becomes more Internet-reliant and computer-centric. People today expect to have to download a video player to watch certain video content. The real problem with Ogg is that there is no ubiquitous media player for the format; RealPlayer has Real Media, QuickTime has QuickTime Player, Windows Media has Windows Media Player, Flash has Flash Player and so on. People easily can find those, but where do they go for Ogg playback?
Promote both free software and free codecs by promoting Ogg formats, but don't fail to promote a player that easily and effectively plays media on all major platforms. One of the better players for this job is VLC player, which installs on Windows, Mac OS X, GNU/Linux, BSD, BeOS and Solaris. Another is miro, an iTunes-like aggregator of video podcasts, IP TV and YouTube, as well as media on your local machine. Both play Ogg, so send a link to the player along with the Ogg clips you distribute.
- Let's Go to Mars with Martian Lander
- Applied Expert Systems, Inc.'s CleverView for TCP/IP on Linux
- My Childhood in a Cigar Box
- Papa's Got a Brand New NAS
- Returning Values from Bash Functions
- Tech Tip: Really Simple HTTP Server with Python
- Rogue Wave Software's TotalView for HPC and CodeDynamics
- Panther MPC, Inc.'s Panther Alpha
- Debugging Democracy