Best A/V quality conversions from MP4 to MKV while adding subtitles

Discuss encoding for devices and presets.
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
jklmnodec
New User
Posts: 1
Joined: Thu Sep 14, 2023 10:18 pm

Best A/V quality conversions from MP4 to MKV while adding subtitles

Post by jklmnodec »

Description of question(s):
Does anybody have any advice or recommendations for my settings converting MP4s to MKVs, adding subtitles, while retaining both audio and video quality? While I am not bound sticking to my now MKV-standard, maybe I am better off simply adding subtitles to my MP4s without the MKV conversion. If so, what settings do you recommended?

Background
I have a lot of old MP4 files sans subtitles, most of which were converted in Handbrake from the raw DVD file that I ripped via Magic DVD Ripper using an older version of Handbrake's DVD preset (that is possibly since modified), see below. Now that I have learned how to add subtitles, I am trying to convert these MP4s to MKVs (since I have converted to MKV as my standard now) using a custom preset, see below, with additional modifications:
  • Filters: All options set to OFF
  • Audio 1: AAC Passthru
  • Audio 2: AC3 Passthru
  • Video: H.264 (listed here in case it is not obvious in custom preset)
  • Subtitles: Loaded a subtitle.srt file downloaded from the usual sources via MPC
HandBrake version (e.g., 1.0.0):
HandBrake 1.6.1 (2023012300)

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Microsoft Windows 10 22H2 (OS Build 19045.3448)

DVD Preset

Code: Select all

{
  "PresetList": [
    {
      "AlignAVStart": false,
      "AudioCopyMask": [
        "copy:aac",
        "copy:ac3",
        "copy:dtshd",
        "copy:dts",
        "copy:mp3",
        "copy:truehd",
        "copy:flac",
        "copy:eac3"
      ],
      "AudioEncoderFallback": "ac3",
      "AudioLanguageList": [
        "eng",
        "und"
      ],
      "AudioList": [
        {
          "AudioBitrate": 160,
          "AudioCompressionLevel": 0,
          "AudioEncoder": "av_aac",
          "AudioMixdown": "dpl2",
          "AudioNormalizeMixLevel": false,
          "AudioSamplerate": "48",
          "AudioTrackQualityEnable": false,
          "AudioTrackQuality": -1,
          "AudioTrackGainSlider": 0,
          "AudioTrackDRCSlider": 0
        },
        {
          "AudioBitrate": 224,
          "AudioCompressionLevel": 0,
          "AudioEncoder": "copy:ac3",
          "AudioMixdown": "dpl2",
          "AudioNormalizeMixLevel": false,
          "AudioSamplerate": "48",
          "AudioTrackQualityEnable": false,
          "AudioTrackQuality": -1,
          "AudioTrackGainSlider": 0,
          "AudioTrackDRCSlider": 0
        }
      ],
      "AudioSecondaryEncoderMode": true,
      "AudioTrackSelectionBehavior": "first",
      "ChapterMarkers": true,
      "ChildrenArray": [],
      "Default": true,
      "FileFormat": "av_mkv",
      "Folder": false,
      "FolderOpen": false,
      "Mp4HttpOptimize": false,
      "Mp4iPodCompatible": false,
      "PictureCropMode": 0,
      "PictureBottomCrop": 138,
      "PictureLeftCrop": 0,
      "PictureRightCrop": 0,
      "PictureTopCrop": 138,
      "PictureDARWidth": 0,
      "PictureDeblockPreset": "off",
      "PictureDeblockTune": "off",
      "PictureDeblockCustom": "strength=strong:thresh=20:blocksize=8",
      "PictureDeinterlaceFilter": "decomb",
      "PictureCombDetectPreset": "default",
      "PictureCombDetectCustom": "",
      "PictureDeinterlacePreset": "default",
      "PictureDeinterlaceCustom": "",
      "PictureDenoiseCustom": "",
      "PictureDenoiseFilter": "hqdn3d",
      "PictureDenoisePreset": "medium",
      "PictureSharpenCustom": "",
      "PictureSharpenFilter": "off",
      "PictureSharpenPreset": "medium",
      "PictureSharpenTune": "none",
      "PictureDetelecine": "off",
      "PictureDetelecineCustom": "",
      "PictureColorspacePreset": "off",
      "PictureColorspaceCustom": "",
      "PictureChromaSmoothPreset": "off",
      "PictureChromaSmoothTune": "none",
      "PictureChromaSmoothCustom": "",
      "PictureItuPAR": false,
      "PictureKeepRatio": true,
      "PicturePAR": "auto",
      "PicturePARWidth": 0,
      "PicturePARHeight": 0,
      "PictureUseMaximumSize": false,
      "PictureAllowUpscaling": false,
      "PictureForceHeight": 0,
      "PictureForceWidth": 0,
      "PicturePadMode": "none",
      "PicturePadTop": 0,
      "PicturePadBottom": 0,
      "PicturePadLeft": 0,
      "PicturePadRight": 0,
      "PicturePadColor": "black",
      "PresetDescription": "",
      "PresetName": "DVD",
      "Type": 1,
      "SubtitleAddCC": false,
      "SubtitleAddForeignAudioSearch": true,
      "SubtitleAddForeignAudioSubtitle": false,
      "SubtitleBurnBehavior": "foreign",
      "SubtitleBurnBDSub": false,
      "SubtitleBurnDVDSub": false,
      "SubtitleLanguageList": [
        "eng",
        "und"
      ],
      "SubtitleTrackSelectionBehavior": "all",
      "VideoAvgBitrate": 0,
      "VideoColorMatrixCode": 0,
      "VideoEncoder": "x264",
      "VideoFramerateMode": "cfr",
      "VideoGrayScale": false,
      "VideoScaler": "swscale",
      "VideoPreset": "veryslow",
      "VideoTune": "film",
      "VideoProfile": "high",
      "VideoLevel": "3.1",
      "VideoOptionExtra": "ref=5:bframes=5",
      "VideoQualityType": 2,
      "VideoQualitySlider": 21,
      "VideoTwoPass": true,
      "VideoTurboTwoPass": false,
      "x264UseAdvancedOptions": false,
      "PresetDisabled": false,
      "MetadataPassthrough": false
    }
  ],
  "VersionMajor": 50,
  "VersionMicro": 0,
  "VersionMinor": 0
}
Custom Preset: MP4 to MKV (subtitling)

