Scan and tag foreign language subtitle

Discussion of the HandBrake command line interface (CLI)
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
Orvas
Posts: 4
Joined: Sun May 01, 2016 6:03 pm

Scan and tag foreign language subtitle

Post by Orvas »

Hello everyone,

I'm using HandBrakeCLI (compiled under Linux from the GIT repository) to encode videos from MKV to MKV. For this I only want to encode the video track and just to copy all audio and subtitle tracks. This is easy with --all-audio and --all-subtitles or --audio 1,2,3,4,5 and --subtitle 1,2,3,4,5,6,7,8,9,10. OK, until this point I don't have a problem. But now I want to use the really cool automatic subtitle scan function of Handbrake for scenes with foreign language to tag this subtitle track as default and/or forced. For this I use the following syntax from the official CLIguide:

--subtitle scan,1,2,3,4,5,6,7,8,9,10 --subtitle-forced 1 --subtitle-default 1


But with these parameters Handbrake does not do what I've expected. As an example I've encoded a video with German and English audio and subtitle tracks. In the video are some Chinese dialogues. In the original MKV file four subtitle tracks exists:

1. German complete
2. German only for Chinese dialogues
3. English complete
4. English only for Chinese dialogues

The Handbrake scan function identifies the 2. subtitle correctly as the needed one. I've expected that Handbrake would only tag this track as default and forced, maybe set it as the first track or copy it as the first track and adds the original four ones subsequent. But the result is:

1. German only for Chinese dialogues (tagged as default and forced)
2. German only for Chinese dialogues (absolute identically to the first one)
3. English complete
4. English only for Chinese dialogues

As you can see I have lost the original first complete German subtitle. Maybe I don't have understood the correct use of the parameters, but I only want Handbrake to tag the scanned foreign language track but not to remove another one. How can I reach this?

Here you can find the activity log of Handbrake:

Code: Select all

# HandBrakeCLI --previews 100:0 --format mkv --encoder x264 --x264-preset ultrafast --x264-profile high --quality 20 --markers --all-audio --aencoder copy --strict-anamorphic --subtitle scan,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 --subtitle-forced 1 --subtitle-default 1 --input input.mkv --output output.mkv

[17:59:16] Preset Universal: Invalid audio encoder (aac)
[17:59:16] Preset iPod: Invalid audio encoder (aac)
[17:59:16] Preset iPhone & iPod touch: Invalid audio encoder (aac)
[17:59:16] Preset iPad: Invalid audio encoder (aac)
[17:59:16] Preset AppleTV: Invalid audio encoder (aac)
[17:59:16] Preset AppleTV 2: Invalid audio encoder (aac)
[17:59:16] Preset AppleTV 3: Invalid audio encoder (aac)
[17:59:16] Preset Android: Invalid audio encoder (aac)
[17:59:16] Preset Android Tablet: Invalid audio encoder (aac)
[17:59:16] Preset Windows Phone 8: Invalid audio encoder (aac)
[17:59:16] Preset Normal: Invalid audio encoder (aac)
[17:59:16] Preset High Profile: Invalid audio encoder (aac)
[17:59:16] hb_init: starting libhb thread
[17:59:16] thread 7f3a586df700 started ("libhb")
HandBrake 20160429203923-a1a3932-master (2016043001) - Linux x86_64 - https://handbrake.fr
8 CPUs detected
Opening input.mkv...
[17:59:16] CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
[17:59:16]  - Intel microarchitecture Skylake
[17:59:16]  - logical processor count: 8
[17:59:16] OpenCL device #1: NVIDIA Corporation GeForce GTX 460
[17:59:16]  - OpenCL version: 1.1 CUDA
[17:59:16]  - driver version: 364.19
[17:59:16]  - device type:    GPU
[17:59:16]  - supported:      no
[17:59:16] hb_scan: path=input.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:251: failed opening UDF image input.mkv
disc.c:332: error opening file BDMV/index.bdmv
disc.c:332: error opening file BDMV/BACKUP/index.bdmv
[17:59:16] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[17:59:16] dvd: not a dvd - trying as a stream/file instead

