.TH OGMMERGE "1" "November 2004" "ogmmerge v1.5" "User Commands" .SH NAME ogmmerge \- Merge multimedia streams into an OGG/OGM file .SH SYNOPSIS .B ogmmerge [\fIglobal options\fR] \-o \fIout\fR [\fIoptions\fR] [[\fIoptions\fR] ...] .SH DESCRIPTION .LP 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 .UR http://www.xiph.org/ (). .UE .LP Global options: .TP \fB\-v\fR, \fB\-\-verbose\fR Increase verbosity. .TP \fB\-q\fR, \fB\-\-quiet\fR Suppress status output. .TP \fB\-o\fR, \fB\-\-output\fR \fIout\fR Write to the file '\fIout\fR'. .LP Options that can be used for each input file: .TP \fB\-a\fR, \fB\-\-astreams\fR <\fIn\fR,\fIm\fR,...> Copy the \fIn\fR'th audio stream, NOT the stream with the serial no. \fIn\fR. Default: copy all audio streams. .TP \fB\-d\fR, \fB\-\-vstreams\fR <\fIn\fR,\fIm\fR,...> Copy the \fIn\fR'th video stream, NOT the stream with the serial no. \fIn\fR. Default: copy all video streams. .TP \fB\-t\fR, \fB\-\-tstreams\fR <\fIn\fR,\fIm\fR,...> Copy the \fIn\fR'th text stream, NOT the stream with the serial no. \fIn\fR. Default: copy all text streams. .TP \fB\-A\fR, \fB\-\-noaudio\fR Don't copy any audio stream from this file. .TP \fB\-D\fR, \fB\-\-novideo\fR Don't copy any video stream from this file. .TP \fB\-T\fR, \fB\-\-notext\fR Don't copy any text stream from this file. .TP \fB\-s\fR, \fB\-\-sync\fR <\fId\fR[,\fIo\fR[/\fIp\fR]]> Synchronize manually, delay the audio stream by \fId\fR ms. .br \fId\fR > 0: Pad with silent samples. .br \fId\fR < 0: Remove samples from the beginning. .br \fIo\fR/\fIp\fR: adjust the timestamps by \fIo\fR/\fIp\fR to fix linear drifts. \fIp\fR defaults to 1000 if omitted. Both \fIo\fR and \fIp\fR can be floating point numbers. .br Defaults: no manual synch correction (which is the same as \fId\fR = 0 and \fIo\fR/\fIp\fR = 1.0). .TP \fB\-r\fR, \fB\-\-range\fR <\fIstart\fR-\fIend\fR> Only process from \fIstart\fR to \fIend\fR. Both values take the form '\fIHH:MM:SS.mmm\fR' or '\fISS.mmm\fR', e.g. '00:01:00.500' or '60.500'. If one of \fIstart\fR or \fIend\fR is omitted then it defaults to 0 or to end of the file respectively. .br If you want to split a file into smaller ones I strongly suggest you use \fBogmsplit(1)\fR as it can do a much better job than using the \fB-r\fR option. .TP \fB\-c\fR, \fB\-\-comment\fR '\fIA=B#C=D\fR' or '\fI@filename\fR' Set additional comment fields for the streams. Sensitive values would be \&'\fILANGUAGE=English\fR' or '\fITITLE=Ally McBeal\fR'. If the parameter starts with '@' then the comments will be read from a file with the same name without the leading '@'. \fB\-c\fR can be specified multiple times per file. The comments will all be concatenated. .TP \fB\-f\fR, \fB\-\-fourcc\fR <\fIFourCC\fR> Forces the FourCC to the specified value. Works only for video streams. Note that you cannot simply use a hex editor and change the FourCC by hand as the OGG file format uses checksums which would be wrong after such a change. .TP \fB\-\-omit\-empty\-packets\fR Normally, when a subtitle entry should be removed, an empty packet is created and inserted with the appropriate timestamp. With this option these empty packets are omitted completely. .TP \fB\-\-old\-headers\fR Assume that the input file has been created with an older version of \fBogmmerge\fR ( < 1.1). This may be needed if \fRogmmerge\fR cannot read such a file correctly. .TP \fB\-\-nav\-seek\fR <\fIfilename\fR> Use an external AVI index file as generated by \fBaviindex\fR from the transcode package. Can be used if an AVI file has a broken index. .LP Other options: .TP \fB\-l\fR, \fB\-\-list\-types\fR List supported input file types. .TP \fB\-h\fR, \fB\-\-help\fR Show usage information. .TP \fB\-V\fR, \fB\-\-version\fR Show version information. .SH USAGE .LP For each file the user can select which tracks \fBogmmerge\fR 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. .SH EXAMPLES .LP Let's assume you have a file called \fIMyMovie.avi\fP and the audio track in a separate file, e.g. \fIMyMovie.wav\fP. First you want to encode the audio to OGG: .LP $ \fBoggenc -q4 -oMyMovie.ogg MyMovie.wav\fP .LP After a couple of minutes you can join video and audio: .LP $ \fBogmmerge -o MyMovie-with-sound.ogm MyMovie.avi MyMovie.ogg\fP .LP If your AVI already contains an audio track then it will be copied as well (if \fBogmmerge\fR supports the audio format). To avoid that simply do .LP $ \fBogmmerge -o MyMovie-with-sound.ogm -A MyMovie.avi MyMovie.ogg\fP .LP After some minutes of consideration you rip another audio track, e.g. the director's comments or another language to \fIMyMovie-add-audio.wav\fP. Encode it again and join it up with the other file: .LP $ \fBoggenc -q4 -oMyMovie-add-audio.ogg MyMovie-add-audio.wav\fP .br $ \fBogmmerge -o MM-complete.ogm MyMovie-with-sound.ogm MyMovie-add-audio.ogg\fP .LP The same result can be achieved with .LP $ \fBogmmerge -o MM-complete.ogm -A MyMovie.avi MyMovie.ogg \\\fP .br \fBMyMovie-add-audio.ogg\fP .LP 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 \&'\fB-vid\fP' and '\fB-aid\fP' parameters. These are 0-based and do not distinguish between video and audio. .LP If you need an audio track synchronized you can do that easily with .LP $ \fBogmmerge -o goodsync.ogm -A source.avi -s 200 outofsync.ogg\fP .LP This would add 200ms of silence at the beginning of the audio tracks taken from \fIoutofsync.ogg\fP. And \fB-s\fP always applies to all audio tracks in a source file. If you want to apply \fB-s\fP only to a specific track then take the same source file more than once and add \fB-a\fP and \fB-s\fP accordingly. .LP 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 .LP $ \fBogmmerge -o goodsync.ogm -s 0,77346/77340 outofsync.ogm\fP .LP The result was fine. .LP The sync options can also be used for subtitles in the same manner. .LP For text subtitles you can either use some Windows software (like \fBSubRipper\fR) or the \fBsubrip\fR package found in \fBtranscode(1)\fR's sources (in \fBcontrib/subrip\fR). The general process is: .TP 1. extract a raw subtitle stream from the source: .br $ \fBtccat -i /path/to/copied/dvd/ -T 1 -L | \\ .br tcextract -x ps1 -t vob -a 0x20 | \\ .br subtitle2pgm -o mymovie\fP .TP 2. convert the resulting PGM images to text with \fBgocr\fP: .br $ \fBpgm2txt mymovie\fP .TP 3. spell-check the resulting text files: .br $ \fBispell -d american *txt\fP .TP 4. convert the text files to a SRT file: .br $ \fBsrttool -s -w -i mymovie.srtx -o mymovie.srt\fP .LP The resulting file can be used as another input file for \fBogmmerge\fR: .LP $ \fBogmmerge -o mymovie.ogm -c 'TITLE=My Movie' mymovie.avi \\ .br -c LANGUAGE=English mymovie.ogg -c LANGUAGE=English mymovie.srt\fP .SH "FILE SIZE" .LP 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). .LP The overhead is defined as \fIfile size\fR \- \fIraw stream size\fR. \fBmencoder\fR prints the raw stream size after encoding, so you'll be able to get that information rather easily. .LP 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 * (\fIOGG size\fR \- \fIraw size\fR) / \fIraw size\fR and seems to be somewhere between \fB1.1%\fR and \fB1.2%\fR. This depends on the number of streams and the stream types used. .LP The \fIraw size\fR itself can be approximated by .br \fIframes\fR * \fIvbitrate\fR .br \fIraw size\fR = ( ----------------- + \fIlength\fR * \fIabitrate\fR ) / 8 * 1000 * 1024 .br \fIframes per sec\fR .br assuming that \fIvbitrate\fR and \fIabitrate\fR are given in kbit/s = 1000 bit/s, and \fIlength\fR is given in seconds. .SH NOTES .LP What works: .TP * AVI as the video and audio source (currently only raw PCM, MP3 and AC3 audio tracks) .TP * OGG as the source for video, audio (Vorbis, raw PCM, MP3 and AC3 audio) and text streams (subtitles). .TP * WAV as the audio source .TP * MP3 audio files .TP * AC3 audio files .TP * Track selection .TP * Manual audio synchronization by adding silence/removing packets for Vorbis audio and for text streams by adjusting the starting point and duration. .TP * Manual audio synchronization for AC3 and MP3 audio by duplicating/removing packets at the beginning. .TP * Adding user comments to the mandatory comment headers (only the headers are mandatory. Comments themselves are not mandatory.) .TP * Text subtitles can be read from SRT (SubRipper / subrip) and MicroDVD files or taken from other OGM files. .TP * PCM, AC3 and MP3 audio work well under Windows and with MPlayer now. .TP * Chapter information as generated by \fBdvdxchap\fR are supported. .LP What not works: .TP * Manual audio synchronization for PCM sound (who needs it anyway?) .LP Planned functionality: .TP * support for other subtitle formats .SH CHAPTERS \fBogmmerge\fR supports chapter information as generated by \fBdvdxchap(1)\fR. The format is very simple: .LP CHAPTER01=HH:MM:SS.sss .br CHAPTER01NAME=the first chapter .br CHAPTER02=HH:MM:SS.sss .br CHAPTER02NAME=another chapter .LP with HH = hour, MM = minute, SS = seconds, sss = milliseconds. .LP The chapter information is stored in the video stream's comments. Therefore you could also specify the chapters with \fI-c CHAPTER01=...\fR 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. .SH TECHNICAL ASPECTS .LP This section is not needed by the average user. .LP \fBogmmerge\fP consists of three parts: .TP * Demultiplexers (called readers) open and read input files specified on the command line and extract specific tracks. .TP * Packetizers (or output modules) take data from a demultiplexer and encapsulate them into OGG pages. These are stored in queues. .TP * The main program requests from every known demultiplexer that it should read some data. It then gets the OGG page with the smallest timestamp from all the packetizer queues. This page is written to the output file. .LP The general class definitions for the readers and the packetizers can be found in \fBogmmerge.h\fP. .LP 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 \fBread()\fP function. The demuxer must make sure that enough data is passed to each of its associated packetizers. Have a look at \fBr_ogm.cpp\fP. .LP A possible setup might look like this: .LP +-> p_video .br +-> r_avi -+ .br | +-> p_pcm .br | .br \fBogmmerge\fR -+-> r_ogm ---> p_vorbis .br | .br | +-> p_video .br | | .br +-> r_ogm -+-> p_vorbis .br | .br +-> p_vorbis .LP 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. .SH AUTHOR .I ogmmerge was written by Moritz Bunkus . .SH SEE ALSO .BR ogmdemux (1), .BR ogmsplit (1), .BR ogminfo (1), .BR ogmcat (1), .BR dvdxchap (1) .SH WWW The newest version can always be found at .UR http://www.bunkus.org/videotools/ogmtools/ .UE