![转码多种字幕类型](https://linux22.com/image/1616790/%E8%BD%AC%E7%A0%81%E5%A4%9A%E7%A7%8D%E5%AD%97%E5%B9%95%E7%B1%BB%E5%9E%8B.png)
我有一个由蓝光生成的 mkv 视频文件,带有一堆字幕流:
$ ffprobe -i 'bluray.mkv' | egrep -i '(stream|duration)' | egrep -v '(STATISTICS)'
[matroska,webm @ 0x8000c7980] 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 @ 0x8000c7980] 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 @ 0x8000c7980] 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
Duration: 03:35:24.22, start: 0.000000, bitrate: 18307 kb/s
Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x1596 [SAR 1:1 DAR 320:133], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
DURATION-eng : 03:35:23.244000000
Stream #0:1(fre): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
DURATION-eng : 03:35:24.224000000
Stream #0:2(eng): Audio: truehd, 48000 Hz, 5.1(side), s32 (24 bit)
DURATION-eng : 03:35:24.204000000
Stream #0:3(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
DURATION-eng : 03:35:24.224000000
Stream #0:4(fre): Subtitle: subrip (default)
DURATION-eng : 03:16:58.472000000
Stream #0:5(fre): Subtitle: subrip
DURATION-eng : 03:34:59.135000000
Stream #0:6(fre): Subtitle: hdmv_pgs_subtitle
DURATION-eng : 03:16:58.473000000
Stream #0:7(fre): Subtitle: hdmv_pgs_subtitle
DURATION-eng : 03:34:59.136000000
Stream #0:8(eng): Subtitle: hdmv_pgs_subtitle
DURATION-eng : 03:24:15.744000000
当我尝试将其转换为 mp4 时:
$ ffmpeg -hide_banner -stats -fix_sub_duration -i "bluray.mkv" -map 0:0 -s 720x480 -metadata title='' -r 29.97 -vcodec libx264 -map 0:1 -m
etadata:s:a:0 language=fre -c:a aac -ab 128k -ar 44100 -map 0:2 -metadata:s:a:1 language=eng -c:a aac -ab 128k -ar 44100 -map 0:3 -metadata:s:a:2 language=eng -c:a aac -ab 128k -ar 44100 -map 0:4 -scodec mov_text -metadata:s:s:0 language=f
re -map 0:5 -scodec mov_text -metadata:s:s:1 language=fre -map 0:6 -scodec dvdsub -metadata:s:s:2 language=fre -map 0:7 -scodec dvdsub -metadata:s:s:3 language=fre -map 0:8 -scodec dvdsub -metadata:s:s:4 language=eng "bluray_shrink.mp4"
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Stream #0:2 -> #0:2 (truehd (native) -> aac (native))
Stream #0:3 -> #0:3 (ac3 (native) -> aac (native))
Stream #0:4 -> #0:4 (subrip (srt) -> dvd_subtitle (dvdsub))
Stream #0:5 -> #0:5 (subrip (srt) -> dvd_subtitle (dvdsub))
Stream #0:6 -> #0:6 (hdmv_pgs_subtitle (pgssub) -> dvd_subtitle (dvdsub))
Stream #0:7 -> #0:7 (hdmv_pgs_subtitle (pgssub) -> dvd_subtitle (dvdsub))
Stream #0:8 -> #0:8 (hdmv_pgs_subtitle (pgssub) -> dvd_subtitle (dvdsub))
Subtitle encoding currently only possible from text to text or bitmap to bitmap
所以,我的问题是...为什么所有字幕流都试图转换为 dvdsub,即使我为 0:4 和 0:5 指定了 mov_text。我遗漏了什么,还是这是一个错误?我找不到任何可以确认或否认这一点的证据。
答案1
需要流说明符。最后一个-scodec
选项设置为dvbsub
。未使用流说明符,因此它适用于所有字幕。尝试:
ffmpeg -hide_banner -stats -fix_sub_duration -i 'bluray.mkv' \
-c:v libx264 \
-r 29.97 \
-s 720x480 \
-c:a aac \
-b:a 128k \
-ar 44100 \
-c:s:0 mov_text \
-c:s:1 mov_text \
-c:s:2 dvdsub \
-c:s:3 dvdsub \
-c:s:4 dvdsub \
-metadata title='' \
-metadata:s:a:0 language=fre \
-metadata:s:a:1 language=eng \
-metadata:s:a:2 language=eng \
-metadata:s:s:0 language=fre \
-metadata:s:s:1 language=fre \
-metadata:s:s:2 language=fre \
-metadata:s:s:3 language=fre \
-metadata:s:s:4 language=eng \
-map 0 'bluray_shrink.mp4'