Archive for the 'distribution' Category

Linux DVD Authoring

Tuesday, March 27th, 2007

Linux’s primary DVD authoring capabilities are provided by the dvdauthor utility, which you can get from most binary package repositories. Most of what dvdauthor does is to create a proper file system structure out of mpeg2 files that you provide. This makes it a bit clunky to use manually. However, since it provides arbitrary control over the menuing system, and even allows you to do a bit of scripting, it is an incredibly versatile tool—much more so than iDVD, for instance. As always, the down side of flexibility is the difficulty of use.

Fortunately, there are a number of projects that build on top of dvdauthor, making DVD authoring more accessible for us, the unwashed masses. DVDStyler is under current development and certainly will allow you to create a basic DVD using your own images and fonts. RPMs of DVDStyler are available from rpm.livna.org. ‘Q’ DVD-Author is another project, for which binaries are more difficult to come by, that provides a fuller set of capabilities.

Audio Filter and Transition Support

Wednesday, March 7th, 2007

The following table summarizes audio filters that are supported by the various packages. There is a complete listings of plugins available for cinelerra. The AUDIO FILTERS section of the mencoder manual describes each of the audio filters operation in more detail.

Effect Cinelerra Kino ffmpeg mencoder
Compressor
EQ
Reverb
Delay
LADSPA
Crossfade

These filters and transitions cover much of what you need to produce good clean audio. The support for LADSPA plugins in mencoder gives mencoder the broadest range in effects since there are so many existing LADSPA plugins available (including compressors), but at the same time it is limited in that it does not support automation, i.e. varying plugin parameters over time. Cinelerra has full automation support for nearly all parameters via auto keyframing. Kino’s audo effects are mostly geared toward compensating for its lack of multitrack audio—it’s current “audio filter” list includes: dub, fade in, fade out, gain, mix, and silence; all typical mixing functions, not what one might initially think of as effects.

Video Filter Support

Monday, March 5th, 2007

The following table summarizes the video filters supported by various video editing packages.

Filter Cinelerra Kino ffmpeg mencoder
scale
flip/mirror
rotate 1
crop 2 2
2:3 pulldown
2:3 pullup
hue/saturation
white balance 3 3
brightness/contrast
gamma
blur
sharpen
chroma key
difference key

In addition, Kino has a very nice “soft focus” filter that does a convincing job of simulating the Hollywood starlet “I’m ready for my closeup, Mr. DeMille,” sort of look. Both Kino and Cinelerra also boast a selection of the usual fare of cheesy filters, like the kaleidoscope, sepia tone, oil painting, or charcoal sketch effects.

Note:

  1. mencoder only supports rotation by 90 degree increments.
  2. Both Cinelerra and Kino support panning and zooming, which can be used to achieve a crop-like effect. Kino, however, doesn’t have a lot of flexibility in specifying the output format; instead it assumes that the output will be either NTSC or PAL, either 4:3 or 16:9, and DV, mpeg for DVD/VCD, or one of a few web distribution presets.
  3. Cinelerra only offers a “color balance” tool, that allows colors to be shifted toward red, green, blue, or cyan, magenta, yellow. Technically, you can set a white-balance with that, but it’s a pain in the but. Kino, offers a much more useful white balance filter that lets you sample your white point from the frame, or set a color temperature in degrees Kelvin.

Image File Format Support

Wednesday, February 7th, 2007

This table summarizes the image file formats supported by various pieces of software. Although not included in the table below, the ImageMagick utility, available on most platforms, can convert among a long list of image file formats, allowing you to, for instance, convert a cineon sequence to a targa sequence for editing in Cinelerra.

Format Cinelerra Kino ffmpeg mencoder
JPEG R W R W R W R W
PNG R W R W R W R W
GIF - - R - R W2 - W3
TIFF R W R - - - - -
TGA R W R - - - R W
EXR R W - - - - - -
RAW R1 - - - - - - -

Cinelerra supports images for slugs or as image sequences, but requires a cinelerra specific table of contents file listing the images in your sequence. Kino can export still frames or sequences as JPEGs or PNGs. Kino imports image sequences and slugs via the FX > Create > Create From File option. ffmpeg and mencoder can convert image sequences into encoded video, as well as the opposite: converting an encoded video into an image sequence.

To convert a video to an image sequence via ffmpeg, you simply specify a supported file extension for the output, and use a printf expression (the “%03d” part ) as a substitute for the frame number. Thus the following will create a bunch of files named output-001.jpg to output-NNN.jpg where NNN is the last frame of you video. If you have more than 999 frames in your video, replace the “3″ in “%03d” with a larger number.

