MKVTOMP4(1)
Gavin Beatty
November 17, 2019



NAME


mkvtomp4.py - convert H.264 mkv files to mp4 files playable on the PS3



SYNOPSIS


_mkvtomp4.py_ OPTIONS [--] <mkvfile>

_mkvtomp4.py_ --correct-profile-only [--] <rawh264file>



DESCRIPTION


Uses existing tools to convert troublesome mkv files to mp4, that is
playable on the PS3. The conversion does not re-encode H.264 video. If
the H.264 profile level is not supported by the PS3, we rewrite just
some profile level information. The default value is 4.1, but it can be
set with --profile-level=4.0, etc. The conversion only re-encodes audio
if it doesn’t already use AAC. The resulting mp4 will be playable on the
Sony PS3, and similar devices. Tested on profile levels 3.x and 4.x,

Note that the PS4 Media Player has better support for mkv than mp4
(subtitles work only on mkv).

We depend on: _mkvtoolnix_ and GPAC’s _MP4Box_ for the conversion.
_ffmpeg_ is only required if doing audio transcoding and subtitles.



OPTIONS


-o, --output=<outfile>
    Put the completed mp4 into <outfile>.

--keep-temp-files
    Keep all temporary files created while converting.

-v, --verbose
    Print info about what is happening.

-n, --dry-run
    Don’t run any commands, but print them in a shellquoted format that
    can be safely copy-pasted by the user.

--mp4box=<mp4box>
    Use <mp4box> as the MP4Box command.

--ffmpeg=<ffmpeg>
    Use <ffmpeg> as the ffmpeg command.

--mkvinfo=<mkvinfo>
    Use <mkvinfo> as the mkvinfo command.

--mkvextract=<mkvextract>
    Use <mkvextract> as the mkvextract command.

--video-track=<video_track>
    Use <video_track> from the mkv file instead of trying to parse it.

--hint, --no-hint
    Add info to the mp4 to make it easier to stream over the network.

--audio-track=<audio_track>
    Use <audio_track> from the mkv file instead of trying to parse it.

--audio-delay-ms=<delay_ms>
    When importing the audio track, delay by <delay_ms> milliseconds.
    e.g., --audio-delay-ms=1000 delays by 1 second. Only supported by
    mp4box.

--audio-bitrate=<bitrate>
    If/When converting audio, use the given bitrate. e.g., 128.

--audio-channels=<channels>
    If/When converting audio, use <channels> channels in the output.
    e.g., 5.1.

--audio-codec=<codec>
    If/When converting audio, convert to <codec>. Default is aac. This
    should be something supported by _ffmpeg_.

--audio-lang=<language>
    The 3-letter code for the language of the audio track. Only needs to
    be set if not already specified in the source.

--subtitle-track=<subtitle_track>
    Use <subtitle_track> from the mkv file instead of trying to parse
    it.

--subtitle-lang=<language>
    The 3-letter code for the language of the subtitle track. Only needs
    to be set if not already specified in the source.

--subtitle-default, --subtitle-no-default
    Specify whether playback should use the subtitles by default.

--correct-profile-only
    Only correct the profile.

--profile-level=<profile-level>
    Use this profile if we need to rewrite the video stream’s H.264
    profile level, instead of the default, “4.1”.

--force-profile-level, --no-force-profile-level
    Rewrite the video stream’s H.264 profile level, even if the existing
    profile is less than or equal to the new value. Or not.

--stop-before-extract-video
    Exit before extracting video from <mkvfile>.

--stop-before-correct-profile
    Exit before correcting profile of raw H.264 stream.

--stop-before-extract-audio
    Exit before extracting audio from <mkvfile>.

--stop-before-convert-audio
    Exit before converting audio previously extracted. This will stop
    even if the audio does not need to be converted.

--stop-before-extract-sub
    Exit before extracting subtitles from <mkvfile>.

--stop-before-mp4
    Exit before adding audio and video to the mp4 container.

--stop-before-add-sub
    Exit before adding subtitles to the mp4.

<mkvfile>
    The Matroska (.mkv) file you wish to convert.

<rawh264file>
    The raw H.264 stream file that will have its profile corrected for
    use on the PS3.



AUTHOR


Gavin Beatty public@gavinbeatty.com



RESOURCES


Website: http://github.com/gavinbeatty/mkvtomp4/



REPORTING BUGS


Please report all bugs and wishes to public@gavinbeatty.com



COPYING


mkvtomp4 Copyright (c) 2012, 2013, 2019 Gavin Beatty,
public@gavinbeatty.com

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