Scanning title 1 of 1, 0.00 %Input #0, matroska,webm, from 'input.mkv':
  Metadata:
    title           : Example
  Duration: 02:21:37.57, start: 0.000000, bitrate: N/A
    Chapter #0.0: start 0.000000, end 202.285417
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 202.285417, end 608.608000
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 608.608000, end 924.590333
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 924.590333, end 1105.187417
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 1105.187417, end 1294.376417
    Metadata:
      title           : Chapter 05
    Chapter #0.5: start 1294.376417, end 1468.091625
    Metadata:
      title           : Chapter 06
    Chapter #0.6: start 1468.091625, end 1732.689292
    Metadata:
      title           : Chapter 07
    Chapter #0.7: start 1732.689292, end 1896.644750
    Metadata:
      title           : Chapter 08
    Chapter #0.8: start 1896.644750, end 2061.100708
    Metadata:
      title           : Chapter 09
    Chapter #0.9: start 2061.100708, end 2353.434417
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 2353.434417, end 2481.770958
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 2481.770958, end 2783.530750
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 2783.530750, end 2965.087125
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 2965.087125, end 3375.747375
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 3375.747375, end 3580.493583
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 3580.493583, end 3743.823417
    Metadata:
      title           : Chapter 16
    Chapter #0.16: start 3743.823417, end 4013.134125
    Metadata:
      title           : Chapter 17
    Chapter #0.17: start 4013.134125, end 4192.980458
    Metadata:
      title           : Chapter 18
    Chapter #0.18: start 4192.980458, end 4431.301875
    Metadata:
      title           : Chapter 19
    Chapter #0.19: start 4431.301875, end 4718.255208
    Metadata:
      title           : Chapter 20
    Chapter #0.20: start 4718.255208, end 4972.467500
    Metadata:
      title           : Chapter 21
    Chapter #0.21: start 4972.467500, end 5441.269167
    Metadata:
      title           : Chapter 22
    Chapter #0.22: start 5441.269167, end 5850.094250
    Metadata:
      title           : Chapter 23
    Chapter #0.23: start 5850.094250, end 6211.997458
    Metadata:
      title           : Chapter 24
    Chapter #0.24: start 6211.997458, end 6376.286583
    Metadata:
      title           : Chapter 25
    Chapter #0.25: start 6376.286583, end 6618.737125
    Metadata:
      title           : Chapter 26
    Chapter #0.26: start 6618.737125, end 6847.966125
    Metadata:
      title           : Chapter 27
    Chapter #0.27: start 6847.966125, end 7069.312250
    Metadata:
      title           : Chapter 28
    Chapter #0.28: start 7069.312250, end 7481.682542
    Metadata:
      title           : Chapter 29
    Chapter #0.29: start 7481.682542, end 7865.732875
    Metadata:
      title           : Chapter 30
    Chapter #0.30: start 7865.732875, end 8008.792458
    Metadata:
      title           : Chapter 31
    Chapter #0.31: start 8008.792458, end 8497.572417
    Metadata:
      title           : Chapter 32
    Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 23.98 fps, 1k tbn, 47.95 tbc
    Metadata:
      BPS-eng         : 26800140
      DURATION-eng    : 02:21:37.572416666
      NUMBER_OF_FRAMES-eng: 203738
      NUMBER_OF_BYTES-eng: 28467014912
      SOURCE_ID-eng   : 001011
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.1(deu): Audio: dca (DTS), 48000 Hz, 5.1, fltp, 768 kb/s (default)
    Metadata:
      title           : Surround 5.1
      BPS-eng         : 768000
      DURATION-eng    : 02:21:37.578666666
      NUMBER_OF_FRAMES-eng: 796648
      NUMBER_OF_BYTES-eng: 815767552
      SOURCE_ID-eng   : 001101
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.2(eng): Audio: dca (DTS), 48000 Hz, 5.1, fltp, 1536 kb/s
    Metadata:
      title           : Surround 5.1
      BPS-eng         : 1509000
      DURATION-eng    : 02:21:37.578666666
      NUMBER_OF_FRAMES-eng: 796648
      NUMBER_OF_BYTES-eng: 1602855776
      SOURCE_ID-eng   : 001100
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.3(deu): Subtitle: pgssub
    Metadata:
      BPS-eng         : 35095
      DURATION-eng    : 02:20:15.636395833
      NUMBER_OF_FRAMES-eng: 3402
      NUMBER_OF_BYTES-eng: 36919198
      SOURCE_ID-eng   : 001203
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.4(deu): Subtitle: pgssub (default)
    Metadata:
      BPS-eng         : 825
      DURATION-eng    : 01:24:34.506937500
      NUMBER_OF_FRAMES-eng: 38
      NUMBER_OF_BYTES-eng: 523476
      SOURCE_ID-eng   : 001203
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.5(eng): Subtitle: pgssub
    Metadata:
      BPS-eng         : 35724
      DURATION-eng    : 02:13:12.088270833
      NUMBER_OF_FRAMES-eng: 3234
      NUMBER_OF_BYTES-eng: 35689592
      SOURCE_ID-eng   : 001200
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.6(eng): Subtitle: pgssub
    Metadata:
      BPS-eng         : 58861
      DURATION-eng    : 00:00:47.693479166
      NUMBER_OF_FRAMES-eng: 24
      NUMBER_OF_BYTES-eng: 350909
      SOURCE_ID-eng   : 001212
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0.7(eng): Subtitle: pgssub
    Metadata:
      BPS-eng         : 58861
      DURATION-eng    : 00:00:47.693479166
      NUMBER_OF_FRAMES-eng: 24
      NUMBER_OF_BYTES-eng: 350909
      SOURCE_ID-eng   : 001212
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.9.9 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-18 12:41:41
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
[17:59:16] scan: decoding previews for title 1
[17:59:16] scan: audio 0x1: dca, rate=48000Hz, bitrate=768000 Deutsch (DTS) (5.1 ch)
[17:59:16] scan: audio 0x2: dca, rate=48000Hz, bitrate=1536000 English (DTS) (5.1 ch)