$ ffmpeg -i input.avi output-%03d.jpg

Unfortunately, there’s no documentation on how to control the compression level of the output images, so you may prefer mplayer.

To convert a video to an image sequence via mencoder (well, actually mplayer, but they’re part of the same package), you use the jpeg pseudo video-driver. See the -vo option in the mplayer manual for more information.

$ mplayer input.avi -vo jpeg

Details are available in the manual, but to force mplayer to output very high quality jpegs, you can include the quality option, like so:

$ mplayer input.avi -vo jpeg:quality=100

Converting an image sequence to a video in ffmpeg is pretty much the opposite in terms of syntax.

$ ffmpeg -i input-%03d.jpg output.avi

Converting an image sequence to a video via mencoder has different syntax. Note that the “-ovc lavc” is unrelated to the task at hand and may be different, depending on your output file format.

$ mendcoder mf://input-*.jpg -ovc lavc -o output.avi

Notes

  1. Cinelerra can only import RAW images for use as slugs, but it does allow you to manually adjust the gamma. It’s recommended that you render these slugs to a MOV clip for performance reasons.
  2. ffmpeg can write either animated GIFs or GIF image sequences depending on whether you use a printf expression (e.g. ‘%03d’) in the output file name.
  3. mplayer will only convert the output to an animated GIF, not a GIF image sequence.

Audio Container Format Support

Friday, February 2nd, 2007

The following table summarizes the audio container formats supported by some video software.

Container Format Cinelerra Kino ffmpeg mencoder
WAV R W R W R W R W
AIFF R W R1 - R W - W
AU R W R1 - R W - W
MP3 - W R1 W2 R W R -
OGG R W R1 W3 R W R -

Kino is capable of exporting a project’s audio to a WAV file natively, or various other formats using external tools. Using FX > Audio Filters > Dub, an audio file may be selected to replace the existing soundtrack, or using FX > Audio Filters > Mix, an audio file may be played simultaneously with the existing soundtrack. Both these techniques require you to specify the starting position of the sound as a number of seconds.

ffmpeg allows you to add a sound track to a silent movie file, you simply specify it as a second input:

$ ffmpeg -i input.wav -i input.avi output.avi

The same action in mencoder has the following syntax. Note that the “-oac lavc -ovc lavc” part of the command is unrelated to this task and may vary depending on your desired output.

$ mencoder input.avi -audiofile input.wav -o output.avi -oac lavc -ovc lavc

Notes

  1. Requires ffmpeg.
  2. Requires lame.
  3. Requires oggenc, provided by the vorbis-tools package on Fedora systems.

Video Container Format Support

Friday, January 26th, 2007

The following table summarizes the video container formats supported by some video software. Note the distinction between a codec and a container format: the more versatile container formats such as AVI or MOV can contain video encoded in any of a number of codecs.

Container Format Cinelerra Kino ffmpeg mencoder
Raw DV R W R W R W R W
AVI R W R -3 R W R W
MOV R -1 - - R W R W
MPEG-1 R W R W R W R W
MPEG-2 PS (VOB) - - R W - W R W
MPEG-4 -2 - R4 W4 R W R W

Notes

  1. Cinelerra writes “QuickTime for Linux” video files which may not be compatible with other tools.
  2. Cinelerra can read MPEG-4 audio from .mp4 files.
  3. Kino can write Raw DV in the DV AVI 1 or DV AVI 2 formats and supports OpenDML, also known as AVI 2.0.
  4. Supported via FFMPEG

Displaying MP4 in a Web Browser

Wednesday, January 24th, 2007

If you’ve encoded your video as MP4 for display on the web, then the likelihood is you’ll want to embed that movie file in the HTML on your site. Fortunately, it’s pretty much a simple procedure. A more comprehensive discussion of video embedding issues is available at A List Apart. The W3C standard OBJECT tag will call up the appropriate plugin, the QuickTime plug-in on most systems, and display the movie in the specified area. Unfortunately, not all browsers are created equal, and calling the right plug-in for Internet Explorer is more of a challenge.

The following, very simple code works for FireFox, which properly complies with the standards:

<object type="video/mp4"
        data="yourmovie.mp4"
        width="320" height="256">
    <param name="autoplay" value="false" />
    <param name="controller" value="true" />
</object>

The following, more complex code, is required to operate in Internet Explorer as well as the other major browsers:

<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
        codebase="http://www.apple.com/qtactivex/qtplugin.cab"
        width="320" height="256">
  <param name="src" value="yourmovie.mp4" />
  <param name="autoplay" value="false" />
  <param name="controller" value="true" />

  <object data="yourmovie.mp4"
          type="video/mp4"
          width="320" height="256">
    <param name="autoplay" value="false" />
    <param name="controller" value="true" />
  </object>
</object>

The name of your movie file needs to appear both in the “data” attribute of the OBJECT tag, and as the value of the “src” parameter to the object embed. This fixes some compatibility issues with certain browsers. Note that the “height” attribute of the OBJECT tag adds an additional 16 pixels onto the height of the video in order to accommodate the playback controls that appear at the bottom of the QuickTime interface. The “type” argument to the OBJECT tag, in this case “video/mp4″ is a MIME type, and it allows standards compliant browsers to associate an arbitrary plug-in with the kind of data indicated by the type. This should mean that you don’t have to specify that the QuickTime player in particular should handle playing the video, and would allow the user to pick a different media player if they happen to hate QuickTime; unfortunately Internet Explorer kinda messes that up. A complete reference of the QuickTime parameters are available here.

MP4 for web distribution via ffmpeg

Tuesday, January 16th, 2007

If you intend to distribute your video content via the web then you will want to minimize the size of your video file in order to incur the least cost in terms of bandwidth. There are three strategies that will lead to lower video file sizes: using more efficient or aggresive compression, reducing the resolution of the file, and reducing the frame rate of the video.

For web distribution we use the MP4 file format with MPEG-4 part 2 encoded video and MP3 encoded audio. The MP4 file format is specified as part of the MPEG-4 suite of standards and is playable by a broad range of media players, including iTunes and the iPod in case you’re podcasting your video. In order to transcode your video into the MP4 format you simply specify the .mp4 file extension for the output file and ffmpeg will understand what you want.

$ ffmpeg -i input.avi output.mp4

If for some reason you want to use a non-standard filename extension, then you must make the file format explicit:

$ ffmpeg -i input.avi -f mp4 output.ext

While the H.264 codec would be ideal, ffmpeg does not yet support encoding in H.264, so instead we use the MPEG-4 part 2 Advanced Simple Profile. The best compression ratio for audio in the MP4 format is still achieved via MP3 compression. The audio codec and video codec can be specified via the -acodec and -vcodec options.

$ ffmpeg -i input.avi -acodec mp3 -vcodec mpeg4 output.mp4

The -b option sets the video bitrate, and the -ab option sets the audio bitrate. By default ffmpeg uses 200 kb/s video bitrate for the mpeg4 codec and 64 kb/s audio bitrate for the mp3 codec.

The most common resolution for web distribution is 320×240; a 4:3 aspect ratio with square pixels. Almost all the video on archive.org is in that resolution, as are MP4 (iPod) video downloads from google video. To force this resolution, use the -s option:

$ ffmpeg -i input.avi -acodec mp3 -vcodec mpeg4 -s 320×240 output.mp4

Note that the same video encoded at standard resolution and at 320×240 will have roughly similar file sizes. This is because the codec’s bitrate is constant: bitrate times time equals file size. Reducing the video resolution allows you to use a lower bitrate with fewer compression artifacts.

If your source material is interlaced, add the -deinterlace option. I don’t know how ffmpeg deinterlaces video, and it’s likely not a great method, e.g. choosing one of the fields and scaling it up to a 4:3 aspect ratio; however, if you’re going from standard definition to 320×240, even the most brutal deinterlacing methods will be hidden by the scaling.

Finally, to squeeze every last spare bit out of the video file, you can reduce the frame rate. Most video can be dropped to 24 FPS with no perceptible change. For relatively static material, such as slide presentations, very low frame rates in the 2-4 FPS range may be appropriate. Again, you also have to reduce your bitrate or 24 FPS will produce an image with fewer compression artifacts rather than a smaller file size. Set the frame rate with the -r option:

$ ffmpeg -i input.avi -acodec mp3 -vcodec mpeg4 -s 320×240 -r 24 output.mp4

A great way to experiment with acceptable bitrates is to use the -ss and -t options. The -ss option seeks to a position in the input file, and the -t option sets the duration of the output file. Thus:

$ ffmpeg -i input.avi -ss 30 -t 5 output.mp4

Will encode a five second clip of the input file thirty seconds from its beginning. This lets you see what the resulting compression level will look like without encoding the whole video.