Code: Select all

{
  "PresetList": [
    {
      "AlignAVStart": false,
      "AudioCopyMask": [
        "copy:aac",
        "copy:ac3",
        "copy:dtshd",
        "copy:dts",
        "copy:mp3",
        "copy:truehd",
        "copy:flac",
        "copy:eac3"
      ],
      "AudioEncoderFallback": "ac3",
      "AudioLanguageList": [
        "eng",
        "und"
      ],
      "AudioList": [
        {
          "AudioBitrate": 160,
          "AudioCompressionLevel": 0,
          "AudioEncoder": "av_aac",
          "AudioMixdown": "dpl2",
          "AudioNormalizeMixLevel": false,
          "AudioSamplerate": "48",
          "AudioTrackQualityEnable": false,
          "AudioTrackQuality": -1,
          "AudioTrackGainSlider": 0,
          "AudioTrackDRCSlider": 0
        },
        {
          "AudioBitrate": 224,
          "AudioCompressionLevel": 0,
          "AudioEncoder": "copy:ac3",
          "AudioMixdown": "dpl2",
          "AudioNormalizeMixLevel": false,
          "AudioSamplerate": "48",
          "AudioTrackQualityEnable": false,
          "AudioTrackQuality": -1,
          "AudioTrackGainSlider": 0,
          "AudioTrackDRCSlider": 0
        }
      ],
      "AudioSecondaryEncoderMode": true,
      "AudioTrackSelectionBehavior": "first",
      "ChapterMarkers": true,
      "ChildrenArray": [],
      "Default": false,
      "FileFormat": "av_mkv",
      "Folder": false,
      "FolderOpen": false,
      "Mp4HttpOptimize": false,
      "Mp4iPodCompatible": false,
      "PictureCropMode": 0,
      "PictureBottomCrop": 0,
      "PictureLeftCrop": 0,
      "PictureRightCrop": 0,
      "PictureTopCrop": 0,
      "PictureDARWidth": 852,
      "PictureDeblockPreset": "off",
      "PictureDeblockTune": "off",
      "PictureDeblockCustom": "strength=strong:thresh=20:blocksize=8",
      "PictureDeinterlaceFilter": "off",
      "PictureCombDetectPreset": "off",
      "PictureCombDetectCustom": "",
      "PictureDeinterlaceCustom": "",
      "PictureDenoiseCustom": "",
      "PictureDenoiseFilter": "off",
      "PictureSharpenCustom": "",
      "PictureSharpenFilter": "off",
      "PictureSharpenPreset": "medium",
      "PictureSharpenTune": "none",
      "PictureDetelecine": "off",
      "PictureDetelecineCustom": "",
      "PictureColorspacePreset": "off",
      "PictureColorspaceCustom": "",
      "PictureChromaSmoothPreset": "off",
      "PictureChromaSmoothTune": "none",
      "PictureChromaSmoothCustom": "",
      "PictureItuPAR": false,
      "PictureKeepRatio": true,
      "PicturePAR": "auto",
      "PicturePARWidth": 43139,
      "PicturePARHeight": 36450,
      "PictureUseMaximumSize": false,
      "PictureAllowUpscaling": false,
      "PictureForceHeight": 0,
      "PictureForceWidth": 0,
      "PicturePadMode": "none",
      "PicturePadTop": 0,
      "PicturePadBottom": 0,
      "PicturePadLeft": 0,
      "PicturePadRight": 0,
      "PicturePadColor": "black",
      "PresetName": "MP4 to MKV (subtitling)",
      "Type": 1,
      "SubtitleAddCC": false,
      "SubtitleAddForeignAudioSearch": true,
      "SubtitleAddForeignAudioSubtitle": false,
      "SubtitleBurnBehavior": "foreign",
      "SubtitleBurnBDSub": false,
      "SubtitleBurnDVDSub": false,
      "SubtitleLanguageList": [
        "eng",
        "und"
      ],
      "SubtitleTrackSelectionBehavior": "all",
      "VideoAvgBitrate": 0,
      "VideoColorMatrixCode": 0,
      "VideoEncoder": "x264",
      "VideoFramerateMode": "vfr",
      "VideoGrayScale": false,
      "VideoScaler": "swscale",
      "VideoPreset": "veryslow",
      "VideoTune": "film",
      "VideoProfile": "high",
      "VideoLevel": "3.1",
      "VideoOptionExtra": "ref=5:bframes=5",
      "VideoQualityType": 2,
      "VideoQualitySlider": 22,
      "VideoTwoPass": true,
      "VideoTurboTwoPass": false,
      "x264UseAdvancedOptions": false,
      "PresetDisabled": false,
      "MetadataPassthrough": false
    }
  ],
  "VersionMajor": 50,
  "VersionMicro": 0,
  "VersionMinor": 0
}
HandBrake Activity Log