Scanning title 1 of 1, preview 2, 2.00 %
Scanning title 1 of 1, preview 5, 5.00 %
Scanning title 1 of 1, preview 8, 8.00 %
Scanning title 1 of 1, preview 10, 10.00 %
Scanning title 1 of 1, preview 12, 12.00 %
Scanning title 1 of 1, preview 14, 14.00 %
Scanning title 1 of 1, preview 16, 16.00 %
Scanning title 1 of 1, preview 18, 18.00 %
Scanning title 1 of 1, preview 21, 21.00 %
Scanning title 1 of 1, preview 23, 23.00 %
Scanning title 1 of 1, preview 25, 25.00 %
Scanning title 1 of 1, preview 27, 27.00 %
Scanning title 1 of 1, preview 29, 29.00 %
Scanning title 1 of 1, preview 31, 31.00 %
Scanning title 1 of 1, preview 34, 34.00 %
Scanning title 1 of 1, preview 36, 36.00 %
Scanning title 1 of 1, preview 38, 38.00 %
Scanning title 1 of 1, preview 40, 40.00 %
Scanning title 1 of 1, preview 42, 42.00 %
Scanning title 1 of 1, preview 44, 44.00 %
Scanning title 1 of 1, preview 47, 47.00 %
Scanning title 1 of 1, preview 49, 49.00 %
Scanning title 1 of 1, preview 51, 51.00 %
Scanning title 1 of 1, preview 54, 54.00 %
Scanning title 1 of 1, preview 56, 56.00 %
Scanning title 1 of 1, preview 58, 58.00 %
Scanning title 1 of 1, preview 60, 60.00 %
Scanning title 1 of 1, preview 62, 62.00 %
Scanning title 1 of 1, preview 65, 65.00 %
Scanning title 1 of 1, preview 67, 67.00 %
Scanning title 1 of 1, preview 70, 70.00 %
Scanning title 1 of 1, preview 72, 72.00 %
Scanning title 1 of 1, preview 73, 73.00 %
Scanning title 1 of 1, preview 75, 75.00 %
Scanning title 1 of 1, preview 77, 77.00 %
Scanning title 1 of 1, preview 80, 80.00 %
Scanning title 1 of 1, preview 82, 82.00 %
Scanning title 1 of 1, preview 84, 84.00 %
Scanning title 1 of 1, preview 87, 87.00 %
Scanning title 1 of 1, preview 89, 89.00 %
Scanning title 1 of 1, preview 91, 91.00 %
Scanning title 1 of 1, preview 93, 93.00 %
Scanning title 1 of 1, preview 95, 95.00 %
Scanning title 1 of 1, preview 97, 97.00 %
Scanning title 1 of 1, preview 99, 99.00 %[17:59:30] scan: 100 previews, 1920x1080, 23.976 fps, autocrop = 140/140/0/0, aspect 16:9, PAR 1:1
[17:59:30] libhb: scan thread found 1 valid title(s)
+ Using preset: Normal
+ title 1:
  + stream: input.mkv
  + duration: 02:21:37
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 140/140/0/0
  + support opencl: no
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:03:22
    + 2: cells 0->0, 0 blocks, duration 00:06:46
    + 3: cells 0->0, 0 blocks, duration 00:05:16
    + 4: cells 0->0, 0 blocks, duration 00:03:01
    + 5: cells 0->0, 0 blocks, duration 00:03:09
    + 6: cells 0->0, 0 blocks, duration 00:02:54
    + 7: cells 0->0, 0 blocks, duration 00:04:25
    + 8: cells 0->0, 0 blocks, duration 00:02:44
    + 9: cells 0->0, 0 blocks, duration 00:02:44
    + 10: cells 0->0, 0 blocks, duration 00:04:52
    + 11: cells 0->0, 0 blocks, duration 00:02:08
    + 12: cells 0->0, 0 blocks, duration 00:05:02
    + 13: cells 0->0, 0 blocks, duration 00:03:02
    + 14: cells 0->0, 0 blocks, duration 00:06:51
    + 15: cells 0->0, 0 blocks, duration 00:03:25
    + 16: cells 0->0, 0 blocks, duration 00:02:43
    + 17: cells 0->0, 0 blocks, duration 00:04:29
    + 18: cells 0->0, 0 blocks, duration 00:03:00
    + 19: cells 0->0, 0 blocks, duration 00:03:58
    + 20: cells 0->0, 0 blocks, duration 00:04:47
    + 21: cells 0->0, 0 blocks, duration 00:04:14
    + 22: cells 0->0, 0 blocks, duration 00:07:49
    + 23: cells 0->0, 0 blocks, duration 00:06:49
    + 24: cells 0->0, 0 blocks, duration 00:06:02
    + 25: cells 0->0, 0 blocks, duration 00:02:44
    + 26: cells 0->0, 0 blocks, duration 00:04:02
    + 27: cells 0->0, 0 blocks, duration 00:03:49
    + 28: cells 0->0, 0 blocks, duration 00:03:41
    + 29: cells 0->0, 0 blocks, duration 00:06:52
    + 30: cells 0->0, 0 blocks, duration 00:06:24
    + 31: cells 0->0, 0 blocks, duration 00:02:23
    + 32: cells 0->0, 0 blocks, duration 00:08:09
  + audio tracks:
    + 1, Deutsch (DTS) (5.1 ch) (iso639-2: deu), 48000Hz, 768000bps
    + 2, English (DTS) (5.1 ch) (iso639-2: eng), 48000Hz, 1536000bps
  + subtitle tracks:
    + 1, German (iso639-2: deu) (Bitmap)(PGS)
    + 2, German (iso639-2: deu) (Bitmap)(PGS)
    + 3, English (iso639-2: eng) (Bitmap)(PGS)
    + 4, English (iso639-2: eng) (Bitmap)(PGS)
    + 5, English (iso639-2: eng) (Bitmap)(PGS)
