VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 4 of 4
  1. Member
    Join Date
    Jul 2013
    Search Comp PM
    This guide is primarily for converting MKV to MP4 with MP4Box but also covers MP4 to MP4 repacking such as adding chapters and subtitles.
    (I wrote this guide after I sent someone these instructions via email, I figured I might as well post it somewhere to help other people new to this as well, hopefully this guide will help people who have not used MP4Box before.)

    The formatting on this Forum adds a space here or there, and some times I have had to use a new line to get it to display properly for Command Line instructions.

    Software you need for this is:




    for current & older versions:

    Oxelon Media Converter:

    K-Lite-Standard Codec Pack (Playback Testing with Media Player Classic & MediaInfo Lite):

    MetaX (Optional):

    YAMB (Optional):

    Extracting the contents of an MKV Container:

    Install MKVToolNix, and then extract the MKVExtractGUI-2 files to the same folder as MKVToolNix.

    Run the MKVExtractGUI-2 executable file and browse for and open your MKV file.
    Select the elements you wish to use for your new MP4 / M4V file from the list by checking the corresponding tick boxes.
    Then click the Extract command button.

    You should have separate files now for the video and audio, also if selected the subtitles and chapters as well.

    Convert DTS to AAC (or AC3):

    I use the program "Oxelon Media Converter" to convert DTS to 2 Channel AAC it's quick and easy.
    I do this as Apple do not support the DTS format, and I only need stereo sound for my iPad.

    Rebuild Chapters to Apple friendly format GPAC TTXT:

    Typical chapters extracted from Matroska (MKV) files are normally in OGG (*.OGM), Extensible Markup Language (*.XML), or SubRip-Text (*.SRT) format.
    Apple does not natively support these formats, supporting instead the Timed Text Format (*.TTXT) .

    To change other types of chapter files to TTXT open any of these files in Notepad, and then copy the time codes into a new text file saved in UTF-8 named “chapters.ttxt”.
    In the following example you can see the areas in red where you can cut and paste the time codes into a previously created template, optionally you can replace the chapter numbers with names as well.

    <?xml version="1.0" encoding="UTF-8" ?>
    <!-- GPAC 3GPP Text Stream -->
    <TextStream version="1.1">
    <TextStreamHeader width="480" height="368" layer="0" translation_x="0" translation_y="0">
    <TextSampleDescription horizontalJustification="center" verticalJustification="bottom" backColor="0 0 0 0" verticalText="no" fillTextRegion="no" continuousKaraoke="no" scroll="None">
    <FontTableEntry fontName="Arial" fontID="1"/>
    <TextBox top="0" left="0" bottom="368" right="480"/>
    <Style styles="Normal" fontID="1" fontSize="32" color="ff ff ff ff"/>
    <TextSample sampleTime="00:00:00.000">1</TextSample>
    <TextSample sampleTime="00:06:05.000">2</TextSample>
    <TextSample sampleTime="00:12:14.000">3</TextSample>
    <TextSample sampleTime="00:20:31.000">4</TextSample>
    <TextSample sampleTime="00:25:21.000">5</TextSample>
    <TextSample sampleTime="00:31:03.000">6</TextSample>
    <TextSample sampleTime="00:35:39.000">7</TextSample>
    <TextSample sampleTime="00:40:04.000">8</TextSample>
    <TextSample sampleTime="00:45:41.000">9</TextSample>
    <TextSample sampleTime="00:51:10.000">10</TextSample>
    <TextSample sampleTime="00:55:28.000">11</TextSample>
    <TextSample sampleTime="01:03:51.000">12</TextSample>
    <TextSample sampleTime="01:13:53.000">13</TextSample>
    <TextSample sampleTime="01:18:56.000">14</TextSample>
    <TextSample sampleTime="01:27:57.000">15</TextSample>
    <TextSample sampleTime="01:32:34.000">16</TextSample>
    <TextSample sampleTime="01:37:55.000">17</TextSample>
    <TextSample sampleTime="01:46:53.000">18</TextSample>
    <TextSample sampleTime="01:52:24.000">19</TextSample>
    <TextSample sampleTime="01:57:32.000">20</TextSample>

    Repack Extracted files into a new Container:

    MP4Box is a part of the GPAC Project on Advanced Content. GPAC is an implementation of the MPEG-4 Systems standard written in ANSI C.
    GPAC provides tools for media playback, vector graphics and 3D rendering, MPEG-4 authoring and distribution. from Wikipedia.

    MP4Box is a tool-set for handling the MP4 container format this is Command Line only by default, although various Graphical User Interface (GUI) for it do exist most are old and unsupported.


    If you want to use a GUI I suggest YAMB (Yet.Another.MP4.Box - User Interface).
    Its old but once installed you can replace the pre-installed MP4Box.exe with the latest version to ensure up to date compatibility.
    To do this replace the MP4Box.exe file in the installation folder with the current one.
    Default location for this (example): C:\Users\John\AppData\Roaming\Yamb\MP4Box.exe

    MP4Box Installation options:

    The latest version of MP4Box comes bundled as an installer as part of the GPAC framework, but you also have the option of not installing MP4Box and just browsing to the executable when you want to run it (if you unpack the .exe, or download a slightly older .zip package).

    MP4Box Command Structure (typical usage):

    MP4Box follows the typical rules for DOS commands, and Batch files can be written to make commonly used tasks available with the click of a mouse.

    1. Typically the MP4Box instruction for each file is placed at the beginning of the file
    2. For each and every file used in the command line, it starts and ends with a speech mark ""
    3. Every instruction within each speech mark for that file is separated by a colon :
    4. Each value is assigned by the equals sign =

    Command Line used by YAMB MP4 to MP4 (example):

    "C:\Users\John\AppData\Roaming\Yamb\MP4Box.exe "
    -add "C:\Users\John\Desktop\MOVIE EDIT DO NOT DEL\Paul (Unrated) [2011] (HD).m4v#1:fps=23.976"
    -add "C:\Users\John\Desktop\MOVIE EDIT DO NOT DEL\Paul (Unrated) [2011] (HD).m4v#2:lang=en" -itags tool="Yamb []"
    "C:\Users\John\Desktop\MOVIE EDIT DO NOT DEL\Paul (Unrated) [2011] (HD) New.mp4"

    In Plain English:

    Locate and use the MP4Box.exe file.
    In MP4Box locate and add the following file, select only track one from that file, and set its frame-rate to 23.976 frames per second.
    In MP4Box locate and add the following file, select only track two from that file, set it's listed language as English, add the following data to the file about it's creation.
    Create a new file in the following location with the following name from all previous files and instructions.


    This takes a video and audio track from a file and creates a new one with those, setting the frame-rate and labeling the audio track as English, then adding data about it's creation (Yamb []).

    Command Line example for adding typical HD content extracted from an MKV file (with installed GPAC Framework) in MP4Box:

    MP4Box -add "C:\Users\John\Desktop\MyMovie.h264:fps=23.976:nam e=MyMovieMP4:lang=en" -add "C\Users\John\Desktop\MyMovie.aac:lang=en:name =2 Channel Audio" "C:\Users\John\Videos\My New Movie.mp4"

    In Plain English:

    Add the H.264 video file to the AAC audio file and label both as English language, set the frame-rate to 23.976 frames per second, label the video file as "MyMovieMP4" and audio file as "2 Channel Audio". Then output these instructions as a new file with the name "My New Movie.mp4" in the Videos folder.

    Repacking a Movie example:

    Commands entered in Administrator Command Prompt (example):

    C:\Windows\system32>mp4box -add "C:\Users\John\Desktop\1.h264:fps=23.976:name= The Host:lang=en" -add "C:\Users\John\Desktop\1.aac:lang=en:name=2 Channel audio" -add "C:\Users\John\Desktop\chapters.ttxt:chap:name=Cha pters" "C:\Users\John\Desktop\The Host.mp4"

    Command Prompt Output:

    AVC-H264 import - frame size 1916 x 796 at 23.976 FPS
    AVC Import results: 180641 samples - Slices: 22064 I 715584 P 707480 B - 183081 SEI - 19520 IDR

    AAC import - sample rate 44100 - MPEG-4 audio - 2 channels

    Timed Text (GPAC TTXT) Import

    Saving to C:\Users\John\Desktop\The Host.mp4: 0.500 secs Interleaving

    Media Information on completed file (from Mediainfo Lite):

    Complete name: C:\Users\John\Desktop\The Host.mp4
    Format: MPEG-4
    Format profile: Base Media
    Codec ID: isom
    File size: 4.27 GiB
    Duration: 2h 5mn
    Overall bit rate mode: Variable
    Overall bit rate: 4 865 Kbps
    Encoded date: UTC 2013-07-07 21:18:46
    Tagged date: UTC 2013-07-07 21:18:46

    ID: 1
    Format: AVC
    Format/Info: Advanced Video Codec
    Format profile: High@L4.0
    Format settings, CABAC: Yes
    Format settings, ReFrames: 5 frames
    Codec ID: avc1
    Codec ID/Info: Advanced Video Coding
    Duration: 2h 5mn
    Bit rate: 4 712 Kbps
    Maximum bit rate: 12.5 Mbps
    Width: 1 916 pixels
    Height: 796 pixels
    Display aspect ratio: 2.40:1
    Frame rate mode: Constant
    Frame rate: 23.976 fps
    Color space: YUV
    Chroma subsampling: 4:2:0
    Bit depth: 8 bits
    Scan type: Progressive
    Bits/(Pixel*Frame): 0.129
    Stream size: 4.13 GiB (97%)
    Title: The Host
    Language: English
    Encoded date: UTC 2013-07-07 21:18:46
    Tagged date: UTC 2013-07-07 21:22:41
    Color primaries: BT.709
    Transfer characteristics: BT.709
    Matrix coefficients: BT.709

    ID: 2
    Format: AAC
    Format/Info: Advanced Audio Codec
    Format profile: LC
    Codec ID: 40
    Duration: 2h 5mn
    Bit rate mode: Variable
    Bit rate: 150 Kbps
    Maximum bit rate: 207 Kbps
    Channel(s): 2 channels
    Channel positions: Front: L R
    Sampling rate: 44.1 KHz
    Compression mode: Lossy
    Stream size: 134 MiB (3%)
    Title: 2 Channel audio
    Language: English
    Encoded date: UTC 2013-07-07 21:22:30
    Tagged date: UTC 2013-07-07 21:22:41

    ID: 3
    Format: Timed text
    Codec ID: tx3g
    Duration: 2h 2mn
    Bit rate mode: Variable
    Bit rate: 0 bps
    Stream size: 71.0 Bytes (0%)
    Title: Chapters
    Encoded date: UTC 2013-07-07 21:22:41
    Tagged date: UTC 2013-07-07 21:22:41

    (The red text above is the data put into the file by the instructions in MP4Box.)

    The M4V container format used primarily by Apple's iTunes supports the use of more Metadata than the standard MP4 extension, so you can either replace the MP4 extension with M4V when building the movie or afterwards, for compatibility with iTunes.

    Simple Batch file examples in MP4Box:

    for /r %%v in (*.mp4) do mp4box "%%v" -info >"%%v.txt"

    In English:

    for recursive variables ending with .mp4 run MP4Box.exe using the variables name, with the command -info, and output the results to a text file of the same name.

    This runs the information tool in MP4Box, listing the file properties of the selected files, which in this case would be all MP4 files in this folder and all sub-folders.

    for %%a in (*.srt) do mp4box -add "%%~Na.m4v" -add "%%a:chap:name=Chapters" "(Ch)%%~Na.m4v"

    In English:

    for all files ending in .srt do MP4Box.exe then add the M4V file with the corresponding name, next set the .srt files use to Chapters instead of the default Subtitles, label it as Chapters, and output these instructions to a new file labeled for the original but with the prefix CH.

    About Subtitles:

    MP4Box can have a problem whereby SRT format subtitles can leave the last Subtitle on the screen, to get round this add another line to the SRT file with a timecode at the end of the movie, I usually put the text "The End" for a millisecond so you don't actually see it.

    By default MP4Box creates subtitles with a font size of 18, I find this too small and I don't like the default font to much either, so I use Myriad Pro Regular, and a font size of 32 for subtitles and 40 for information such as places and dates.
    (If you want to get the font Myriad Pro Regular the easiest way is to instal Adobe Reader and browse the installation folder for the font there, then install it to the Fonts folder in Control Panel.)


    -add "C:\Users\John\Desktop\ l Subtitles:lang=en:font=Myriad Pro Regular:

    Important note about MP4Box and Metadata:

    MP4Box does not handle the extended Metadata in the M4V container format well, it can extract from these files fine straight to MP4, AVI, RAW etc, but fails to add Subtitles to films often where this extended Metadata is present. So for adding subtitles to an existing M4V file it is better to extract the file first and rebuild it with the new Subs included (remembering to add the frame rate back in if selecting the RAW option).
    Last edited by raregrit; 2nd Aug 2013 at 04:36. Reason: Tidying up and making it easier to read, some additional content too.
    Quote Quote  
  2. aBigMeanie aedipuss's Avatar
    Join Date
    Oct 2005
    666th portal
    Search Comp PM
    i guess you've never heard of or tried MkvToMp4
    "a lot of people are better dead" - prisoner KSC2-303
    Quote Quote  
  3. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Search Comp PM
    But it might be good if you want to learn how every software works and tweak every step. If not then just use mkvtomp4.
    Quote Quote  
  4. Member
    Join Date
    Jul 2013
    Search Comp PM
    I originally wrote this as an email for someone who primarily wanted to repack MKV's but also modify the MP4 container with MP4Box. I edited this a bit more and changed the title to show it's intended scope of being more a beginners guide to MP4Box.
    Last edited by raregrit; 2nd Aug 2013 at 04:19. Reason: Better explain reasons for editing main post, and more accurate response
    Quote Quote  

Similar Threads