1

I'm struggling with this specific example of encoding an mkv into h264. 0:0 is video; 0:1 is audio(eng) and 0:9 is eng subtitles that only occur whenever japanese is spoken. I want to encode video into h264, copy audio and hardcode the subtitles into the video track. Problem is: 0:9 seems to be damaged:

Could not find codec parameters for stream 9 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options

Here is what I've came up with so far:

ffmpeg -i .\sample.mkv -map 0:0 -map 0:1 -map 0:9 -vcodec h264 -c:s mov_text sample.mp4 -analyzeduration 2147483647 -probesize 2147483647

And this is the result:

Error while opening encoder for output stream #0:2 - maybe incorrect parameters
such as bit_rate, rate, width or height

Here is the sample I am trying to process...

(Note that the subtitles are not present in the sample since its only english monologue)

Interestingly when I input the entire movie, ffmpeg complains not only about stream 9, but about all the other subtitle streams 3-8 as well. But this time it actually gives me Metadata for stream 9:

   Stream #0:9(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 3100
      DURATION-eng    : 02:19:46.378000000
      NUMBER_OF_FRAMES-eng: 390
      NUMBER_OF_BYTES-eng: 3250745
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES

Which could be because stream 9 technically doesn't contain anything during just the sample.

Maybe someone knows a thing or two; Thanks Edit: Full meta-data Sample:

[matroska,webm @ 0000021abd9fa540] Could not find codec parameters for stream 9 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from '.\sample.mkv':
  Metadata:
    encoder         : libebml v1.3.6 + libmatroska v1.4.9
    creation_time   : 2018-05-20T14:02:19.000000Z
    Writing frontend: StaxRip v1.7.0.0
  Duration: 00:00:27.58, start: 0.000000, bitrate: 14690 kb/s
    Chapter #0:0: start 0.000000, end 27.584000
    Metadata:
      title           : 00:09:58.389
    Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x792, SAR 1:1 DAR 80:33, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      BPS-eng         : 12393305
      DURATION-eng    : 00:00:27.569000000
      NUMBER_OF_FRAMES-eng: 661
      NUMBER_OF_BYTES-eng: 42708880
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: truehd, 48000 Hz, 5.1(side), s32 (24 bit) (default)
    Metadata:
      BPS-eng         : 1471625
      DURATION-eng    : 00:00:27.570000000
      NUMBER_OF_FRAMES-eng: 33083
      NUMBER_OF_BYTES-eng: 5071590
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:00:27.584000000
      NUMBER_OF_FRAMES-eng: 862
      NUMBER_OF_BYTES-eng: 2206720
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle, 1920x1080 (default)
    Metadata:
      BPS-eng         : 58340
      DURATION-eng    : 00:00:24.817000000
      NUMBER_OF_FRAMES-eng: 11
      NUMBER_OF_BYTES-eng: 180978
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:4(chi): Subtitle: hdmv_pgs_subtitle, 1920x1080
    Metadata:
      BPS-eng         : 35267
      DURATION-eng    : 00:00:24.817000000
      NUMBER_OF_FRAMES-eng: 11
      NUMBER_OF_BYTES-eng: 109405
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:5(kor): Subtitle: hdmv_pgs_subtitle, 1920x1080
    Metadata:
      BPS-eng         : 29740
      DURATION-eng    : 00:00:24.817000000
      NUMBER_OF_FRAMES-eng: 11
      NUMBER_OF_BYTES-eng: 92258
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:6(por): Subtitle: hdmv_pgs_subtitle, 1920x1080
    Metadata:
      BPS-eng         : 54521
      DURATION-eng    : 00:00:24.817000000
      NUMBER_OF_FRAMES-eng: 11
      NUMBER_OF_BYTES-eng: 169131
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:7(ara): Subtitle: hdmv_pgs_subtitle, 1920x1080
    Metadata:
      BPS-eng         : 26955
      DURATION-eng    : 00:00:24.817000000
      NUMBER_OF_FRAMES-eng: 11
      NUMBER_OF_BYTES-eng: 83618
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:8(ind): Subtitle: hdmv_pgs_subtitle, 1920x1080
    Metadata:
      BPS-eng         : 53892
      DURATION-eng    : 00:00:24.817000000
      NUMBER_OF_FRAMES-eng: 11
      NUMBER_OF_BYTES-eng: 167182
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:9(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 0
      DURATION-eng    : 00:00:00.000000000
      NUMBER_OF_FRAMES-eng: 0
      NUMBER_OF_BYTES-eng: 0
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:02:19
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES

Full video:

[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 3 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 4 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 5 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 6 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 7 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 8 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 000002116b3fa600] Could not find codec parameters for stream 9 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from '.\The_last_Samurai.mkv':
  Metadata:
    encoder         : libebml v1.3.6 + libmatroska v1.4.9
    creation_time   : 2018-05-20T14:00:32.000000Z
    Writing frontend: StaxRip v1.7.0.0
  Duration: 02:34:11.23, start: 0.000000, bitrate: 12111 kb/s
    Chapter #0:0: start 0.000000, end 112.070000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 112.070000, end 338.630000
    Metadata:
      title           : 00:01:52.070
    Chapter #0:2: start 338.630000, end 598.389000
    Metadata:
      title           : 00:05:38.630
    Chapter #0:3: start 598.389000, end 793.584000
    Metadata:
      title           : 00:09:58.389
    Chapter #0:4: start 793.584000, end 924.882000
    Metadata:
      title           : 00:13:13.584
    Chapter #0:5: start 924.882000, end 1206.497000
    Metadata:
      title           : 00:15:24.882
    Chapter #0:6: start 1206.497000, end 1374.832000
    Metadata:
      title           : 00:20:06.497
    Chapter #0:7: start 1374.832000, end 1539.496000
    Metadata:
      title           : 00:22:54.832
    Chapter #0:8: start 1539.496000, end 1872.996000
    Metadata:
      title           : 00:25:39.496
    Chapter #0:9: start 1872.996000, end 2220.677000
    Metadata:
      title           : 00:31:12.996
    Chapter #0:10: start 2220.677000, end 2460.917000
    Metadata:
      title           : 00:37:00.677
    Chapter #0:11: start 2460.917000, end 2651.440000
    Metadata:
      title           : 00:41:00.917
    Chapter #0:12: start 2651.440000, end 2976.098000
    Metadata:
      title           : 00:44:11.440
    Chapter #0:13: start 2976.098000, end 3161.116000
    Metadata:
      title           : 00:49:36.098
    Chapter #0:14: start 3161.116000, end 3408.363000
    Metadata:
      title           : 00:52:41.116
    Chapter #0:15: start 3408.363000, end 3604.559000
    Metadata:
      title           : 00:56:48.363
    Chapter #0:16: start 3604.559000, end 3805.260000
    Metadata:
      title           : 01:00:04.559
    Chapter #0:17: start 3805.260000, end 4018.973000
    Metadata:
      title           : 01:03:25.260
    Chapter #0:18: start 4018.973000, end 4303.257000
    Metadata:
      title           : 01:06:58.973
    Chapter #0:19: start 4303.257000, end 4480.601000
    Metadata:
      title           : 01:11:43.257
    Chapter #0:20: start 4480.601000, end 4735.689000
    Metadata:
      title           : 01:14:40.601
    Chapter #0:21: start 4735.689000, end 4882.002000
    Metadata:
      title           : 01:18:55.689
    Chapter #0:22: start 4882.002000, end 5061.014000
    Metadata:
      title           : 01:21:22.002
    Chapter #0:23: start 5061.014000, end 5199.820000
    Metadata:
      title           : 01:24:21.014
    Chapter #0:24: start 5199.820000, end 5428.381000
    Metadata:
      title           : 01:26:39.820
    Chapter #0:25: start 5428.381000, end 5641.761000
    Metadata:
      title           : 01:30:28.381
    Chapter #0:26: start 5641.761000, end 5836.456000
    Metadata:
      title           : 01:34:01.761
    Chapter #0:27: start 5836.456000, end 6106.392000
    Metadata:
      title           : 01:37:16.456
    Chapter #0:28: start 6106.392000, end 6295.915000
    Metadata:
      title           : 01:41:46.392
    Chapter #0:29: start 6295.915000, end 6486.605000
    Metadata:
      title           : 01:44:55.915
    Chapter #0:30: start 6486.605000, end 6746.365000
    Metadata:
      title           : 01:48:06.605
    Chapter #0:31: start 6746.365000, end 6924.376000
    Metadata:
      title           : 01:52:26.365
    Chapter #0:32: start 6924.376000, end 7203.655000
    Metadata:
      title           : 01:55:24.376
    Chapter #0:33: start 7203.655000, end 7584.535000
    Metadata:
      title           : 02:00:03.655
    Chapter #0:34: start 7584.535000, end 7701.485000
    Metadata:
      title           : 02:06:24.535
    Chapter #0:35: start 7701.485000, end 7846.797000
    Metadata:
      title           : 02:08:21.485
    Chapter #0:36: start 7846.797000, end 7986.604000
    Metadata:
      title           : 02:10:46.797
    Chapter #0:37: start 7986.604000, end 8197.314000
    Metadata:
      title           : 02:13:06.604
    Chapter #0:38: start 8197.314000, end 8577.527000
    Metadata:
      title           : 02:16:37.314
    Chapter #0:39: start 8577.527000, end 8671.288000
    Metadata:
      title           : 02:22:57.527
    Chapter #0:40: start 8671.288000, end 9251.232000
    Metadata:
      title           : 02:24:31.288
    Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x792, SAR 1:1 DAR 80:33, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      BPS-eng         : 9997049
      DURATION-eng    : 02:34:11.159000000
      NUMBER_OF_FRAMES-eng: 221806
      NUMBER_OF_BYTES-eng: 11560537037
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: truehd, 48000 Hz, 5.1(side), s32 (24 bit) (default)
    Metadata:
      BPS-eng         : 1367285
      DURATION-eng    : 02:34:11.201000000
      NUMBER_OF_FRAMES-eng: 11101441
      NUMBER_OF_BYTES-eng: 1581129012
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 02:34:11.232000000
      NUMBER_OF_FRAMES-eng: 289101
      NUMBER_OF_BYTES-eng: 740098560
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle (default)
    Metadata:
      BPS-eng         : 18749
      DURATION-eng    : 02:33:42.130000000
      NUMBER_OF_FRAMES-eng: 2164
      NUMBER_OF_BYTES-eng: 21614023
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:4(chi): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 12260
      DURATION-eng    : 02:33:42.130000000
      NUMBER_OF_FRAMES-eng: 1870
      NUMBER_OF_BYTES-eng: 14133317
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:5(kor): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 9361
      DURATION-eng    : 02:33:42.130000000
      NUMBER_OF_FRAMES-eng: 1858
      NUMBER_OF_BYTES-eng: 10791550
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:6(por): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 16812
      DURATION-eng    : 02:33:41.880000000
      NUMBER_OF_FRAMES-eng: 1844
      NUMBER_OF_BYTES-eng: 19380820
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:7(ara): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 8939
      DURATION-eng    : 02:33:42.130000000
      NUMBER_OF_FRAMES-eng: 1880
      NUMBER_OF_BYTES-eng: 10305380
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:8(ind): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 18054
      DURATION-eng    : 02:33:42.130000000
      NUMBER_OF_FRAMES-eng: 1856
      NUMBER_OF_BYTES-eng: 20812792
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:9(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS-eng         : 3100
      DURATION-eng    : 02:19:46.378000000
      NUMBER_OF_FRAMES-eng: 390
      NUMBER_OF_BYTES-eng: 3250745
      _STATISTICS_WRITING_APP-eng: mkvmerge v23.0.0 ('The Bride Said No') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-05-20 14:00:32
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
| improve this question | | | | |
0

The command you gave tries to add the subtitels as softsubs to the MP4, not hard-burn them, but you need to use the subtitles filter to render soft subs into hard subs.

Something along the lines of

ffmpeg -i .\sample.mkv -filter_complex "[0:v][0:s]overlay[v]" -map "[v]" -map "0:a" -c:v h264 -c:a copy sample.mp4

should do the trick.

EDIT 1

After posting the sample, it became clear, that the original audio is not AAC, so we need to rencode the audio: -c:a copy will not work.

running

ffmpeg -i .\sample.mkv -filter_complex "[0:v][0:s]overlay[v]" -map "[v]" -map "0:a" -c:v h264 -c:a aac sample.mp4

works as expected.

EDIT 2

How does this work? Let's go through the arguments:

  • First we open the file: -i sample.mkv
  • Then we combine the image (0:v) with the softsubs (0:s) using a filter - a filter is a construct that does not only change the encoding of the medium, but also its content. In this case, we change the image by hard-burning the subtitles into it and creating a named stream called v.
  • Next we tell ffmpeg which streams to process: For image, it should use v, for audio it should use the audio of the original file (0:a). We use -map to set these.
  • Finally we must encode the output - -c:v defines the codec for video, while -c:a defines it for audio.
| improve this answer | | | | |
  • I can't really tell how this works? Never heard of filter_complex but all I know is that ffmpeg responded with this: Too many packets buffered for output stream 0:1. – Taku Oct 20 '19 at 13:19
  • The audio can't be copied - edited my answer. – Eugen Rieck Oct 20 '19 at 13:37
  • Okay it did work with the sample perfectly but I now tried the entire movie and the result was this message: [graph 0 input from stream 0:3 @ 00000214ca69cdc0] Changing frame properties on the fly is not supported by all filters. Spammed and the resulting video forced the captions always on, so it didn't seem to use stream 9? Maybe? I'll edit my original post and provide all the meta data for the sample and full video – Taku Oct 20 '19 at 13:54
  • Try -filter_complex "[0:v][0:9]overlay[v]" instead of -filter_complex "[0:v][0:s]overlay[v]" - this can happen if there is more than one subtitle stream present. – Eugen Rieck Oct 20 '19 at 14:03
  • All signs seem to indicate that it does indeed work ^^ – Taku Oct 20 '19 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.