Warning: Could not find subtitle track 6, skipped
Warning: Could not find subtitle track 7, skipped
Warning: Could not find subtitle track 8, skipped
Warning: Could not find subtitle track 9, skipped
Warning: Could not find subtitle track 10, skipped
Warning: Could not find subtitle track 11, skipped
Warning: Could not find subtitle track 12, skipped
Warning: Could not find subtitle track 13, skipped
Warning: Could not find subtitle track 14, skipped
Warning: Could not find subtitle track 15, skipped
[17:59:30] 1 job(s) to process
[17:59:30] json job:
{
    "Audio": {
        "AudioList": [
            {
                "Encoder": "copy:dts",
                "PresetEncoder": "copy",
                "Track": 0
            },
            {
                "Encoder": "copy:dts",
                "PresetEncoder": "copy",
                "Track": 1
            }
        ],
        "CopyMask": [
            "copy:aac",
            "copy:ac3",
            "copy:dts",
            "copy:dtshd",
            "copy:eac3",
            "copy:flac",
            "copy:mp3",
            "copy:truehd"
        ],
        "FallbackEncoder": "ac3"
    },
    "Destination": {
        "ChapterList": [
            {
                "Name": "Chapter 1"
            },
            {
                "Name": "Chapter 2"
            },
            {
                "Name": "Chapter 3"
            },
            {
                "Name": "Chapter 4"
            },
            {
                "Name": "Chapter 5"
            },
            {
                "Name": "Chapter 6"
            },
            {
                "Name": "Chapter 7"
            },
            {
                "Name": "Chapter 8"
            },
            {
                "Name": "Chapter 9"
            },
            {
                "Name": "Chapter 10"
            },
            {
                "Name": "Chapter 11"
            },
            {
                "Name": "Chapter 12"
            },
            {
                "Name": "Chapter 13"
            },
            {
                "Name": "Chapter 14"
            },
            {
                "Name": "Chapter 15"
            },
            {
                "Name": "Chapter 16"
            },
            {
                "Name": "Chapter 17"
            },
            {
                "Name": "Chapter 18"
            },
            {
                "Name": "Chapter 19"
            },
            {
                "Name": "Chapter 20"
            },
            {
                "Name": "Chapter 21"
            },
            {
                "Name": "Chapter 22"
            },
            {
                "Name": "Chapter 23"
            },
            {
                "Name": "Chapter 24"
            },
            {
                "Name": "Chapter 25"
            },
            {
                "Name": "Chapter 26"
            },
            {
                "Name": "Chapter 27"
            },
            {
                "Name": "Chapter 28"
            },
            {
                "Name": "Chapter 29"
            },
            {
                "Name": "Chapter 30"
            },
            {
                "Name": "Chapter 31"
            },
            {
                "Name": "Chapter 32"
            }
        ],
        "ChapterMarkers": true,
        "File": "output.mkv",
        "Mp4Options": {
            "IpodAtom": false,
            "Mp4Optimize": false
        },
        "Mux": "mkv"
    },
    "Filters": {
        "FilterList": [
            {
                "ID": 6,
                "Settings": {
                    "mode": 0
                }
            },
            {
                "ID": 11,
                "Settings": {
                    "crop-bottom": 140,
                    "crop-left": 0,
                    "crop-right": 0,
                    "crop-top": 140,
                    "height": 800,
                    "width": 1920
                }
            }
        ]
    },
    "Metadata": {
        "Name": "Example"
    },
    "PAR": {
        "Den": 1,
        "Num": 1
    },
    "SequenceID": 0,
    "Source": {
        "Angle": 0,
        "Path": "input.mkv",
        "Range": {
            "End": 32,
            "Start": 1,
            "Type": "chapter"
        },
        "Title": 1
    },
    "Subtitle": {
        "Search": {
            "Burn": false,
            "Default": true,
            "Enable": true,
            "Forced": true
        },
        "SubtitleList": [
            {
                "Burn": false,
                "Default": true,
                "Forced": true,
                "Track": 0
            },
            {
                "Burn": false,
                "Default": false,
                "Forced": false,
                "Track": 1
            },
            {
                "Burn": false,
                "Default": false,
                "Forced": false,
                "Track": 2
            },
            {
                "Burn": false,
                "Default": false,
                "Forced": false,
                "Track": 3
            },
            {
                "Burn": false,
                "Default": false,
                "Forced": false,
                "Track": 4
            }
        ]
    },
    "Video": {
        "ColorMatrixCode": 0,
        "Encoder": "x264",
        "HWDecode": false,
        "Level": "4.0",
        "OpenCL": false,
        "Options": "",
        "Preset": "ultrafast",
        "Profile": "high",
        "QSV": {
            "AsyncDepth": 4,
            "Decode": false
        },
        "Quality": 20.0,
        "Tune": "",
        "Turbo": false,
        "TwoPass": false
    }
}
[17:59:30] starting job
[17:59:30] job configuration:
[17:59:30]  * source
[17:59:30]    + input.mkv
[17:59:30]    + title 1, chapter(s) 1 to 32
[17:59:30]    + container: matroska,webm
[17:59:30]  * destination
[17:59:30]    + output.mkv
[17:59:30]    + container: Matroska (libavformat)
[17:59:30]      + chapter markers
[17:59:30]  * video track
[17:59:30]    + decoder: h264
[17:59:30]    + filters
[17:59:30]      + Framerate Shaper (mode=0)
[17:59:30]        + frame rate: same as source (around 23.976 fps)
[17:59:30]      + Crop and Scale (width=1920:height=800:crop-top=140:crop-bottom=140:crop-left=0:crop-right=0)
[17:59:30]        + source: 1920 * 1080, crop (140/140/0/0): 1920 * 800, scale: 1920 * 800
[17:59:30]    + Output geometry
[17:59:30]      + storage dimensions: 1920 x 800
[17:59:30]      + pixel aspect ratio: 1 : 1
[17:59:30]      + display dimensions: 1920 x 800
[17:59:30]  * Foreign Audio Search: Passthrough, Forced Only, Default
[17:59:30]    + subtitle, German (track 3, id 0x3) Picture [PGS]
[17:59:30]    + subtitle, German (track 4, id 0x4) Picture [PGS]
[17:59:30] sync: expecting 203737 video frames
[18:03:59] reader: done. 1 scr changes
[18:03:59] work: average encoding speed for job is 0.000000 fps
[18:03:59] render: lost time: 0 (0 frames)
[18:03:59] render: gained time: 0 (0 frames) (0 not accounted for)
[18:03:59] h264-decoder done: 0 frames, 0 decoder errors, 0 drops
[18:03:59] sync: got 0 frames, 203737 expected
[18:03:59] Subtitle track 3 (id 0x3) 'German': 1701 hits (19 forced)
[18:03:59] Subtitle track 4 (id 0x4) 'German': 19 hits (19 forced)
[18:03:59] Found a subtitle candidate with id 0x3 (contains forced subs)
[18:03:59] starting job
[18:03:59] job configuration:
[18:03:59]  * source
[18:03:59]    + input.mkv
[18:03:59]    + title 1, chapter(s) 1 to 32
[18:03:59]    + container: matroska,webm
[18:03:59]  * destination
[18:03:59]    + output.mkv
[18:03:59]    + container: Matroska (libavformat)
[18:03:59]      + chapter markers
[18:03:59]  * video track
[18:03:59]    + decoder: h264
[18:03:59]    + filters
[18:03:59]      + Framerate Shaper (mode=0)
[18:03:59]        + frame rate: same as source (around 23.976 fps)
[18:03:59]      + Crop and Scale (width=1920:height=800:crop-top=140:crop-bottom=140:crop-left=0:crop-right=0)
[18:03:59]        + source: 1920 * 1080, crop (140/140/0/0): 1920 * 800, scale: 1920 * 800
[18:03:59]    + Output geometry
[18:03:59]      + storage dimensions: 1920 x 800
[18:03:59]      + pixel aspect ratio: 1 : 1
[18:03:59]      + display dimensions: 1920 x 800
[18:03:59]    + encoder: H.264 (libx264)
[18:03:59]      + preset:  ultrafast
[18:03:59]      + profile: high
[18:03:59]      + level:   4.0
[18:03:59]      + quality: 20.00 (RF)
[18:03:59]  * subtitle track 1, German (track 3, id 0x3) Picture [PGS] -> Passthrough, Forced Only, Default
[18:03:59]  * subtitle track 2, German (track 1, id 0x4) Picture [PGS] -> Passthrough
[18:03:59]  * subtitle track 3, English (track 2, id 0x5) Picture [PGS] -> Passthrough
[18:03:59]  * subtitle track 4, English (track 3, id 0x6) Picture [PGS] -> Passthrough
[18:03:59]  * subtitle track 5, English (track 4, id 0x7) Picture [PGS] -> Passthrough
[18:03:59]  * audio track 1
[18:03:59]    + decoder: Deutsch (DTS) (5.1 ch) (track 1, id 0x1)
[18:03:59]      + bitrate: 768 kbps, samplerate: 48000 Hz
[18:03:59]    + DTS Passthru
[18:03:59]  * audio track 2
[18:03:59]    + decoder: English (DTS) (5.1 ch) (track 2, id 0x2)
[18:03:59]      + bitrate: 1536 kbps, samplerate: 48000 Hz
[18:03:59]    + DTS Passthru
[18:03:59] sync: expecting 203737 video frames
[18:03:59] encx264: min-keyint: 24, keyint: 240
[18:03:59] encx264: encoding at constant RF 20.000000
[18:03:59] encx264: unparsed options: scenecut=0:level=4.0:ref=1:bframes=0:no-deblock=1:weightp=0:analyse=none:cabac=0:8x8dct=0:me=dia:trellis=0:subme=0:mixed-refs=0:vbv-bufsize=25000:vbv-maxrate=20000:aq-mode=0:rc-lookahead=0:mbtree=0
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x264 [info]: profile Constrained Baseline, level 4.0
[18:03:59] reader: first SCR 0 id 0x0 DTS 0
[18:03:59] sync: first pts audio 0x1 is 0
[18:03:59] sync: first pts audio 0x2 is 0
[18:03:59] sync: first pts video is 0
[18:04:11] sync: first pts subtitle 0x5 is 11321280
[18:04:20] h264: "Chapter 2" (2) at frame 4859 time 18209430
[18:05:11] h264: "Chapter 3" (3) at frame 14600 time 54774720
[18:05:56] h264: "Chapter 4" (4) at frame 22178 time 83220660
[18:06:15] h264: "Chapter 5" (5) at frame 26508 time 99474390
[18:06:41] h264: "Chapter 6" (6) at frame 31045 time 116505180
[18:07:05] h264: "Chapter 7" (7) at frame 35207 time 132128280
[18:07:38] h264: "Chapter 8" (8) at frame 41553 time 155949570
[18:07:55] h264: "Chapter 9" (9) at frame 45482 time 170698050
[18:08:16] h264: "Chapter 10" (10) at frame 49425 time 185499090
[18:08:51] h264: "Chapter 11" (11) at frame 56436 time 211816620
[18:09:08] h264: "Chapter 12" (12) at frame 59511 time 223359390
[18:09:47] h264: "Chapter 13" (13) at frame 66746 time 250517790
[18:10:08] h264: "Chapter 14" (14) at frame 71100 time 266861610
[18:10:59] h264: "Chapter 15" (15) at frame 80947 time 303824790
[18:11:03] sync: first pts subtitle 0x3 is 306899100
[18:11:03] sync: first pts subtitle 0x4 is 306899100
[18:11:21] h264: "Chapter 16" (16) at frame 85854 time 322244460
[18:11:43] h264: "Chapter 17" (17) at frame 89772 time 336951630
[18:12:15] h264: "Chapter 18" (18) at frame 96229 time 361189620
[18:12:33] h264: "Chapter 19" (19) at frame 100541 time 377375760
[18:13:03] h264: "Chapter 20" (20) at frame 106253 time 398817180
[18:13:39] h264: "Chapter 21" (21) at frame 113134 time 424646730
[18:13:51] sync: first pts subtitle 0x6 is 435772800
[18:13:51] sync: first pts subtitle 0x7 is 435772800
[18:14:08] h264: "Chapter 22" (22) at frame 119228 time 447522120
[18:15:04] h264: "Chapter 23" (23) at frame 130470 time 489721770
[18:15:56] h264: "Chapter 24" (24) at frame 140272 time 526516020
[18:16:41] h264: "Chapter 25" (25) at frame 148949 time 559087290
[18:17:02] h264: "Chapter 26" (26) at frame 152886 time 573865830
[18:17:32] h264: "Chapter 27" (27) at frame 158702 time 595697580
[18:17:58] h264: "Chapter 28" (28) at frame 164197 time 616324500
[18:18:26] h264: "Chapter 29" (29) at frame 169505 time 636249330
[18:19:19] h264: "Chapter 30" (30) at frame 179389 time 673351470
[18:20:09] h264: "Chapter 31" (31) at frame 188597 time 707915970
[18:20:24] h264: "Chapter 32" (32) at frame 192029 time 720798840
[18:21:14] reader: done. 1 scr changes
[18:21:14] work: average encoding speed for job is 196.702469 fps
[18:21:15] render: lost time: 0 (0 frames)
[18:21:15] render: gained time: 0 (0 frames) (0 not accounted for)
[18:21:15] dca-decoder done: 796648 frames, 0 decoder errors, 0 drops
[18:21:15] dca-decoder done: 796648 frames, 0 decoder errors, 0 drops
[18:21:15] h264-decoder done: 203738 frames, 0 decoder errors, 0 drops
[18:21:15] sync: got 203737 frames, 203737 expected
[18:21:15] sync: framerate min 23.810 fps, max 24.390 fps, avg 23.976 fps
x264 [info]: frame I:866   Avg QP:16.26  size:209315
x264 [info]: frame P:202871 Avg QP:19.09  size: 51318
x264 [info]: mb I  I16..4: 100.0%  0.0%  0.0%
x264 [info]: mb P  I16..4: 12.3%  0.0%  0.0%  P16..4: 55.2%  0.0%  0.0%  0.0%  0.0%    skip:32.5%
x264 [info]: coded y,uvDC,uvAC intra: 51.6% 50.8% 23.3% inter: 33.6% 27.4% 3.4%
x264 [info]: i16 v,h,dc,p: 34% 23% 29% 13%
x264 [info]: i8c dc,h,v,p: 53% 21% 22%  5%
x264 [info]: kb/s:9972.00
[18:21:19] mux: track 0, 203737 frames, 10592143766 bytes, 9971.88 kbps, fifo 512
[18:21:19] mux: track 1, 796648 frames, 815767552 bytes, 768.00 kbps, fifo 2048
[18:21:19] mux: track 2, 796648 frames, 1602855776 bytes, 1508.99 kbps, fifo 2048
[18:21:19] mux: track 3, 38 frames, 523476 bytes, 0.49 kbps, fifo 16
[18:21:19] mux: track 4, 38 frames, 523476 bytes, 0.49 kbps, fifo 16
[18:21:19] mux: track 5, 3234 frames, 35689592 bytes, 33.60 kbps, fifo 32
[18:21:19] mux: track 6, 24 frames, 350909 bytes, 0.33 kbps, fifo 16
[18:21:19] mux: track 7, 24 frames, 350909 bytes, 0.33 kbps, fifo 16
[18:21:19] libhb: work result = 0

