mkvmerge -- Fusiona fluxos multimèdia dins d'un fitxer Matroska(tm)

Table of contents

1. Sinopsis

mkvmerge [opcions_globals] {-o sortida} [opcions_1] {fitxer_1} [[opcions_2] {fitxer_2}] [@fitxer_opcions]

2. Descripció

Aquest programa pren l'entrada des de diversos fitxers multimèdia d'entrada i uneix els seus fluxos (tots o només els seleccionats) en un fitxer Matroska(tm); vegeu el lloc web del Matroska.

Important:

L'ordre de les opcions a la línia d'ordres és important. Si us plau, llegiu la secció «L'ordre de les opcions» si sou novell emprant aquest programa.

2.1. Opcions globals

Option Description
-v, --verbose

Incrementa la loquacitat.

-q, --quiet

Suprimeix la sortida de l'estat.

-o, --output nom_fitxer

Escriu al fitxer nom_fitxer. Si s'usa la divisió, llavors aquest paràmetre es tractarà de manera diferent. Per a més detalls vegeu l'explicació sobre l'opció --split.

-w, --webm

Crea un fitxer conforme amb WebM. També s'habilita si el nom de l'extensió del fitxer de sortida és «webm». Aquest mode obliga a complir certes restriccions. Els únics còdecs permesos són VP8, VP9 per a vídeo i Opus, Vorbis per a pistes d'àudio. No estan permeses ni els capítols ni les etiquetes. L'element de capçalera DocType és canviat a «webm».

--title títol

Estableix el títol general pel fitxer de sortida, p. ex., el nom de la pel·lícula.

--default-language codi_idioma

Estableix el codi d'idioma per omissió que serà usat per a les pistes on no s'hagi establert l'idioma amb l'opció --language i per a les quals el contenidor font no proporciona un idioma.

El codi d'idioma per omissió és «und» per a «undefined» (sense definir).

2.2. Informació quant a la manipulació del segment (opcions globals)

Option Description
--segmentinfo nom_fitxer.xml

Llegeix la informació del segment a partir d'un fitxer XML. Aquest fitxer pot contenir l'UID de la família del segment, l'UID del segment, l'UID del segment anterior i l'UID del segment següent. Un fitxer i una DTD d'exemple estan inclosos en la distribució de les MKVToolNix.

Per a més detalls, vegeu més endavant la secció sobre els fitxers XML d'informació del segment.

--segment-uid SID1,SID2...

Estableix els UID del segment a usar. Aquest és un UID del segment de 128 bits en la forma usual de l'UID: nombres hexadecimals, amb o sense el «0x» com a prefix, amb o sense espais, exactament 32 dígits.

If SID starts with = then its rest is interpreted as the name of a Matroska file whose segment UID is read and used.

Cada fitxer creat conté un segment, i cada segment té un UID del segment. Si s'especifiquen més UID que segments, llavors els UID que sobrin seran ignorats. Si s'especifiquen menys UID que segments, llavors es crearan de manera aleatòria els UID que faltin.

2.3. Manipulació dels capítols i etiquetes (opcions globals)

Option Description
--chapter-language codi_idioma

Estableix el codi d'idioma ISO639-2 que s'escriurà en cada entrada de capítol. Per omissió s'estableix a «eng». Per a més detalls vegeu més endavant la secció sobre els capítols.

Aquesta opció es pot usar tant per a simples fitxers de capítols com per a fitxers d'origen que continguin capítols sense informació sobre l'idioma, p. ex., fitxers MP4 i OGM.

--chapter-charset joc_de_caràcters

Estableix el joc de caràcters que es farà servir per a la conversió a UTF-8 per a simples fitxers de capítols. Vegeu la secció sobre la conversió per a fitxers de text i jocs de caràcters per a veure una explicació sobre com realitza el mkvmerge(1) la conversió entre diferents jocs de caràcters.

Aquest ajustament també s'aplica als capítols que es copien des de certs tipus de contenidors, p. ex., fitxers Ogg/OGM i MP4. Per a més detalls vegeu més endavant la secció sobre els capítols.

--cue-chapter-name-format format

El mkvmerge(1) pot llegir fulls de muntatge (CUE sheets) per a fitxers d'àudio com a entrada pels capítols. Els fulls de muntatge normalment contenen les entrades PERFORMER i TITLE per a cada entrada de l'índex. El mkvmerge(1) usa aquestes dues cadenes per tal de construir el nom del capítol. Amb aquesta opció, es pot establir el format emprat per a aquest nom.

Si no s'indica aquesta opció, llavors el mkvmerge(1) usarà per omissió el format «%p - %t» (l'artista, seguit per un espai, una barra, un altre espai i el títol).

Si s'indica el format, llavors es copiarà tot tal com està excepte els següents meta caràcters que seran substituïts així:

  • %p serà substituït per la cadena a l'entrada PERFORMER,

  • %t serà substituït per la cadena a l'entrada TITLE,

  • %n serà substituït pel número de la pista actual i,

  • %N serà substituït pel número de la pista actual afegint-li un zero a l'esquerra si aquest número és menor que 10.

--chapters nom_fitxer

Llegeix la informació dels capítol des del fitxer nom_fitxer. Per a més detalls vegeu més endavant la secció sobre els capítols.

--global-tags nom_fitxer

Llegeix les etiquetes globals des del fitxer nom_fitxer. Per a més detalls vegeu més endavant la secció sobre les etiquetes.

2.4. Control general de la sortida (opcions globals avançades)

Option Description
--track-order FID1:TID1,FID2:TID2...

Aquesta opció canvia l'ordre en el qual es creen les pistes d'un fitxer d'entrada. L'argument és una llista separada per comes de parells d'ID. Cada parell conté primer l'ID del fitxer (FID1), el qual només és el número del fitxer a la línia d'ordres partint de 0. El segon és un ID de pista (TID1) d'aquest fitxer. Si s'ometen alguns ID de pista, llavors aquestes pistes seran creades després de les establertes amb aquesta opció.

--cluster-length especificació

Limita el nombre de blocs de dades o la durada de les dades en cada clúster. El paràmetre especificació pot ser un número n sense una unitat o un número d amb el sufix «ms».

Si no s'empra cap unitat, llavors el mkvmerge(1) tindrà com a màxim n blocs d'informació a cada clúster. El nombre màxim de blocs és 65535.

Si el número d té el sufix «ms», llavors el mkvmerge(1) posarà com a màxim d mil·lisegons d'informació de dades en cada clúster. El valor mínim per a d és «100ms», i el màxim és «32000ms».

Per omissió, el mkvmerge(1) posa com a màxim 65535 blocs de dades i 5000ms d'informació de dades a cada clúster.

Els programes que intenten trobar un cert fotograma només poden cercar directament a un clúster i posteriorment llegir tot el clúster. Per tant, el crear clústers molt grans podria comportar una cerca lenta i poc precisa.

--no-cues

Li diu al mkvmerge(1) que no crei i escrigui les dades de l'índex, el qual es pot comparar amb l'índex d'un AVI. Els fitxers Matroska(tm) es poden reproduir sense les dades de l'índex, però la cerca probablement serà poc precisa i lenta. Useu això només si realment esteu desesperat per estalviar espai o amb finalitat de proves. Vegeu també que l'opció --cues es pot especificar per a cada fitxer d'entrada.

--clusters-in-meta-seek

Li diu al mkvmerge(1) que crei un element meta de cerca al final del fitxer que contindrà tots els clústers. Vegeu també la secció sobre disposició dels fitxers Matroska.

--disable-lacing

Deshabilita l'enllaçat per a les pistes. Això incrementarà la mida del fitxer, especialment si hi ha moltes pistes d'àudio. Aquesta opció no ha estat dissenyada per a l'ús freqüent.

--enable-durations

Escriu les durades per a tots els blocs. Això incrementarà la mida del fitxer, i al moment no oferirà cap valor addicional als reproductors.

--disable-track-statistics-tags

Normalment, el mkvmerge(1) escriu algunes etiquetes amb estadístiques per a cada pista. Si aquestes etiquetes ja estan presents, llavors se sobreescriuran. Les etiquetes són BPS, DURATION, NUMBER_OF_BYTES i NUMBER_OF_FRAMES.

L'habilitar aquesta opció impedeix que el mkvmerge(1) escrigui i editi les etiquetes existents que tinguin els mateixos noms.

--timecode-scale factor

Força el factor d'escala dels codis de temps amb factor. Els valors admesos estan compresos en l'interval 1000..10000000 o el valor especial -1.

Normalment, el mkvmerge(1) usarà el valor 1000000, el qual vol dir que els codis de temps i durades tindran una precisió d'1ms. Pels fitxers que no continguin una pista de vídeo però sí almenys una d'àudio, llavors el mkvmerge(1) agafarà un factor d'escala de codis de temps pel que tots els codis de temps i durades tindran una precisió d'una mostra d'àudio. Això causarà una major sobrecàrrega però permetrà que la cerca i extracció siguin més precises.

Si s'usa el valor especial -1, llavors el mkvmerge(1) emprarà la precisió de la mostra, encara que hi hagi una pista de vídeo.

