This program takes the input from several media files and joins their streams (all of them or just a selection) into an OGM. It was formerly known as 'oggmerge' and is based on the 'oggmerge' CVS module from Xiph's repository (<http://www.xiph.org/>).
Global options:
Options that can be used for each input file:
Other options:
For each file the user can select which tracks ogmmerge should take. They are all put into the file specified with '-o'. A list of known (and supported) source formats can be obtained with the '-l' option.
Let's assume you have a file called MyMovie.avi and the audio track in a separate file, e.g. MyMovie.wav. First you want to encode the audio to OGG:
$ oggenc -q4 -oMyMovie.ogg MyMovie.wav
After a couple of minutes you can join video and audio:
$ ogmmerge -o MyMovie-with-sound.ogm MyMovie.avi MyMovie.ogg
If your AVI already contains an audio track then it will be copied aswell (if ogmmerge supports the audio format). To avoid that simply do
$ ogmmerge -o MyMovie-with-sound.ogm -A MyMovie.avi MyMovie.ogg
After some minutes of consideration you rip another audio track, e.g. the director's comments or another language to MyMovie-add-audio.wav. Encode it again and join it up with the other file:
$ oggenc -q4 -oMyMovie-add-audio.ogg MyMovie-add-audio.wav
$ ogmmerge -o MM-complete.ogm MyMovie-with-sound.ogm MyMovie-add-audio.ogg
The same result can be achieved with
$ ogmmerge -o MM-complete.ogm -A MyMovie.avi MyMovie.ogg \
MyMovie-add-audio.ogg
Now fire up mplayer and enjoy. If you have multiple audio tracks (or even video tracks) then you can tell mplayer which track to play with the '-vid' and '-aid' parameters. These are 0-based and do not distinguish between video and audio.
If you need an audio track synchronized you can do that easily with
$ ogmmerge -o goodsync.ogm -A source.avi -s 200 outofsync.ogg
This would add 200ms of silence at the beginning of the audio tracks taken from outofsync.ogg. And -s always applies to all audio tracks in a source file. If you want to apply -s only to a specific track then take the same source file more than once and add -a and -s accordingly.
Some movies start synced correctly but slowly drift out of sync. For these kind of movies you can specify a delay factor that is applied to all timestamps - no data is added or removed. So if you make that factor too big or too small you'll get bad results. An example is that an episode I transcoded was 0.2 seconds out of sync at the end of the movie which was 77340 frames long. At 29.97fps 0.2 seconds correspond to approx. 6 frames. So I did
$ ogmmerge -o goodsync.ogm -s 0,77346/77340 outofsync.ogm
The result was fine.
The sync options can also be used for subtitles in the same manner.
For text subtitles you can either use some Windows software (like SubRipper) or the subrip package found in transcode(1)'s sources (in contrib/subrip). The general process is:
The resulting file can be used as another input file for ogmmerge:
$ ogmmerge -o mymovie.ogm -c 'TITLE=My Movie' mymovie.avi \
-c LANGUAGE=English mymovie.ogg -c LANGUAGE=English mymovie.srt
Using OGG as the container format introduces overhead - each OGG packet has a header, and each OGG packet can span one or more OGG pages, which itself again contain headers. Several tests show that the overhead is bigger than the overhead introduced by AVI (comparing video only files and files with video and MP3 audio).
The overhead is defined as file size - raw stream size. mencoder prints the raw stream size after encoding, so you'll be able to get that information rather easily.
Most of the times you want to calculate the overhead prior to encoding in order to adjust the bitrate accordingly. Unfortunately the overhead per frame is not constant - only the percentage is constant. This percentage is calculated as 100 * (OGG size - raw size) / raw size and seems to be somewhere between 1.1% and 1.2%. This depends on the number of streams and the stream types used.
The raw size itself can be approximated by
frames * vbitrate
raw size = ( ----------------- + length * abitrate ) / 8 * 1000 * 1024
frames per sec
assuming that vbitrate and abitrate are given in kbit/s =
1000 bit/s, and length is given in seconds.
What works:
What not works:
Planned functionality:
CHAPTER01=HH:MM:SS.sss
CHAPTER01NAME=the first chapter
CHAPTER02=HH:MM:SS.sss
CHAPTER02NAME=another chapter
with HH = hour, MM = minute, SS = seconds, sss = milliseconds.
The chapter information is stored in the video stream's comments. Therefore you could also specify the chapters with -c CHAPTER01=... Using a chapter file has an advantage: If the video stream's comments already contain chapter information and the command line contains a chapter information file then the existing chapter information will be completely replaced.
This section is not needed by the average user.
ogmmerge consists of three parts:
The general class definitions for the readers and the packetizers can be found in ogmmerge.h.
The main loop expects that the queues managed by the demuxer's packetizers are filled with at least one page after a call to the demuxer's read() function. The demuxer must make sure that enough data is passed to each of its associated packetizers. Have a look at r_ogm.cpp.
A possible setup might look like this:
+-> p_video
+-> r_avi -+
| +-> p_pcm
|
ogmmerge -+-> r_ogm ---> p_vorbis
|
| +-> p_video
| |
+-> r_ogm -+-> p_vorbis
|
+-> p_vorbis
One AVI source with a video and an audio track, one OGG/OGM source with only one Vorbis track, another OGG/OGM source with a video and two Vorbis tracks.