Encode done!
HandBrake has exited.
Thank you in advance for your help!
Orvas
Last edited by Orvas on Sun May 22, 2016 4:24 pm, edited 2 times in total.
mduell
Veteran User
Posts: 8202
Joined: Sat Apr 21, 2007 8:54 pm

Re: Scan and tag foreign language subtitle

Post by mduell »

Forum rules
Activity Log is required for support requests. See Must Read: How To Get Questions Answered on These Forums for details

Guess you missed that?
Orvas
Posts: 4
Joined: Sun May 01, 2016 6:03 pm

Re: Scan and tag foreign language subtitle

Post by Orvas »

Thanks for the advice, I have added the activity log in my first post.
Orvas
Posts: 4
Joined: Sun May 01, 2016 6:03 pm

Re: Scan and tag foreign language subtitle

Post by Orvas »

Has nobody an idea about this issue? I thought the automatic subtitle scan is an often used standard function, but above all it is an important and very useful feature (not only) for me. I would be happy if anyone could give me a hint about my problem!

Thanks
Orvas
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Scan and tag foreign language subtitle

Post by JohnAStebbins »

Your subtitle tracks are somewhat unusual. The first German track is complete German subtitles *and* it flags the subtitles for the Chinese audio as forced (there are 19 of these). The second German track only includes the subtitles for the Chinese audio and it flags them all as forced (also 19 of them). The "scan" option is picking the first subtitle track it finds with forced subtitles, which happens to be the track that is also complete German subtitles. It uses this subtitle track and filters out only the 19 forced subtitles from this track. Then it adds the other remaining tracks. Not ideal behavior, but it's hard to cover all the possibilities in a general way.