2.5. Divisió, vinculació, annexat i concatenació dels fitxers (més opcions globals)

Option Description
--split especificació

Divideix el fitxer de sortida després d'una mida o temps especificat. Si us plau, tingueu en compte que aquestes pistes només es poden dividir just abans d'un fotograma clau. A causa de l'ús de memòria intermèdia i després d'arribar al punt de divisió especificat, el mkvmerge(1) realitzarà la divisió just abans que s'hagi abastat el següent fotograma clau. Per tant, el punt de divisió podria ser un xic diferent de l'especificat per l'usuari.

Fins ara, el mkvmerge(1) admet quatre modes diferents.

  1. Divisió per la mida.

    Sintaxi: --split [size:]d[k|m|g]

    Exemples: --split size:700m o --split 150000000

    El paràmetre d pot acabar amb «k», «m» o «g» per indicar que la mida és en KB, MB o GB respectivament. D'altra manera, s'assumeix que la mida és en bytes. Després que el fitxer de sortida actual abasti la mida límit, començarà la creació d'un altre fitxer.

    El prefix «size:» es pot ometre per motius de compatibilitat.

  2. Divisió després d'una durada.

    Sintaxi: --split [duration:]HH:MM:SS.nnnnnnnnn|ds

    Exemples: --split duration:00:60:00.000 o --split 3600s

    El paràmetre pot tenir la forma HH:MM:SS.nnnnnnnnn per especificar la durada amb una precisió de nanosegons, o pot ser un número d seguit per la lletra «s» per a una durada en segons. HH és el número de les hores, MM és el dels minuts, SS és el dels segons i nnnnnnnnn és el dels nanosegons. Tant el número de les hores com el dels nanosegons es poden ometre. Hi ha fins a nou dígits després del punt decimal. Després que el fitxer de sortida actual abasti la durada límit, començarà la creació d'un altre fitxer.

    El prefix «duration:» es pot ometre per motius de compatibilitat.

  3. Divisió després d'uns codis de temps específics.

    Sintaxi: --split timecodes:A[,B[,C...]]

    Exemple: --split timecodes:00:45:00.000,01:20:00.250,6300s

    Els paràmetres A, B, C, etc. poden tenir el mateix format que l'usat per a la divisió per durada (vegeu més amunt ). La llista dels codis de temps està separada per comes. Després que el flux d'entrada abasti el punt de divisió pel codi de temps actual, es crearà un fitxer nou. Llavors s'usarà el següent punt de divisió especificat a la llista.

    El prefix «timecodes:» no es pot ometre.

  4. Manté les parts especificades pels intervals de codis de temps especificats mentre que les altres seran descartades.

    Sintaxi: --split parts:inici_1-final_1[,[+]inici_2-final_2[,[+]inici_3-final_3...]]

    Exemples:

    1. --split parts:00:01:20-00:02:45,00:05:50-00:10:30

    2. --split parts:00:01:20-00:02:45,+00:05:50-00:10:30

    3. --split parts:-00:02:45,00:05:50-

    El mode «parts» li indica al mkvmerge(1) que mantingui certs intervals de codis de temps mentre es descarten altres. Els intervals a mantenir s'han de llistar després de la paraula clau parts: i s'han de separar amb comes. Un interval, en si mateix, consisteix d'un inici i un final, en el mateix format i altres variacions que accepta --split (p. ex., tant 00:01:20 com 80s es refereixen al mateix codi de temps).

    Si s'omet un codi de temps d'inici, llavors per omissió s'emprarà el codi de temps final de l'interval anterior. Si no hi ha un interval anterior, llavors per omissió s'emprarà el d'inici del fitxer (vegeu l'exemple 3).

    Si s'omet el codi de temps final, llavors per omissió es prendrà el valor final dels fitxers d'entrada. El qual bàsicament li indicarà al mkvmerge(1) que mantingui la resta (vegeu l'exemple 3).

    Normalment, cada interval serà escrit a un fitxer nou. Això es pot canviar de manera que els intervals consecutius s'escriguin en el mateix fitxer. Per fer-ho, l'usuari haurà d'assignar el prefix + al codi de temps d'inici. Això li indicarà al mkvmerge(1) que no creï un fitxer nou i en comptes d'això, que annexi l'interval després de l'últim interval escrit al fitxer. Els codis de temps seran ajustats de manera que no hi hagi discontinuïtats en el fitxer de sortida, fins i tot si hi havia una entre dos intervals al fitxer d'entrada.

    En l'exemple 1, el mkvmerge(1) crearà dos fitxers. El primer abastarà el contingut a partir de 00:01:20 fins 00:02:45. El segon abastarà el contingut a partir de 00:05:50 fins 00:10:30.

    En l'exemple 2, el mkvmerge(1) crearà un únic fitxer. Aquest abastarà ambdós, el contingut a partir de 00:01:20 fins 00:02:45 i el contingut a partir de 00:05:50 fins 00:10:30.

    En l'exemple 3, el mkvmerge(1) crearà dos fitxers. El primer abastarà el contingut des del començament dels fitxers d'origen fins 00:02:45. El segon abastarà el contingut a partir de 00:05:50 fins al final dels fitxers d'origen.

    Note:

    Recordeu que el mkvmerge(1) només pren decisions sobre la divisió a les posicions dels fotogrames clau. Això és aplicable tant a l'inici com al final de cada interval. De manera que si un codi de temps final es troba entre dos fotogrames clau, el mkvmerge(1) continuarà amb la sortida dels fotogrames fins al final però excloent el següent fotograma clau.

  5. Manté les parts especificades pels intervals de número de fotograma/camp especificats mentre que les altres seran descartades.

    Sintaxi: --split parts-frames:inici_1-final_1[,[+]inici_2-final_2[,[+]inici_3-final_3...]]

    Exemples:

    1. --split parts-frames:137-258,548-1211

    2. --split parts-frames:733-912,+1592-2730

    3. --split parts-frames:-430,2512-

    El mode «parts-frames:» li indica al mkvmerge(1) que mantingui certs intervals numèrics de fotogrames/camps, mentre es descarten altres. Els intervals a mantenir s'han d'especificar després de la paraula clau parts-frames: i separar amb comes. Un interval consisteix en un número de fotograma/camp d'inici i final. La numeració comença per l'1.

    Si s'omet un número d'inici, llavors per omissió s'emprarà el número final de l'interval anterior Si no hi ha un interval anterior, llavors per omissió s'emprarà el d'inici del fitxer (vegeu l'exemple 3).

    Si s'omet el número final, llavors per omissió es prendrà el valor final dels fitxers d'entrada. El qual bàsicament li indicarà al mkvmerge(1) que mantingui la resta (vegeu l'exemple 3).

    Normalment, cada interval serà escrit a un fitxer nou. Això es pot canviar de manera que els intervals consecutius s'escriguin en el mateix fitxer. Per fer-ho, l'usuari haurà d'assignar el prefix + al número d'inici. Això li indicarà al mkvmerge(1) que no creï un fitxer nou i en comptes d'això, que annexi l'interval després de l'últim interval escrit al fitxer. Els codis de temps seran ajustats de manera que no hi hagi discontinuïtats en el fitxer de sortida, fins i tot si hi havia una entre dos intervals al fitxer d'entrada.

    Note:

    Recordeu que el mkvmerge(1) només pren decisions sobre la divisió a les posicions dels fotogrames clau. Això és aplicable tant a l'inici com al final de cada interval. De manera que si un número de fotograma/camp final es troba entre dos fotogrames clau, el mkvmerge(1) continuarà amb la sortida dels fotogrames fins al final però excloent el següent fotograma clau.

    En l'exemple 1, el mkvmerge(1) crearà dos fitxers. El primer abastarà el contingut a partir del primer fotograma clau o després del 137 fins, però sense incloure el primer fotograma clau o després del 258. El segon abastarà el contingut a partir del 548 fins al 1211.

    En l'exemple 2, el mkvmerge(1) crearà un únic fitxer. Aquest abastarà ambdós, el contingut a partir del 733 fins al 912 i el contingut a partir del 1592 fins al 2730.

    En l'exemple 3, el mkvmerge(1) crearà dos fitxers. El primer abastarà el contingut des del començament dels fitxers d'origen fins al 430. El segon abastarà el contingut a partir del 2512 fins al final dels fitxers d'origen.

    Aquest mode només considera la primera pista de vídeo que es genera. Si no hi ha cap pista de vídeo a la sortida, no es produirà cap divisió.

    Note:

    Els números donats amb aquest argument són interpretats en base al nombre de blocs Matroska(tm) que es generen. Un únic bloc Matroska(tm) conté tot un fotograma (per a contingut progressiu) o només un camp (per a contingut entrellaçat). El mkvmerge(1) no fa distincions entre els dos i només compta el nombre de blocs. Per exemple: Si es vol dividir després del 25è fotograma amb material entrellaçat, llavors s'haurà d'usar 50 (dos camps per a tot un fotograma) com a punt de tall.

  6. Divisió després d'uns fotogrames/camps específics.

    Sintaxi: --split frames:A[,B[,C...]]

    Exemple: --split frames:120,237,891

    Els paràmetres A, B, C, etc. hauran de ser tots sencers positius. La numeració comença per 1. La llista de números de fotograma/camp estarà separada per comes. Després que el flux d'entrada hagi abastat el número de fotograma/camp del punt de tall actual, es crearà un fitxer nou. Després s'usarà el següent punt de tall indicat a la llista.

    El prefix «frames:» no es pot ometre.

    Aquest mode només considera la primera pista de vídeo que es genera. Si no hi ha cap pista de vídeo a la sortida, no es produirà cap divisió.

    Note:

    Els números donats amb aquest argument són interpretats en base al nombre de blocs Matroska(tm) que es generen. Un únic bloc Matroska(tm) conté tot un fotograma (per a contingut progressiu) o només un camp (per a contingut entrellaçat). El mkvmerge(1) no fa distincions entre els dos i només compta el nombre de blocs. Per exemple: Si es vol dividir després del 25è fotograma amb material entrellaçat, llavors s'haurà d'usar 50 (dos camps per a tot un fotograma) com a punt de tall.

  7. Dividir abans de capítols específics.

    Sintaxi: --split chapters:all o --split chapters:A[,B[,C...]]

    Exemple: --split chapters:5,8

    Els paràmetres A, B, C, etc. hauran de ser tots sencers positius. La numeració comença per 1. La llista de capítols estarà separada per comes. La divisió succeirà just abans del primer fotograma clau on el codi de temps sigui igual o major que el codi de temps d'inici per als capítols dels números llistats. Un capítol que comença als 0s mai es tindrà en compte per a la divisió i serà omès silenciosament.

    La paraula clau all es pot usar en lloc d'una llista manual de tots els números de capítols.

    El prefix «chapters:» no es pot ometre.

    Note:

    El format de fitxer Matroska(tm) admet estructures de capítols arbitràries i aniuades profundament anomenades «entrades de l'edició» (edition entries) i «àtoms del capítol» (chapter atoms). No obstant, aquest mode només té en compte el nivell més alt dels capítols al llarg de totes les entrades de l'edició.

En aquest mode de divisió, el nom del fitxer de sortida serà tractat de manera diferent que amb el funcionament normal. Pot contenir un printf com l'expressió «%d», incloent una amplada de camp opcional, p. ex., «%02d». Si es fa llavors el número del fitxer actual serà formatat adequadament i inserit en aquest punt del nom del fitxer. Si no hi ha aquest patró, llavors s'assumirà «-%03d» com a patró just abans de l'extensió del fitxer: «-o sortida.mkv» resultaria en «sortida-001.mkv» i així en endavant. Si no hi ha extensió, llavors s'afegirà «-%03d» al nom.

--link

Els fitxers es vinculen a altres quan es divideix el fitxer de sortida. Per a més detalls, vegeu la següent secció vincular els fitxers.

--link-to-previous UID_segment

Vincula el primer fitxer de sortida al segment amb l'UID del segment indicat mitjançant el paràmetre UID_segment. Per a més detalls, vegeu la següent secció vincular els fitxers.

If SID starts with = then its rest is interpreted as the name of a Matroska file whose segment UID is read and used.

--link-to-next UID_segment

Vincula l'últim fitxer de sortida al segment amb l'UID del segment indicat mitjançant el paràmetre UID_segment. Per a més detalls, vegeu la següent secció vincular els fitxers.

If SID starts with = then its rest is interpreted as the name of a Matroska file whose segment UID is read and used.

--append-mode mode

Determina com es calcularan els codis de temps en annexar els fitxers. El paràmetre mode pot tenir dos valors: «file» que és l'opció per omissió i «track».

Quan el mkvmerge(1) annexa una pista (anomenada «pista2_1» d'ara en endavant) des d'un segon fitxer (anomenat «fitxer2») a una pista (anomenada «pista1_1») des del primer fitxer (anomenat «fitxer1») llavors compensarà una quantitat en tots els codis de temps per a la «pista2_1». En el mode «file» aquesta quantitat serà el major codi de temps trobat en el «fitxer1», fins i tot si aquest codi de temps provingués d'una pista diferent de «pista1_1». En el mode «track», la compensació serà el major codi de temps de la «pista1_1».

Malauradament, el mkvmerge(1) no pot detectar quin mode és més convenient usar. Per tant, per omissió usa el mode «file». Aquest mode, en general funciona millor per a fitxers que es creen de manera independent els uns dels altres; p. ex., quan s'annexen fitxers AVI o MP4. El mode «track» podria funcionar millor per a fonts que essencialment només són parts d'un fitxer gran, p. ex., per a fitxers VOB i EVO.

Les pistes de subtítols sempre seran tractades com si estigués actiu el mode «file», fins i tot si el que està actiu és el mode «track».

--append-to SFID1:STID1:DFID1:DTID1[...]

Aquesta opció controla quina pista és annexada a una altra. Cada especificació conté quatre ID: un identificador de fitxer (FID), un identificador de pista (TID), un segon identificador de fitxer i un segon identificador de pista. El primer parell, l'«ID del fitxer d'origen» i l'«ID de la pista de l'origen», identifiquen la pista que s'ha d'annexar. El segon parell, l'«ID del fitxer de destinació» i l'«ID de la pista de destinació», identifiquen la pista a la qual s'ha d'annexar la primera.

Si s'omet aquesta opció, llavors s'usarà un mapeig estàndard. Aquest, annexarà cada pista del fitxer actual a una pista del fitxer anterior amb el mateix ID de pista. Això permet annexar amb facilitat dos fitxers que havien estat dividits a partir d'una pel·lícula, si tenen el mateix nombre de pistes i ID de la pista, amb l'ordre: mkvmerge -o sortida.mkv part1.mkv +part2.mkv.

+

Un únic signe «+» causarà que s'annexi el fitxer següent en comptes d'afegir-lo. El signe «+» també es pot posar davant del nom de fitxer següent. Per tant, les dues ordres següents són equivalents:

$ mkvmerge -o complet.mkv fitxer_1.mkv + fitxer_2.mkv
$ mkvmerge -o complet.mkv fitxer_1.mkv +fitxer_2.mkv
=

Normally mkvmerge(1) looks for files in the same directory as an input file that have the same base name and only differ in their running number (e.g. 'VTS_01_1.VOB', 'VTS_01_2.VOB', 'VTS_01_3.VOB' etc) and treats all of those files as if they were concatenated into a single big file. This option, a single '=', causes mkvmerge not to look for those additional files.

El signe «=» també es pot posar davant del nom de fitxer següent. Per tant, les dues ordres següents són equivalents:

$ mkvmerge -o complet.mkv = fitxer_1.mkv
$ mkvmerge -o complet.mkv =fitxer_1.mkv
( fitxer_1 fitxer_2 )

If multiple file names are contained in a pair of parenthesis then those files will be treated as if they were concatenated into a single big file consisting of the content of each of the files one after the other.

This can be used for e.g. VOB files coming from a DVD or MPEG transport streams. It cannot be used if each file contains its own set of headers which is usually the case with stand-alone files like AVI or MP4.

Putting a file name into parenthesis also prevents mkvmerge(1) from looking for additional files with the same base name as described in option =. Therefore these two command lines are equivalent:

$ mkvmerge -o sortida.mkv = fitxer.mkv
$ mkvmerge -o sortida.mkv '(' fitxer.mkv ')'

Hi ha diverses coses que s'han de tenir en compte:

  1. Hi ha d'haver espais abans i després dels signes de parèntesi.

  2. Cada paràmetre entre parèntesis s'interpretarà com un nom de fitxer. Per tant, totes les opcions que s'hagin d'aplicar a aquest fitxer, per lògica s'hauran d'introduir abans del signe d'obertura del parèntesi.

  3. Alguns intèrprets d'ordres tracten els parèntesis com a caràcters especials. Per tant, s'hauran d'escapar o posar entre cometes tal com es mostra en l'exemple anterior.

2.6. Implementació per a adjunts (més opcions globals)

Option Description
--attachment-description descripció

Descripció en text pla del següent adjunt. S'aplica a l'opció --attach-file o --attach-file-once.

--attachment-mime-type tipus_MIME

Tipus MIME del següent adjunt. S'aplica a l'opció --attach-file o --attach-file-once. Es pot trobar una llista oficial de tipus MIME reconeguts a la pàgina web de la IANA. El tipus MIME és obligatori per a un adjunt.

--attachment-name nom

Estableix el nom per aquest adjunt que s'emmagatzemarà al fitxer de sortida. Si no s'especifica aquesta opció, llavors el nom derivarà del nom del fitxer de l'adjunt especificat amb l'opció --attach-file o --attach-file-once.

--attach-file nom_fitxer, --attach-file-once nom_fitxer

Crea un fitxer adjunt dins del fitxer Matroska(tm). El tipus MIME s'ha d'establir abans que aquesta opció es pugui usar. La diferència entre les dues formes és que durant la divisió, els fitxers adjunts amb --attach-file seran adjuntats a tots els fitxers de sortida mentre que amb --attach-file-once només s'adjuntaran al primer fitxer creat. Si no s'usa la divisió, llavors les dues opcions faran el mateix.

El mkvextract(1) es pot emprar per extreure els fitxers adjunts des d'un fitxer Matroska(tm).

2.7. Opcions que es poden usar per a cada fitxer d'entrada

Option Description
-a, --audio-tracks [!]n,m...

Copy the audio tracks n, m etc. The numbers are track IDs which can be obtained with the --identify switch. They're not simply the track numbers (see section track IDs). Default: copy all audio tracks.

Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks.

Per omissió: copia totes les pistes d'aquest tipus.

If the IDs are prefixed with ! then the meaning is reversed: copy all tracks of this kind but the ones listed after the !.

-d, --video-tracks [!]n,m...

Copia les pistes de vídeo n, m, etc. Els números són els ID de pista que es poden obtenir amb l'opció --identify. No són els números de la pista (vegeu la secció Els ID de la pista). Per omissió: copia totes les pistes de vídeo.

Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks.

If the IDs are prefixed with ! then the meaning is reversed: copy all tracks of this kind but the ones listed after the !.

-s, --subtitle-tracks [!]n,m...

Copia les pistes de subtítols n, m, etc. Els números són els ID de pista que es poden obtenir amb l'opció --identify. No són els números de la pista (vegeu la secció Els ID de la pista). Per omissió: copia totes les pistes de subtítols.

Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks.

If the IDs are prefixed with ! then the meaning is reversed: copy all tracks of this kind but the ones listed after the !.

-b, --button-tracks [!]n,m...

Copia les pistes de botons n, m, etc. Els números són els ID de pista que es poden obtenir amb l'opció --identify. No són els números de la pista (vegeu la secció Els ID de la pista). Per omissió: copia totes les pistes de botons.

Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks.

If the IDs are prefixed with ! then the meaning is reversed: copy all tracks of this kind but the ones listed after the !.

--track-tags [!]n,m...

Copia les etiquetes per a les pistes n, m, etc. Els números són els ID de pista que es poden obtenir amb l'opció --identify. No són els números de la pista (vegeu la secció Els ID de la pista). Per omissió: copia totes les pistes de vídeo.

If the IDs are prefixed with ! then the meaning is reversed: copy everything but the IDs listed after the !.

-m, --attachments [!]n[:all|first],m[:all|first]...

Copy the attachments with the IDs n, m etc to all or only the first output file. Each ID can be followed by either ':all' (which is the default if neither is entered) or ':first'. If splitting is active then those attachments whose IDs are specified with ':all' are copied to all of the resulting output files while the others are only copied into the first output file. If splitting is not active then both variants have the same effect.

El comportament per omissió és copiar tots els adjunts a tots els fitxers de sortida.

If the IDs are prefixed with ! then the meaning is reversed: copy everything but the IDs listed after the !.

-A, --no-audio

No copia cap pista d'àudio des d'aquest fitxer.

-D, --no-video

No copia cap pista de vídeo des d'aquest fitxer.

-S, --no-subtitles

No copia cap pista de subtítols des d'aquest fitxer.

-B, --no-buttons

No copia cap pista de botó des d'aquest fitxer.

-T, --no-track-tags

No copia cap etiqueta específica de pista des d'aquest fitxer.

--no-chapters

No copia cap capítol des d'aquest fitxer.

-M, --no-attachments

No copia cap adjunt des d'aquest fitxer.

--no-global-tags

No copia cap etiqueta global des d'aquest fitxer.

--chapter-charset joc_de_caràcters

Estableix el joc de caràcters que es farà servir per a la conversió a UTF-8 per a la informació de capítols continguda al fitxer d'origen. Vegeu la secció sobre la conversió per a fitxers de text i jocs de caràcters per a veure una explicació sobre com realitza el mkvmerge(1) la conversió entre diferents jocs de caràcters.

--chapter-language codi_idioma

Sets the ISO639-2 language code that is written for each chapter entry. This option can be used for source files that contain chapters but no information about the chapters' languages, e.g. for MP4 and OGM files.

-y, --sync TID:d[,o[/p]]

Adjust the timecodes of the track with the id TID by d ms. The track IDs are the same as the ones given with --identify (see section track IDs).

o/p: adjust the timestamps by o/p to fix linear drifts. p defaults to 1 if omitted. Both o and p can be floating point numbers.

Defaults: no manual sync correction (which is the same as d = 0 and o/p = 1.0).

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.

--cues TID:none|iframes|all

Controls for which tracks cue (index) entries are created for the given track (see section track IDs). 'none' inhibits the creation of cue entries. For 'iframes' only blocks with no backward or forward references ( = I frames in video tracks) are put into the cue sheet. 'all' causes mkvmerge(1) to create cue entries for all blocks which will make the file very big.

The default is 'iframes' for video tracks and 'none' for all others. See also option --no-cues which inhibits the creation of cue entries regardless of the --cues options used.

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.

--default-track TID[:booleà]

Sets the 'default' flag for the given track (see section track IDs) if the optional argument bool is not present. If the user does not explicitly select a track himself then the player should prefer the track that has his 'default' flag set. Only one track of each kind (audio, video, subtitles, buttons) can have his 'default' flag set. If the user wants no track to have the default track flag set then he has to set bool to 0 for all tracks.

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.

--forced-track TID[:booleà]

Sets the 'forced' flag for the given track (see section track IDs) if the optional argument bool is not present. A player must play all tracks for which this flag is set to 1.

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.

--blockadd TID:nivell

Només manté BlockAdditions fins al nivell per a la pista indicada. Per omissió ho manté en tots els nivells. Aquesta opció només afecta certs tipus de còdecs com WAVPACK4.

--track-name TID:nom

Sets the track name for the given track (see section track IDs) to name.

--language TID:idioma

Sets the language for the given track (see section track IDs). Both ISO639-2 language codes and ISO639-1 country codes are allowed. The country codes will be converted to language codes automatically. All languages including their ISO639-2 codes can be listed with the --list-languages option.

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.

-t, --tags TID:nom_fitxerTIDTID

Llegeix les etiquetes per a la pista amb el número TID des del fitxer nom_fitxer. Per a més detalls vegeu més endavant la secció sobre les etiquetes.

--aac-is-sbr TID[:0|1]

Tells mkvmerge(1) that the track with the ID TID is SBR AAC (also known as HE-AAC or AAC+). This options is needed if a) the source file is an AAC file (not for a Matroska(tm) file) and b) the AAC file contains SBR AAC data. The reason for this switch is that it is technically impossible to automatically tell normal AAC data from SBR AAC data without decoding a complete AAC frame. As there are several patent issues with AAC decoders mkvmerge(1) will never contain this decoding stage. So for SBR AAC files this switch is mandatory. The resulting file might not play back correctly or even not at all if the switch was omitted.

If the source file is a Matroska(tm) file then the CodecID should be enough to detect SBR AAC. However, if the CodecID is wrong then this switch can be used to correct that.

If mkvmerge wrongfully detects that an AAC file is SBR then you can add ':0' to the track ID.

--reduce-to-core TID

Some audio codecs have a lossy core and optional extensions that implement lossless decoding. This option tells mkvmerge(1) to only copy the core but not the extensions. By default mkvmerge(1) copies both the core and the extensions.

Currently only DTS tracks are affected by this option. TrueHD tracks that contain an embedded AC-3 core are instead presented as two separate tracks for which the user can select which track to copy. For DTS such a scheme would not work as the HD extensions cannot be decoded by themselves – unlike the TrueHD data.

If mkvmerge wrongfully detects that an AAC file is SBR then you can add ':0' to the track ID.

--timecodes TID:nom_fitxer

Read the timecodes to be used for the specific track ID from file-name. These timecodes forcefully override the timecodes that mkvmerge(1) normally calculates. Read the section about external timecode files.

--default-duration TID:x

Forces the default duration of a given track to the specified value. Also modifies the track's timecodes to match the default duration. The argument x must be postfixed with 's', 'ms', 'us', 'ns', 'fps', 'p' or 'i' to specify the default duration in seconds, milliseconds, microseconds, nanoseconds, 'frames per second', 'progressive frames per second' or 'interlaced frames per second' respectively. The number x itself can be a floating point number or a fraction.

If the default duration is not forced then mkvmerge will try to derive the track's default duration from the container and/or the encoded bitstream for certain track types, e.g. AVC/h.264 or MPEG-2.

This option can also be used to change the FPS of video tracks without having to use an external timecode file.

--fix-bitstream-timing-information TID[:0|1]

Normally mkvmerge(1) does not change the timing information (frame/field rate) stored in the video bitstream. With this option that information is adjusted to match the container timing information. The container timing information can come from various sources: from the command line (see option --default-duration), the source container or derived from the bitstream.

Note:

Per ara, només s'ha implementat per a pistes AVC/h.264.

--nalu-size-length TID:n

Forces the NALU size length to n bytes. This parameter is only used if the AVC/h.264 elementary stream packetizer is used. If left out it defaults to 4 bytes, but there are files that contain frames or slices that are all smaller than 65536 bytes. For such files you can use this parameter and decrease the size to 2.

--compression TID:n

Selects the compression method to be used for the track. Note that the player also has to support this method. Valid values are 'none', 'zlib', 'lzo'/'lxo1x', 'bz2'/'bzlib' and 'mpeg4_p2'/'mpeg4p2'. The values 'lzo'/'lxo1x' and 'bz2'/'bzlib' are only available if mkvmerge(1) has been compiled with support for the liblzo(tm) and bzlib(tm) compression libraries, respectively.

The compression method 'mpeg4_p2'/'mpeg4p2' is a special compression method called 'header removal' that is only available for MPEG4 part 2 video tracks.

The default for some subtitle tracks is 'zlib' compression. This compression method is also the one that most if not all playback applications support. Support for other compression methods other than 'none' is not assured.

2.8. Opcions que només s'apliquen a les pistes de vídeo

Option Description
-f, --fourcc TID:FourCC

Força el FourCC al valor especificat. Només funciona per a les pistes de vídeo en el mode compatibilitat de MS.

--display-dimensions TID:amplada_x_alçada

Matroska(tm) files contain two values that set the display properties that a player should scale the image on playback to: display width and display height. These values can be set with this option, e.g. '1:640x480'.

Another way to specify the values is to use the --aspect-ratio or the --aspect-ratio-factor option (see below). These options are mutually exclusive.

--aspect-ratio TID:relació|amplada/alçada

Matroska(tm) files contain two values that set the display properties that a player should scale the image on playback to: display width and display height. With this option mkvmerge(1) will automatically calculate the display width and display height based on the image's original width and height and the aspect ratio given with this option. The ratio can be given either as a floating point number ratio or as a fraction 'width/height', e.g. '16/9'.

Another way to specify the values is to use the --aspect-ratio-factor or --display-dimensions options (see above and below). These options are mutually exclusive.

--aspect-ratio-factor TID:factor|n/d

Another way to set the aspect ratio is to specify a factor. The original aspect ratio is first multiplied with this factor and used as the target aspect ratio afterwards.

Another way to specify the values is to use the --aspect-ratio or --display-dimensions options (see above). These options are mutually exclusive.

--cropping TID:Esquerra,A_dalt,Dreta,A_baix

Sets the pixel cropping parameters of a video track to the given values.

--stereo-mode TID:n|Paraula_clau

Sets the stereo mode for the video track with the track ID TID. The mode can either be a number n between 0 and 14 or one of these keywords:

'mono', 'side_by_side_left_first', 'top_bottom_right_first', 'top_bottom_left_first', 'checkerboard_right_first', 'checkerboard_left_first', 'row_interleaved_right_first', 'row_interleaved_left_first', 'column_interleaved_right_first', 'column_interleaved_left_first', 'anaglyph_cyan_red', 'side_by_side_right_first', 'anaglyph_green_magenta', 'both_eyes_laced_left_first', 'both_eyes_laced_right_first'.

2.9. Opcions que només s'apliquen a pistes de subtítols de text

Option Description
--sub-charset TID:joc_de_caràcters

Sets the character set for the conversion to UTF-8 for UTF-8 subtitles for the given track ID. If not specified the charset will be derived from the current locale settings. Note that a charset is not needed for subtitles read from Matroska(tm) files or from Kate streams, as these are always stored in UTF-8. See the section about text files and character sets for an explanation how mkvmerge(1) converts between character sets.

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.

2.10. Altres opcions

Option Description
-i, --identify nom_fitxer

Will let mkvmerge(1) probe the single file and report its type, the tracks contained in the file and their track IDs. If this option is used then the only other option allowed is the filename.

The output format used for the result can be changed with the option --identification-format.

-I, --identify-verbose nom_fitxer

This option is deprecated. Use --identification-format verbose-text --identify … instead.

-F, --identification-format format

Determines the output format used by the --identify option. The following formats are supported: text (the default if this option isn't used), verbose-text and json.

  1. The text format is short and human-readable. It consists of one line per item found (container, tracks, attachments etc.).

    This format is not meant to be parsed. The output will be translated into the language mkvmerge(1) uses (see also --ui-language).

  2. The verbose-text format extends the text format with additional properties for each item. The extra information is surronded by square brackets. It consists of space-saparated key/value pairs where keys and values are separated by a colon.

    Cada valor és escapat d'acord amb les regles descrites a la secció sobre escapar caràcters especials en el text.

    This format is not meant to be parsed. The output will be translated into the language mkvmerge(1) uses (see also --ui-language).

  3. The json format outputs a machine-readable JSON representation. This format follows the JSON schema described in the file mkvmerge-identification-output-schema.json.

-l, --list-types

Llista els tipus de fitxers d'entrada admesos.

--list-languages

Lists all languages and their ISO639-2 code which can be used with the --language option.

--priority prioritat

Sets the process priority that mkvmerge(1) runs with. Valid values are 'lowest', 'lower', 'normal', 'higher' and 'highest'. If nothing is given then 'normal' is used. On Unix like systems mkvmerge(1) will use the nice(2) function. Therefore only the super user can use 'higher' and 'highest'. On Windows all values are useable for every user.

Selecting 'lowest' also causes mkvmerge(1) to select idle I/O priority in addition to the lowest possible process priority.

--command-line-charset joc_de_caràcters

Estableix el joc de caràcters al qual convertir les cadenes donades des de la línia d'ordres. Per omissió serà el joc de caràcters donat per la configuració regional actual del sistema. Aquesta ajustament s'aplicarà als arguments de les següents opcions: --title, --track-name i --attachment-description.

--output-charset joc_de_caràcters

Estableix el joc de caràcters al qual convertir les cadenes donades per la sortida. Per omissió serà el joc de caràcters establert a la configuració regional actual del sistema.

-r, --redirect-output nom_fitxer

Escriu tots els missatges al fitxer nom_fitxer en lloc de a la consola. Si bé això es pot fer fàcilment amb la redirecció de la sortida, hi ha casos en què cal aquesta opció: quan el terminal reinterpreta la sortida abans d'escriure-la a un fitxer. Es respecta el joc de caràcters establert amb --output-charset.

--ui-language codi

Força l'ús de les traduccions pel codi d'idioma (p. ex., «de_DE» per a les traduccions en alemany). Tot i que és preferible usar les variables d'entorn LANG, LC_MESSAGES i LC_ALL. Introduint «list» com a codi farà que el mkvmerge(1) ofereixi a la sortida, una llista de les traduccions disponibles.

--debug tema

Activa la depuració per a una característica específica. Aquesta opció només és útil per als desenvolupadors.

--engage característica

Activa les característiques experimentals. Es pot sol·licitar una llista de les característiques disponibles amb mkvmerge --engage list. Aquestes característiques no estan destinades a ser emprades en situacions normals.

--gui-mode

Activa el mode IGU. En aquest mode, les línies surten amb un format especial que pot explicar-vos el que està succeint per tal de controlar la IGU. Aquests missatges segueixen el format «#GUI#message». El missatge pot estar seguit per parells clau/valor com a «#GUI#message#key1=value1#key2=value2…». Ni els missatges ni les claus seran traduïts, sempre sortiran en anglès.

@fitxer_opcions

Reads additional command line arguments from the file options-file. See the section about option files for further information.

--capabilities

Lists information about optional features that have been compiled in and exit. The first line output will be the version information. All following lines contain exactly one word whose presence indicates that the feature has been compiled in. These features are:

  • 'BZ2' -- the bzlib(tm) compression library. Affects the available compression methods for the --compression option.

  • 'LZO' -- the lzo(tm) compression library. Affects the available compression methods for the --compression option.

  • 'FLAC' -- reading raw FLAC files and handling FLAC tracks in other containers, e.g. Ogg(tm) or Matroska(tm).

-h, --help

Mostra la informació d'ús i surt.

-V, --version

Mostra la informació sobre la versió i surt.

--check-for-updates

Comprova en línia si hi ha nous llançaments per baixar-los des de l'URL http://mkvtoolnix-releases.bunkus.org/latest-release.xml. Es generaran quatre línies amb l'estil key=valor: l'URL des d'on s'ha obtingut la informació (clau version_check_url), la versió actualment en execució (clau running_version), la versió de l'últim llançament (clau available_version) i l'URL per a la baixada (clau download_url).

Després el programa sortirà amb un codi de sortida de 0 si no hi ha cap llançament més recent disponible, amb 1 si hi ha disponible una nova versió i amb 2 si s'ha produït un error (p. ex., si no s'ha pogut recuperar la informació sobre l'actualització).

Aquesta opció només estarà disponible si el programa va ser construït amb la implementació per a «libcurl».

3. Ús

For each file the user can select which tracks mkvmerge(1) 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.

Important:

L'ordre de les opcions a la línia d'ordres és important. Si us plau, llegiu la secció «L'ordre de les opcions» si sou novell emprant aquest programa.

4. L'ordre de les opcions

The order in which options are entered is important for some options. Options fall into two categories:

  1. Options that affect the whole program and are not tied to any input file. These include but are not limited to --command-line-charset, --output or --title. These can appear anywhere on the command line.

  2. Options that affect a single input file or a single track in an input file. These options all apply to the following input file on the command line. All options applying to the same input (or to tracks from the same input file) file can be written in any order as long as they all appear before that input file's name. Examples for options applying to an input file are --no-chapters or --chapter-charset. Examples for options applying to a single track are --default-duration or --language.

The options are processed from left to right. If an option appears multiple times within the same scope then the last occurence will be used. Therefore the title will be set to "Something else" in the following example:

$ mkvmerge -o sortida.mkv --title 'Això i allò' entrada.avi --title 'Qualsevulla cosa'

The following example shows that using the --language option twice is OK because they're used in different scopes. Even though they apply to the same track ID they apply to different input files and therefore have different scopes:

$ mkvmerge -o sortida.mkv --language 0:fre frances.ogg --language 0:deu holandes.ogg

5. Exemples

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 OggVorbis(tm):

$ oggenc -q4 -o meva_peli.ogg meva_peli.wav

Després d'uns minuts ja podreu unir l'àudio i el vídeo:

$ mkvmerge -o meva_peli-amb-so.mkv meva_peli.avi meva_peli.ogg

If your AVI already contains an audio track then it will be copied as well (if mkvmerge(1) supports the audio format). To avoid that simply do

$ mkvmerge -o meva_peli-amb-so.mkv -A meva_peli.avi meva_peli.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 -o meva_peli-afegeix-àudio.ogg meva_peli-afegeix-àudio.wav
$ mkvmerge -o MM-completa.mkv meva_peli-amb-so.mkv meva_peli-afegeix-àudio.ogg

Es pot aconseguir el mateix resultat amb

$ mkvmerge -o MM-complet.mkv -A meva_peli.avi meva_peli.ogg meva_peli-afegeix_àudio.ogg

Now fire up mplayer(tm) and enjoy. If you have multiple audio tracks (or even video tracks) then you can tell mplayer(tm) which track to play with the '-vid' and '-aid' options. These are 0-based and do not distinguish between video and audio.

If you need an audio track synchronized you can do that easily. First find out which track ID the Vorbis track has with

$ mkvmerge --identify desincronitzat.ogg

Ara podeu emprar aquest ID a la línia d'ordres següent:

$ mkvmerge -o ben_sincronitzat.mkv -A origen.avi -y 12345:200 sense_sincronitzar.ogg

This would add 200ms of silence at the beginning of the audio track with the ID 12345 taken from 'outofsync.ogg'.

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

$ mkvmerge -o ben_sincronitzat.mkv -y 23456:0,77346/77340 sense_sincronitzar.mkv

El resultat ha estat bo.

Les opcions de sincronització també es poden usar per a subtítols de la mateixa manera.

For text subtitles you can either use some Windows software (like SubRipper(tm)) or the subrip(tm) package found in transcode(1)'s sources in the 'contrib/subrip' directory. The general process is:

  1. extract a raw subtitle stream from the source:

    $ tccat -i /camí/on/copiar/dvd/ -T 1 -L | tcextract -x ps1 -t vob -a 0x20 | subtitle2pgm -o meva_peli
  2. convert the resulting PGM images to text with gocr:

    $ pgm2txt meva_peli
  3. spell-check the resulting text files:

    $ ispell -d american *txt
  4. convert the text files to a SRT file:

    $ srttool -s -w -i meva_peli.srtx -o meva_peli.srt

El fitxer resultant el pot usar el mkvmerge(1) com un altre fitxer d'entrada:

$ mkvmerge -o meva_peli.mkv meva_peli.avi meva_peli.srt

If you want to specify the language for a given track then this is easily done. First find out the ISO639-2 code for your language. mkvmerge(1) can list all of those codes for you:

$ mkvmerge --list-languages

Search the list for the languages you need. Let's assume you have put two audio tracks into a Matroska(tm) file and want to set their language codes and that their track IDs are 2 and 3. This can be done with

$ mkvmerge -o amb_codis_d_idioma.mkv --language 2:ger --language 3:dut sense_codis_d_idioma.mkv

As you can see you can use the --language switch multiple times.

Maybe you'd also like to have the player use the Dutch language as the default language. You also have extra subtitles, e.g. in English and French, and want to have the player display the French ones by default. This can be done with

$ mkvmerge -o amb_codis_d_idioma.mkv --language 2:ger --language 3:dut --default-track 3 sense_codis_d_idioma.mkv --language 0:eng anglès.srt --default-track 0 --language 0:fre francès.srt

If you do not see the language or default track flags that you've specified in mkvinfo(1)'s output then please read the section about default values.

Deshabilita la compressió per a un fitxer d'entrada.

$ mkvmerge -o sense_compressió.mkv --compression -1:none meva_peli.avi --compression -1:none meva_peli.srt

6. Els ID de la pista

Some of the options for mkvmerge(1) need a track ID to specify which track they should be applied to. Those track IDs are printed by the readers when demuxing the current input file, or if mkvmerge(1) is called with the --identify option. An example for such output:

$ mkvmerge -i v.mkv
Fitxer «v.mkv»: contenidor: Matroska
ID de la pista 0: video (V_MS/VFW/FOURCC, DIV3)
ID de la pista 1: audio (A_MPEG/L3)

Do not confuse the track IDs that are assigned to the tracks that are placed in the output MKV file with the track IDs of the input files. Only the input file track IDs are used for options needing these values.

Also note that each input file has its own set of track IDs. Therefore the track IDs for file 'file1.ext' as reported by 'mkvmerge --identify' do not change no matter how many other input files are there or in which position 'file1.ext' is used.

Els ID de pista són assignats així:

The special track ID '-1' is a wild card and applies the given switch to all tracks that are read from an input file.

The options that use the track IDs are the ones whose description contains 'TID'. The following options use track IDs as well: --audio-tracks, --video-tracks, --subtitle-tracks, --button-tracks and --track-tags.

7. Conversió per a fitxers de text i jocs de caràcters

Note:

This section applies to all programs in MKVToolNix even if it only mentions mkvmerge(1).

7.1. Introducció

All text in a Matroska(tm) file is encoded in UTF-8. This means that mkvmerge(1) has to convert every text file it reads as well as every text given on the command line from one character set into UTF-8. In return this also means that mkvmerge(1)'s output has to be converted back to that character set from UTF-8, e.g. if a non-English translation is used with --ui-language or for text originating from a Matroska(tm) file.

mkvmerge(1) does this conversion automatically based on the presence of a byte order marker (short: BOM) or the system's current locale. How the character set is inferred from the locale depends on the operating system that mkvmerge(1) is run on.

7.2. Byte order markers (BOM)

Text files that start with a BOM are already encoded in one representation of UTF. mkvmerge(1) supports the following five modes: UTF-8, UTF-16 Little and Big Endian, UTF-32 Little and Big Endian. Text files with a BOM are automatically converted to UTF-8. Any of the parameters that would otherwise set the character set for such a file (e.g. --sub-charset) is silently ignored.

7.3. Sistemes Linux i Unix, incloent el Mac OS

On Unix-like systems mkvmerge(1) uses the setlocale(3) system call which in turn uses the environment variables LANG, LC_ALL and LC_CYPE. The resulting character set is often one of UTF-8 or the ISO-8859-* family and is used for all text file operations and for encoding strings on the command line and for output to the console.

7.4. Windows

On Windows the default character set used for converting text files is determined by a call to the GetACP() system call.

Reading the command line is done with the GetCommandLineW() function which already returns a Unicode string. Therefore the option --command-line-charset is ignored on Windows.

La sortida a la consola consta de tres escenaris:

  1. If the output is redirected with the option --redirect-output then the default charset is UTF-8. This can be changed with --output-charset.

    If the output is redirected with cmd.exe itself, e.g. with mkvinfo file.mkv > info.txt, then the charset is always UTF-8 and cannot be changed.

    Otherwise (when writing directly to the console) the Windows function WriteConsoleW() is used and the option --output-charset is ignored. The console should be able to output all Unicode characters for which the corresponding language support is installed (e.g. Chinese characters might not be displayed on English Windows versions).

7.5. Opcions de la línia d'ordres

Les següents opcions permeten especificar els jocs de caràcters:

8. Fitxers d'opcions

An option file is a file mkvmerge(1) can read additional command line arguments from. This can be used in order to circumvent certain limitations of the shell or the operating system when executing external programs like a limited command line length.

Hi ha diverses regles relatives als fitxers d'opcions. Les línies que tinguin com a primer caràcter un coixinet (#) seran tractades com a comentaris i ignorades. Els espais en blanc al començament i final de la línia seran descartats. Cada línia haurà de contenir exactament una opció.

A line not containing anything is also ignored. An empty argument is represented by the line '#EMPTY#'.

Es poden interpretar diversos caràcters com d'escapament, p. ex., si necessiteu que una línia que comença amb un coixinet «#», no sigui interpretada com un comentari. Les regles es descriuen a la secció sobre escapar en el text.

Note that backslashes must always be escaped. Hash marks ('#') must be escaped if they should not start a comment.

La línia d'ordres «mkvmerge -o "meu_fitxer.mkv" -A "una_peli.avi" so.ogg» es pot convertir en el següent fitxer d'opcions:

# Escriu al fitxer «C:\Matroska\meu_fitxer.mkv», sota Windows.
-o
C:\\Matroska\\meu_fitxer.mkv
# Estableix el títol a «#65».
--title
\h65
# Només pren el vídeo de «una_peli.avi».
-A
una_peli.avi
so.ogg

9. Caràcters especials d'escapament en el text

Hi ha pocs llocs en els quals els caràcters especials en el text puguin o s'hagin d'escapar. Les regles de l'escapament són simples: cada caràcter que necessiti ser escapat serà substituït amb una barra invertida seguida d'un altre caràcter.

Les regles són: « » (un espai) serà «\s», «"» (cometes) serà «\2», «:» serà «\c», «#» serà «\h», «[» serà «\b», «]» serà «\B» i «\» (una única barra invertida) serà «\\».

10. Subtítols

There are several text and bitmap subtitle formats that can be embedded into Matroska(tm). Text subtitles must be recoded to UTF-8 so that they can be displayed correctly by a player (see the section about text files and character sets for an explanation how mkvmerge(1) converts between character sets). Kate subtitles are already encoded in UTF-8 and do not have to be re-encoded.

De moment s'admeten els següents formats de subtítols:

11. Vincular els fitxers

Matroska(tm) supports file linking which simply says that a specific file is the predecessor or successor of the current file. To be precise, it's not really the files that are linked but the Matroska(tm) segments. As most files will probably only contain one Matroska(tm) segment the following explanations use the term 'file linking' although 'segment linking' would be more appropriate.

Each segment is identified by a unique 128 bit wide segment UID. This UID is automatically generated by mkvmerge(1). The linking is done primarily via putting the segment UIDs (short: SID) of the previous/next file into the segment header information. mkvinfo(1) prints these SIDs if it finds them.

If a file is split into several smaller ones and linking is used then the timecodes will not start at 0 again but will continue where the last file has left off. This way the absolute time is kept even if the previous files are not available (e.g. when streaming). If no linking is used then the timecodes should start at 0 for each file. By default mkvmerge(1) does not use file linking. If you want that you can turn it on with the --link option. This option is only useful if splitting is activated as well.

Regardless of whether splitting is active or not the user can tell mkvmerge(1) to link the produced files to specific SIDs. This is achieved with the options --link-to-previous and --link-to-next. These options accept a segment SID in the format that mkvinfo(1) outputs: 16 hexadecimal numbers between 0x00 and 0xff prefixed with '0x' each, e.g. '0x41 0xda 0x73 0x66 0xd9 0xcf 0xb2 0x1e 0xae 0x78 0xeb 0xb4 0x5e 0xca 0xb3 0x93'. Alternatively a shorter form can be used: 16 hexadecimal numbers between 0x00 and 0xff without the '0x' prefixes and without the spaces, e.g. '41da7366d9cfb21eae78ebb45ecab393'.

If splitting is used then the first file is linked to the SID given with --link-to-previous and the last file is linked to the SID given with --link-to-next. If splitting is not used then the one output file will be linked to both of the two SIDs.

12. Valors per omissió

The Matroska(tm) specification states that some elements have a default value. Usually an element is not written to the file if its value is equal to its default value in order to save space. The elements that the user might miss in mkvinfo(1)'s output are the language and the default track flag elements. The default value for the language is English ('eng'), and the default value for the default track flag is true. Therefore if you used --language 0:eng for a track then it will not show up in mkvinfo(1)'s output.

13. Adjunts

Maybe you also want to keep some photos along with your Matroska(tm) file, or you're using SSA subtitles and need a special TrueType(tm) font that's really rare. In these cases you can attach those files to the Matroska(tm) file. They will not be just appended to the file but embedded in it. A player can then show those files (the 'photos' case) or use them to render the subtitles (the 'TrueType(tm) fonts' case).

Here's an example how to attach a photo and a TrueType(tm) font to the output file:

$ mkvmerge -o output.mkv -A video.avi sound.ogg \
  --attachment-description "Me and the band behind the stage in a small get-together" \
  --attachment-mime-type image/jpeg \
  --attach-file me_and_the_band.jpg \
  --attachment-description "The real rare and unbelievably good looking font" \
  --attachment-type application/octet-stream \
  --attach-file really_cool_font.ttf

If a Matroska(tm) containing attachments file is used as an input file then mkvmerge(1) will copy the attachments into the new file. The selection which attachments are copied and which are not can be changed with the options --attachments and --no-attachments.

14. Capítols

The Matroska(tm) chapter system is more powerful than the old known system used by OGM files. The full specifications can be found at the Matroska website.

mkvmerge(1) supports two kinds of chapter files as its input. The first format, called 'simple chapter format', is the same format that the OGM tools expect. The second format is a XML based chapter format which supports all of Matroska(tm)'s chapter functionality.

14.1. El format de capítols simple

This formmat consists of pairs of lines that start with 'CHAPTERxx=' and 'CHAPTERxxNAME=' respectively. The first one contains the start timecode while the second one contains the title. Here's an example:

CHAPTER01=00:00:00.000
CHAPTER01NAME=Introducció
CHAPTER02=00:02:30.000
CHAPTER02NAME=El nen prepara un rock
CHAPTER03=00:02:42.300
CHAPTER03NAME=El nen fa trontollar la casa

mkvmerge(1) will transform every pair or lines into one Matroska(tm) ChapterAtom. It does not set any ChapterTrackNumber which means that the chapters all apply to all tracks in the file.

Com es tracta d'un fitxer de text, podria ser necessari realitzar una conversió del joc de caràcters. Vegeu la secció sobre la conversió per a fitxers de text i jocs de caràcters per a veure una explicació sobre com realitza el mkvmerge(1) la conversió entre diferents jocs de caràcters.

14.2. El format de capítols basat en XML

El format de capítols basat en XML s'assembla a aquest exemple:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Chapters SYSTEM "matroskachapters.dtd">
<Chapters>
  <EditionEntry>
    <ChapterAtom>
      <ChapterTimeStart>00:00:30.000</ChapterTimeStart>
      <ChapterTimeEnd>00:01:20.000</ChapterTimeEnd>
      <ChapterDisplay>
        <ChapterString>Un capítol curt</ChapterString>
        <ChapterLanguage>cat</ChapterLanguage>
      </ChapterDisplay>
      <ChapterAtom>
        <ChapterTimeStart>00:00:46.000</ChapterTimeStart>
        <ChapterTimeEnd>00:01:10.000</ChapterTimeEnd>
        <ChapterDisplay>
          <ChapterString>Una part d'aquest capítol curt</ChapterString>
          <ChapterLanguage>cat</ChapterLanguage>
        </ChapterDisplay>
      </ChapterAtom>
    </ChapterAtom>
  </EditionEntry>
</Chapters>

With this format three things are possible that are not possible with the simple chapter format:

  1. The timestamp for the end of the chapter can be set,

  2. chapters can be nested,

  3. the language and country can be set.

The mkvtoolnix distribution contains some sample files in the doc subdirectory which can be used as a basis.

The following lists the supported XML tags, their data types and, where appropriate, the valid range for their values:

Chapters (master)
  EditionEntry (master)
    EditionUID (unsigned integer, valid range: 1 <= value)
    EditionFlagHidden (unsigned integer, valid range: 0 <= value <= 1)
    EditionFlagDefault (unsigned integer, valid range: 0 <= value <= 1)
    EditionFlagOrdered (unsigned integer, valid range: 0 <= value <= 1)
    ChapterAtom (master)
      ChapterAtom (master)
      ChapterUID (unsigned integer, valid range: 1 <= value)
      ChapterTimeStart (unsigned integer)
      ChapterTimeEnd (unsigned integer)
      ChapterFlagHidden (unsigned integer, valid range: 0 <= value <= 1)
      ChapterFlagEnabled (unsigned integer, valid range: 0 <= value <= 1)
      ChapterSegmentUID (binary, valid range: 1 <= length in bytes)
      ChapterSegmentEditionUID (unsigned integer, valid range: 1 <= value)
      ChapterPhysicalEquiv (unsigned integer)
      ChapterTrack (master)
        ChapterTrackNumber (unsigned integer, valid range: 1 <= value)
      ChapterDisplay (master)
        ChapterString (UTF-8 string)
        ChapterLanguage (UTF-8 string)
        ChapterCountry (UTF-8 string)
      ChapterProcess (master)
        ChapterProcessCodecID (unsigned integer)
        ChapterProcessPrivate (binary)
        ChapterProcessCommand (master)
          ChapterProcessTime (unsigned integer)
          ChapterProcessData (binary)

14.3. Notes generals

When splitting files mkvmerge(1) will correctly adjust the chapters as well. This means that each file only includes the chapter entries that apply to it, and that the timecodes will be offset to match the new timecodes of each output file.

mkvmerge(1) is able to copy chapters from Matroska(tm) source files unless this is explicitly disabled with the --no-chapters option. The chapters from all sources (Matroska(tm) files, Ogg files, MP4 files, chapter text files) are usually not merged but end up in separate ChapterEditions. Only if chapters are read from several Matroska(tm) or XML files that share the same edition UIDs will chapters be merged into a single ChapterEdition. If such a merge is desired in other situations as well then the user has to extract the chapters from all sources with mkvextract(1) first, merge the XML files manually and mux them afterwards.

15. Etiquetes

15.1. Introducció

Matroska(tm) supports an extensive set of tags that is deprecated and a new, simpler system like it is is used in most other containers: KEY=VALUE. However, in Matroska(tm) these tags can also be nested, and both the KEY and the VALUE are elements of their own. The example file example-tags-2.xml shows how to use this new system.

15.2. Àmbit de les etiquetes

Matroska(tm) tags do not automatically apply to the complete file. They can, but they also may apply to different parts of the file: to one or more tracks, to one or more chapters, or even to a combination of both. The the Matroska specification gives more details about this fact.

One important fact is that tags are linked to tracks or chapters with the Targets Matroska(tm) tag element, and that the UIDs used for this linking are not the track IDs mkvmerge(1) uses everywhere. Instead the numbers used are the UIDs which mkvmerge(1) calculates automatically (if the track is taken from a file format other than Matroska(tm)) or which are copied from the source file if the track's source file is a Matroska(tm) file. Therefore it is difficult to know which UIDs to use in the tag file before the file is handed over to mkvmerge(1).

mkvmerge(1) knows two options with which you can add tags to Matroska(tm) files: The --global-tags and the --tags options. The difference is that the former option, --global-tags, will make the tags apply to the complete file by removing any of those Targets elements mentioned above. The latter option, --tags, automatically inserts the UID that mkvmerge(1) generates for the tag specified with the TID part of the --tags option.

15.3. Exemple

Let's say that you want to add tags to a video track read from an AVI. mkvmerge --identify file.avi tells you that the video track's ID (do not mix this ID with the UID!) is 0. So you create your tag file, leave out all Targets elements and call mkvmerge(1):

$ mkvmerge -o fitxer.mkv --tags 0:etiquetes.xml fitxer.avi

15.4. Format del fitxer d'etiquetes

mkvmerge(1) supports a XML based tag file format. The format is very closely modeled after the Matroska specification. Both the binary and the source distributions of MKVToolNix come with a sample file called example-tags-2.xml which simply lists all known tags and which can be used as a basis for real life tag files.

Els fonaments són:

15.5. Tipus de dades

The new Matroska(tm) tagging system only knows two data types, a UTF-8 string and a binary type. The first is used for the tag's name and the <String> element while the binary type is used for the <Binary> element.

As binary data itself would not fit into a XML file mkvmerge(1) supports two other methods of storing binary data. If the contents of a XML tag starts with '@' then the following text is treated as a file name. The corresponding file's content is copied into the Matroska(tm) element.

Otherwise the data is expected to be Base64 encoded. This is an encoding that transforms binary data into a limited set of ASCII characters and is used e.g. in email programs. mkvextract(1) will output Base64 encoded data for binary elements.

The deprecated tagging system knows some more data types which can be found in the official Matroska(tm) tag specs. As mkvmerge(1) does not support this system anymore these types aren't described here.

15.6. Etiquetes conegudes per al format de fitxer en XML

The following lists the supported XML tags, their data types and, where appropriate, the valid range for their values:

Tags (master)
  Tag (master)
    Targets (master)
      TargetTypeValue (unsigned integer)
      TargetType (UTF-8 string)
      TrackUID (unsigned integer)
      EditionUID (unsigned integer)
      ChapterUID (unsigned integer)
      AttachmentUID (unsigned integer)
    Simple (master)
      Simple (master)
      Name (UTF-8 string)
      TagLanguage (UTF-8 string)
      DefaultLanguage (unsigned integer)
      String (UTF-8 string)
      Binary (binary)

16. Els fitxers XML d'informació del segment

With a segment info XML file it is possible to set certain values in the "segment information" header field of a Matroska(tm) file. All of these values cannot be set via other command line options.

Other "segment information" header fields can be set via command line options but not via the XML file. This includes e.g. the --title and the --timecode-scale options.

There are other elements that can be set neither via command line options nor via the XML files. These include the following elements: DateUTC (also known as the "muxing date"), MuxingApp, WritingApp and Duration. They're always set by mkvmerge(1) itself.

The following lists the supported XML tags, their data types and, where appropriate, the valid range for their values:

Info (master)
  SegmentUID (binary, valid range: length in bytes == 16)
  SegmentFilename (UTF-8 string)
  PreviousSegmentUID (binary, valid range: length in bytes == 16)
  PreviousSegmentFilename (UTF-8 string)
  NextSegmentUID (binary, valid range: length in bytes == 16)
  NextSegmentFilename (UTF-8 string)
  SegmentFamily (binary, valid range: length in bytes == 16)
  ChapterTranslate (master)
    ChapterTranslateEditionUID (unsigned integer)
    ChapterTranslateCodec (unsigned integer)
    ChapterTranslateID (binary)

17. Disposició dels fitxers Matroska

The Matroska(tm) file layout is quite flexible. mkvmerge(1) will render a file in a predefined way. The resulting file looks like this:

[EBML head] [segment {meta seek #1} [segment information] [track information] {attachments} {chapters} [cluster 1] {cluster 2} ... {cluster n} {cues} {meta seek #2} {tags}]

The elements in curly braces are optional and depend on the contents and options used. A couple of notes:

The shortest possible Matroska(tm) file would look like this:

[EBML head] [segment [segment information] [track information] [cluster 1]]

This might be the case for audio-only files.

18. Fitxers externs pels codis de temps

mkvmerge(1) allows the user to chose the timecodes for a specific track himself. This can be used in order to create files with variable frame rate video or include gaps in audio. A frame in this case is the unit that mkvmerge(1) creates separately per Matroska(tm) block. For video this is exactly one frame, for audio this is one packet of the specific audio type. E.g. for AC-3 this would be a packet containing 1536 samples.

Timecode files that are used when tracks are appended to each other must only be specified for the first part in a chain of tracks. For example if you append two files, v1.avi and v2.avi, and want to use timecodes then your command line must look something like this:

$ mkvmerge ... --timecodes 0:codis_de_temps.txt v1.avi +v2.avi

There are four formats that are recognized by mkvmerge(1). The first line always contains the version number. Empty lines, lines containing only whitespace and lines beginning with '#' are ignored.

18.1. Format v1 pel fitxer del codi de temps

This format starts with the version line. The second line declares the default number of frames per second. All following lines contain three numbers separated by commas: the start frame (0 is the first frame), the end frame and the number of frames in this range. The FPS is a floating point number with the dot '.' as the decimal point. The ranges can contain gaps for which the default FPS is used. An example:

# Format v1 pel codi de temps
assume 27.930
800,1000,25
1500,1700,30

18.2. Format v2 pel fitxer del codi de temps

In this format each line contains a timecode for the corresponding frame. This timecode must be given in millisecond precision. It can be a floating point number, but it doesn't have to be. You have to give at least as many timecode lines as there are frames in the track. The timecodes in this file must be sorted. Example for 25fps:

# Format v2 pel codi de temps
0
40
80

18.3. Format v3 pel fitxer del codi de temps

In this format each line contains a duration in seconds followed by an optional number of frames per second. Both can be floating point numbers. If the number of frames per second is not present the default one is used. For audio you should let the codec calculate the frame timecodes itself. For that you should be using 0.0 as the number of frames per second. You can also create gaps in the stream by using the 'gap' keyword followed by the duration of the gap. Example for an audio file:

# Format v3 pel codi de temps
assume 0.0
25.325
7.530,38.236
gap, 10.050
2.000,38.236

18.4. Format v4 pel fitxer del codi de temps

This format is identical to the v2 format. The only difference is that the timecodes do not have to be sorted. This format should almost never be used.

19. Codis de sortida

El mkvmerge(1) sortirà amb un d'aquests tres codis de sortida:

20. Variables d'entorn

El mkvmerge(1) usa les variables per omissió que es determinen a la configuració regional del sistema (p. ex., LANG i la família LC_*). Variables addicionals:

Option Description
MKVMERGE_DEBUG, MKVTOOLNIX_DEBUG i la seva forma abreujada MTX_DEBUG

El contingut es tractarà com si s'hagués passat l'opció --debug.

MKVMERGE_ENGAGE, MKVTOOLNIX_ENGAGE i la seva forma abreujada MTX_ENGAGE

El contingut es tractarà com si s'hagués passat l'opció --engage.

MKVMERGE_OPTIONS, MKVTOOLNIX_OPTIONS i la seva forma abreujada MTX_OPTIONS

El contingut serà dividit en espais en blanc. Les cadenes parcials resultants seran tractades com si haguessin estat passades com a opcions a la línia d'ordres. Si necessiteu passar caràcters especials (p. ex., espais) llavors els haureu d'escapar (vegeu la secció caràcters especials d'escapament en el text).

21. Vegeu també

mkvinfo(1), mkvextract(1), mkvpropedit(1), mkvtoolnix-gui(1)

22. WWW

The latest version can always be found at the MKVToolNix homepage.