Ogg Theora Cook Book

OggResize

The command line tool oggResize can resize the height and width of an ogg file (ogg, oga or ogv) in various ways. However, it does only handle Ogg Theora and Vorbis streams. The advantage of oggResize over other tools is that it converts only the streams that need to be changed. Streams that need no conversion will not be effected.

oggResize can change the video frame size, video or audio datarate and the video frame rate or audio sample rate.

It can also add comments to any stream and can include PNG images with an alpha channel, which are rendered into the video at any time period before or after the resizing process.

Synopsis: oggResize [options] inputfile.ogv outputfile.ogv

The available options are:

-s   sets the size of the video frame. The size is given as <width>x<height>. The default size is 480x320.
By default the aspect ratio of the original video frame is kept as it is, so if the size of the new video frame does not match in aspect ratio, oggResize adds black borders at the top and bottom or right and left, to fit the new aspect ratio.
If you want to stretch the video frames to the new size, use the -t option.

Example: -s 320x240

-d   sets the datarate in bits per second for the video encoder (theora). This is meant to be an upper threshold. So the file may be smaller than assumed. If not set, the datarate of the original stream is used.

Example: -d 1024000

-D   sets the datarate in bits per second for the audio encoder (vorbis). If not set, the datarate of the original stream is used.

Example: -D 64000

-f   sets the frame rate of the video with numerator and denominator and is the frames per second. If only one number is given, the denominator is set to 1. If not set, the frame rate of the original video is used.

Example: -f 25:2

-F   sets the sample frequency (sample rate) of the audio data in Hertz. If the sample frequency does not match the original file, resampling is invoked.

Example: -F 32000

-t   if this option is set, the picture will be stretched to the output size. In this case, the aspect ratio of the output video may not match the original video frame aspect ratio. This option help omitting the black borders, that appear if the aspect ratio of the original and the new video do not match.

Example: -t

-c   adds comments to the video (theora) stream. Comments are in the form 'type=value'. More than one comment can be concatenated with a semicolon. It is recommended that apostrophes (single quote) be used, as the command line may use the semicolon as a separator.

Example: -c 'AUTHOR=yorn;DATE=03.07.09'

-C   adds comments to the audio (vorbis) stream. Comments are in the form 'type=value'. More than one comment can be concatenated with a semicolon. It is recommended that apostrophes (single quote) be used, as the command line may use the semicolon as a separator.

Example: -C 'AUTHOR=yorn;DATE=03.07.09'

-q   specifies the quality for the resizing process. Values can be chosen between 1 (best quality, with slight bluring) and 6 (worst quality). The default value is 2.

Example: -q1

-p   creates a preview film. The number given with this option specifies the interval between the frames selected, e.g. -p24 means that every 24th frame is selected/shown. Thus the newly created video plays 24 times faster. This option can be combined with the -f option to control the frame rate. With both options nice video previews can be created. If -p is used, the audio stream is ignored.

Example: -p 24

-a   adds a picture to the video frame before it is resized. The picture does not have to fit into the video frame. It is always placed in the upper left corner of the video frame.

Expression: <picture1.png>[,<startTime>[,<endTime>[,s]]]

The default start time is 0. The default end time is -1. By default s is not set. In this case the picture does not fade in. If s is set then the picture does fade in.

It is possible to superimpose more than one picture on a video frame. To concatenate the expressions use the colon. If the timelines overlap, the pictures are superimposed on one another, so the last picture is the foreground layer.

Example: -a etwas.png,2,7,s:etwasneues.png,5,10

-A   adds a picture to the video frame after it is resized.

The syntax is the same expression as with -a option

Examples

Changing the video frame size and the datarate:

 oggResize -s320x240 -d512000 orig.ogv new.ogv

This command converts the video file orig.ogv to the new video file new.ogv. The frame size of the newly created video is set to 320x240 pixels and the data rate is set to 512 kByte/s. If the parameters of the original file fit the new parameters, the video stream is just copied, without changing the data. If the video frame size is different, it is changed to the new size by some appropriate algorithms.

If there was an audio stream within the orig.ogv file, it is copied into the new file.

Changing the audio data rate, sample rate and numbers of channels:

oggResize -D64000 -F16000 -N1 orig.ogv new.ogv

This command line converts only the audio stream of file orig.ogv to a sample rate of 16kHz, a datarate of 64 kBytes/s and a mono channel. As with video, the audio stream is only reencoded, if the given parameters do not match that ones in the vorbis audio stream. The video stream is copied as is.

This is a very fast method of reencoding only the audio stream, without any other procedures such as splitting and rejoining the streams of an ogg file.

Changing the video frame size, the audio data rate, the video data rate and adding two pictures on top of the video for a period of time:

oggResize -s300x200 -D32000 -d1024000 -A etwas.png,2,7,s:etwasneues.png,5,10 \ orig.ogv new.ogv

This command line converts the audio and video stream as described in the before mentioned examples.

Additionally it adds a picture in PNG format and an alpha channel etwas.png to the video from second 2 to second 7 with a smooth fade in and fade out and the picture etwasneues.png is placed on top of the video frame from second 5 to second 10 without any fading.