Code: Select all

HandBrake 1.6.1 (2023012300)
OS: Microsoft Windows NT 10.0.19045.0
CPU: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
Ram: 16306 MB, 
GPU Information:
  Intel(R) HD Graphics 4600 - 20.19.15.5126
  NVIDIA GeForce GT 710 - 27.21.14.5671
Screen: 1920x1080
Temp Dir: ****\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake\
Data Dir: ****\AppData\Roaming\HandBrake

-------------------------------------------
[13:24:17] hb_init: starting libhb thread

 # Starting Scan ...

[13:24:17] CPU: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
[13:24:17]  - Intel microarchitecture Haswell
[13:24:17]  - logical processor count: 4
[13:24:17] Intel Quick Sync Video support: no
[13:24:17] hb_scan: path=****\Media\Movies\Catch Me If You Can.mp4, title_index=0
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:333: failed opening UDF image ****\Media\Movies\Catch Me If You Can.mp4
src/libbluray/disc/disc.c:437: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:437: error opening file BDMV\BACKUP\index.bdmv
[13:24:17] bd: not a bd - trying as a stream/file instead
libdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[13:24:17] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '****\Media\Movies\Catch Me If You Can.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2013-11-19T17:41:23.000000Z
    encoder         : HandBrake 0.9.9 2013052900
  Duration: 02:20:42.77, start: 0.000000, bitrate: 1427 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 720x482 [SAR 43139:36450 DAR 716:405], 812 kb/s, SAR 27764:23459 DAR 716:405, 23.99 fps, 59.94 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2013-11-19T17:41:23.000000Z
      vendor_id       : [0][0][0][0]
      encoder         : JVT/AVC Coding
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
    Metadata:
      creation_time   : 2013-11-19T17:41:23.000000Z
      vendor_id       : [0][0][0][0]
      title           : Stereo
  Stream #0:2[0x3](und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 448 kb/s
    Metadata:
      creation_time   : 2013-11-19T17:41:23.000000Z
      vendor_id       : [0][0][0][0]
      title           : Surround
    Side data:
      audio service type: main
[13:24:17] scan: decoding previews for title 1
[13:24:18] scan: audio 0x1: aac, rate=48000Hz, bitrate=159975 Unknown (AAC LC) (2.0 ch) (159 kbps)
[13:24:18] scan: audio 0x2: ac3, rate=48000Hz, bitrate=448000 Unknown (AC3) (5.1 ch) (448 kbps)
[13:24:18] WARNING: Video PAR 43139:36450 != container PAR 27764:23459
[13:24:18] scan: 10 previews, 720x482, 23.986 fps, autocrop = 0/0/0/0, aspect 1.77:1, PAR 43139:36450, color profile: 6-1-6, chroma location: left
[13:24:18] scan: supported video decoders: avcodec nvdec
[13:24:18] libhb: scan thread found 1 valid title(s)

 # Scan Finished ...
tlindgren
Bright Spark User
Posts: 260
Joined: Sun May 03, 2009 2:14 pm

Re: Best A/V quality conversions from MP4 to MKV while adding subtitles

Post by tlindgren »

HandBrake always re-encode the video which is what you DON'T want for this if you can avoid it, especially when the original encoding is probably fairly good - re-encoding always loose some quality.

Since MKV video/audio container is a superset of MP4 container's capabilities it's pretty much always possible to just remux a MP4 video to MKV (going the other way varies, lots of thing can't be stored in MP4 containers). Basically this consists of using a remuxer to copy the video and audio tracks (as is) from the MP4 and put them in a MKV container, you can add the subtitle track(s) from files at the same time.

The standard tool for this for MKV (and WebM) files is MKVToolNix

MKVToolNix also contains many other MKV tools, for what you're doing you may later use the MKV header editor to tweak the timing of the subtitle track (positive or negative offset) to get the subtitles to show up at the right time without having to redo the muxing process (editing headers this way is pretty close to instant regardless of video size!). Or the chapter editor to add chapters. Or...
Post Reply