我正在努力将这个 mkv 编码为 h264 的具体示例。0:0 是视频;0:1 是音频(英语),0:9 是只有说日语时才会出现的英语字幕。我想将视频编码为 h264,复制音频并将字幕硬编码到视频轨道中。问题是:0:9 似乎已损坏:
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
以下是我目前想到的:
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
结果如下:
Error while opening encoder for output stream #0:2 - maybe incorrect parameters
such as bit_rate, rate, width or height
这里是 样本我正在嘗試處理...
(请注意,由于该样本只有英文独白,因此没有字幕)
有趣的是,当我输入整部电影时,ffmpeg 不仅抱怨流 9,还抱怨所有其他字幕流 3-8。但这次它实际上给了我流 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
这可能是因为流 9 在技术上在样本期间不包含任何内容。
也许有人知道一两件事;谢谢编辑:完整元数据示例:
[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
完整视频:
[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
答案1
您给出的命令尝试将字幕作为软字幕添加到 MP4,而不是硬刻录,但您需要使用过滤subtitles
器将软字幕渲染为硬字幕。
类似于
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
应该可以解决问题。
编辑1
发布样本后,很明显,原始音频不是 AAC,所以我们需要重新编码音频:-c:a copy
行不通。
跑步
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
按预期工作。
编辑2
这是怎么回事呢?让我们来看一下这些论点:
- 首先我们打开文件:
-i sample.mkv
- 然后我们使用过滤器将图像 (0:v) 与软替换 (0:s) 结合起来 - 过滤器是一种不仅改变编码媒介,而且它的内容。在本例中,我们通过将字幕刻录到图像中并创建名为 的命名流来更改图像
v
。 - 接下来我们告诉 ffmpeg 要处理哪些流:对于图像,它应该使用
v
,对于音频,它应该使用原始文件的音频 (0:a)。我们使用-map
来设置这些。 - 最后,我们必须对输出进行编码 -
-c:v
为视频定义编解码器,同时-c:a
为音频定义编解码器。