I think you'll get better behaviour in this case if you *do not* specify --subtitle-forced. HandBrake will use a different algorithm that ignores the "forced" flags in the subtitles to find a subtitle track for foreign audio. This algorithm only works when there is a subtitle track that *only* contains subtitles for the foreign audio (thus the reason we also provide the --subtitle-forced option). In this case, it should find the second track which is composed of only the subtitles for the Chinese audio.
Deleted User 11865

Re: Scan and tag foreign language subtitle

Post by Deleted User 11865 »

Looks like a possible libhb bug to me. There are two German tracks in the input:

Code: Select all

[18:03:59] Subtitle track 3 (id 0x3) 'German': 1701 hits (19 forced)
[18:03:59] Subtitle track 4 (id 0x4) 'German': 19 hits (19 forced)
[18:03:59] Found a subtitle candidate with id 0x3 (contains forced subs)
Foreign Audio Search automatically prepends track 3 + forced-only to the final list; it also removes any duplicate from the list, but the first non-scan track should NOT be dropped, since it doesn't have forced-only set (and is therefore different from the track inserted by Foreign Audio Search).

I remember fixing a similar bug years ago (where FAS would drop a track even though the forced only flag didn't match between the FAS-inserted track and the so-called duplicate), maybe a change made since then caused a regression.

I don't have time to look into it, however.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Scan and tag foreign language subtitle

Post by JohnAStebbins »

Rodeo wrote:I don't have time to look into it, however.
I'll look into in the near future.
Orvas
Posts: 4
Joined: Sun May 01, 2016 6:03 pm

Re: Scan and tag foreign language subtitle

Post by Orvas »

Thank you very much for the detailed answers. In the meanwhile I have run some more tests and I have to say I am really confused now. Before I started to use Handbrake and naturally before I asked for help I have studied the CLIGuide of Handbrake and it says the following about the two parameters --subtitle-forced and --subtitle-default:
-F or --subtitle-forced: only subtitles that have the forced flag set will be displayed for the selected subtitle tracks. Multiple subtitles tracks are separated by commas. Works with DVD VobSub? subtitles from DVD, MKV and MP4 sources. The values are indexes into the subtitle list defined via --subtitle, so --subtitle scan,3,2,1 --subtitle-forced 2,4 will set the forced option for the source subtitle tracks 3 and 1.

--subtitle-default: flag the selected subtitle as the default subtitle to be displayed during playback. The values is an index into the subtitle list defined via --subtitle, so --subtitle scan,3,2,1 --subtitle-default 1 will display the foreign audio segment track ('scan') by default.

https://trac.handbrake.fr/wiki/CLIGuide
For my understanding both parameters are only setting the corresponding force flag or default flag for an subtitle track inside the output MKV but do not effect which tracks will be in the output. The guide says nothing about an impact on the scan algorithm, but this impact is clearly there, as JohnAStebbins already said. When I encode the MKV file from my first post without the --subtitle-forced option but with the --subtitle-default option, Handbrake recognized the correct foreign language subtitle track and put it on the first position, followed by the other subtitles. The curious thing: Handbrake then sets the first (scanned foreign) subtitle only to forced but the second full german subtitle to forced and default.

But when I encode the MKV without --subtitle-forced and without --subtitle-default everything is as I want it! Handbrake recognizes the correct foreign language subtitle, copies it on the first position and marks it as default and as forced. The other tracks are copied afterwards and none of them is tagged as forced or default. But exactly this behaviour I have expected with (and not without) the parameters --subtitle-default 1 and --subtitle-forced 1.

Am I to stupid to understand the official CLIGuide of Handbrake or does the current version behaves not as described there?

Thanks and regards,
Orvas
Post Reply