如何使用 ffmpeg 刻录 vobsub 字幕?

如何使用 ffmpeg 刻录 vobsub 字幕?

我有一个 MKV,我正在用 DeVeDe 创建 DVD

MKV 嵌入了 vobsub 格式的字幕,但 DeVeDe 不支持(或存在错误,不确定)

我决定使用额外的 ffmpeg 参数选项将字幕刻录到输出,该选项取自这里:

https://trac.ffmpeg.org/wiki/How%20to%20burn%20subtitles%20into%20the%20video

因此我已更新到最新的 ffmpeg 并添加了以下额外参数:

-filter_complex "[0:v][0:s]overlay[v]" -map [v] -map 0:a

因此完整的命令是:

ffmpeg -i ~/Input.mkv -vf scale=720:412,fifo,pad=720:576:0:82:0x000000 -y -target pal-dvd -sn -acodec copy -g 12 -t 60.0 -ac 2 -s 720x576 -threads 3 -trellis 1 -mbd 2 -b 2616000 -aspect 16:9 /var/tmp/previewfile_01_01.mpg -filter_complex "[0:v][0:s]overlay[v]" -map [v] -map 0:a

但是从 DeVeDe 中我得到:

[AVFilterGraph @ 0xa744ca0] No such filter: '"'

在 shell 中运行它可获得:

Output pad "default" with type video of the filter instance "Parsed_overlay_0" of overlay not connected to any destination

过滤器的文档在这里:http://ffmpeg.org/ffmpeg-filters.html#overlay-1

但我完全搞不懂。-map 参数同样是个谜。

以下是流的详细信息:

Stream #0:0(eng): Video: h264 (High), yuv420p(tv, smpte170m), 720x336 [SAR 21845:18873 DAR 109225:44037], SAR 199:172 DAR 2985:1204, 23.98 fps, 23.98 tbr, 1k tbn, 180k tbc (default)
Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
Stream #0:2(eng): Subtitle: dvd_subtitle, 720x480

devede 的完整输出:

Launching program:  ffmpeg -i ~/input.mkv -vf scale=720:412,fifo,pad=720:576:0:82:0x000000 -y -target pal-dvd -sn -acodec copy -g 12 -t 60.0 -ac 2 -s 720x576 -threads 3 -trellis 1 -mbd 2 -b 2616000 -aspect 16:9 /var/tmp/previewfile_01_01.mpg -filter_complex "[0:v][0:s]overlay[v]" -map [v] -map 0:a
elemento:  /usr/bin
ffmpeg version N-59114-gcc0e2ba Copyright (c) 2000-2013 the FFmpeg developers
Input #0, matroska,webm, from '~/input.mkv':
  Duration: 03:03:11.13, start: 0.000000, bitrate: 898 kb/s
    Chapter #0.0: start 0.000000, end 232.982856
    Metadata:
      title           : Chapter 1
    Chapter #0.1: start 232.982856, end 479.729356
    Metadata:
      title           : Chapter 2
    Chapter #0.2: start 479.729356, end 573.322856
    Metadata:
      title           : Chapter 3
    Chapter #0.3: start 573.322856, end 1007.089522
    Metadata:
      title           : Chapter 4
    Chapter #0.4: start 1007.089522, end 1375.590989
    Metadata:
      title           : Chapter 5
    Chapter #0.5: start 1375.590989, end 2044.258989
    Metadata:
      title           : Chapter 6
    Chapter #0.6: start 2044.258989, end 2395.443156
    Metadata:
      title           : Chapter 7
    Chapter #0.7: start 2395.443156, end 2863.110356
    Metadata:
      title           : Chapter 8
    Chapter #0.8: start 2863.110356, end 3193.657244
    Metadata:
      title           : Chapter 9
    Chapter #0.9: start 3193.657244, end 3327.290744
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 3327.290744, end 3801.214189
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 3801.214189, end 4209.622189
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 4209.622189, end 4484.897189
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 4484.897189, end 4971.299778
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 4971.299778, end 5710.371444
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 5710.371444, end 5999.627078
    Metadata:
      title           : Chapter 16
    Chapter #0.16: start 5999.627078, end 6423.417111
    Metadata:
      title           : Chapter 17
    Chapter #0.17: start 6423.417111, end 6593.470322
    Metadata:
      title           : Chapter 18
    Chapter #0.18: start 6593.470322, end 7171.923244
    Metadata:
      title           : Chapter 19
    Chapter #0.19: start 7171.923244, end 7462.630322
    Metadata:
      title           : Chapter 20
    Chapter #0.20: start 7462.630322, end 8388.505278
    Metadata:
      title           : Chapter 21
    Chapter #0.21: start 8388.505278, end 8734.233989
    Metadata:
      title           : Chapter 22
    Chapter #0.22: start 8734.233989, end 9171.087078
    Metadata:
      title           : Chapter 23
    Chapter #0.23: start 9171.087078, end 9439.688744
    Metadata:
      title           : Chapter 24
    Chapter #0.24: start 9439.688744, end 9770.936322
    Metadata:
      title           : Chapter 25
    Chapter #0.25: start 9770.936322, end 10253.918822
    Metadata:
      title           : Chapter 26
    Chapter #0.26: start 10253.918822, end 10732.396822
    Metadata:
      title           : Chapter 27
    Chapter #0.27: start 10732.396822, end 10991.130000
    Metadata:
      title           : Chapter 28
    Stream #0:0(eng): Video: h264 (High), yuv420p(tv, smpte170m), 720x336 [SAR 21845:18873 DAR 109225:44037], SAR 199:172 DAR 2985:1204, 23.98 fps, 23.98 tbr, 1k tbn, 180k tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Stream #0:2(eng): Subtitle: dvd_subtitle, 720x480
Please use -b:a or -b:v, -b is ambiguous
[AVFilterGraph @ 0x9c18ca0] No such filter: '"'
Error configuring filters.
Creating window /usr/share/devede/werror_dialog.ui

如果我将该命令复制到 shell 中,输出会有所不同:

    $ ffmpeg -i ~/input.mkv -vf scale=720:412,fifo,pad=720:576:0:82:0x000000 -y -target pal-dvd -sn -acodec copy -g 12 -t 60.0 -ac 2 -s 720x576 -threads 3 -trellis 1 -mbd 2 -b 2616000 -aspect 16:9 /var/tmp/previewfile_01_01.mpg -filter_complex "[0:v][0:s]overlay[v]" -map [v] -map 0:a
    ffmpeg version N-59114-gcc0e2ba Copyright (c) 2000-2013 the FFmpeg developers
      built on Dec 15 2013 05:22:20 with gcc 4.6 (Debian 4.6.3-1)
      configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32 --extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static' --extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
      libavutil      52. 58.100 / 52. 58.100
      libavcodec     55. 45.101 / 55. 45.101
      libavformat    55. 22.100 / 55. 22.100
      libavdevice    55.  5.102 / 55.  5.102
      libavfilter     3. 92.100 /  3. 92.100
      libswscale      2.  5.101 /  2.  5.101
      libswresample   0. 17.104 /  0. 17.104
      libpostproc    52.  3.100 / 52.  3.100
    Trailing options were found on the commandline.
    Input #0, matroska,webm, from '~/input.mkv':
      Duration: 03:03:11.13, start: 0.000000, bitrate: 898 kb/s
        Chapter #0.0: start 0.000000, end 232.982856
        Metadata:
          title           : Chapter 1
        Chapter #0.1: start 232.982856, end 479.729356
        Metadata:
          title           : Chapter 2
        Chapter #0.2: start 479.729356, end 573.322856
        Metadata:
          title           : Chapter 3
        Chapter #0.3: start 573.322856, end 1007.089522
        Metadata:
          title           : Chapter 4
        Chapter #0.4: start 1007.089522, end 1375.590989
        Metadata:
          title           : Chapter 5
        Chapter #0.5: start 1375.590989, end 2044.258989
        Metadata:
          title           : Chapter 6
        Chapter #0.6: start 2044.258989, end 2395.443156
        Metadata:
          title           : Chapter 7
        Chapter #0.7: start 2395.443156, end 2863.110356
        Metadata:
          title           : Chapter 8
        Chapter #0.8: start 2863.110356, end 3193.657244
        Metadata:
          title           : Chapter 9
        Chapter #0.9: start 3193.657244, end 3327.290744
        Metadata:
          title           : Chapter 10
        Chapter #0.10: start 3327.290744, end 3801.214189
        Metadata:
          title           : Chapter 11
        Chapter #0.11: start 3801.214189, end 4209.622189
        Metadata:
          title           : Chapter 12
        Chapter #0.12: start 4209.622189, end 4484.897189
        Metadata:
          title           : Chapter 13
        Chapter #0.13: start 4484.897189, end 4971.299778
        Metadata:
          title           : Chapter 14
        Chapter #0.14: start 4971.299778, end 5710.371444
        Metadata:
          title           : Chapter 15
        Chapter #0.15: start 5710.371444, end 5999.627078
        Metadata:
          title           : Chapter 16
        Chapter #0.16: start 5999.627078, end 6423.417111
        Metadata:
          title           : Chapter 17
        Chapter #0.17: start 6423.417111, end 6593.470322
        Metadata:
          title           : Chapter 18
        Chapter #0.18: start 6593.470322, end 7171.923244
        Metadata:
          title           : Chapter 19
        Chapter #0.19: start 7171.923244, end 7462.630322
        Metadata:
          title           : Chapter 20
        Chapter #0.20: start 7462.630322, end 8388.505278
        Metadata:
          title           : Chapter 21
        Chapter #0.21: start 8388.505278, end 8734.233989
        Metadata:
          title           : Chapter 22
        Chapter #0.22: start 8734.233989, end 9171.087078
        Metadata:
          title           : Chapter 23
        Chapter #0.23: start 9171.087078, end 9439.688744
        Metadata:
          title           : Chapter 24
        Chapter #0.24: start 9439.688744, end 9770.936322
        Metadata:
          title           : Chapter 25
        Chapter #0.25: start 9770.936322, end 10253.918822
        Metadata:
          title           : Chapter 26
        Chapter #0.26: start 10253.918822, end 10732.396822
        Metadata:
          title           : Chapter 27
        Chapter #0.27: start 10732.396822, end 10991.130000
        Metadata:
          title           : Chapter 28
        Stream #0:0(eng): Video: h264 (High), yuv420p(tv, smpte170m), 720x336 [SAR 21845:18873 DAR 109225:44037], SAR 199:172 DAR 2985:1204, 23.98 fps, 23.98 tbr, 1k tbn, 180k tbc (default)
        Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
        Stream #0:2(eng): Subtitle: dvd_subtitle, 720x480
    Please use -b:a or -b:v, -b is ambiguous
    Output pad "default" with type video of the filter instance "Parsed_overlay_0" of overlay not connected to any destination

如何将字幕流刻录至输出视频?

答案1

问题

我发现你的命令存在几个问题:

  • 所有过滤应在一个过滤图

  • 你有许多相互矛盾的命令:例如你使用scale视频滤镜,然后你使用-target哪个会扩展,你使用-s哪个也会扩展。你-acodec copy使用流复制音频,但您还包含-ac 2强制立体声。这些是互斥的,因此会忽略某些内容。

  • 您将选项放在输出之后。我不确定 ffmpeg 将如何解释这一点。期权配置事。

例子

谁是好猪?

ffmpeg -y -i input.mkv -filter_complex "[0:v:0][0:s:0]overlay[vid]" -map "[vid]" -map 0:a \
-target pal-dvd -acodec copy -t 60 output.mpg

笔记

您的视频分辨率为 720x336,但字幕分辨率为 720x480。您可能需要使用crop使用前请阅读字幕overlay

[0:s:0]crop=iw:336[s1];[0:v:0][s1]overlay[vid]

y或者您也可以在坐标上使用负值overlay

[0:v:0][0:s:0]overlay=0:H-h[vid]

答案2

假设您的输入文件为infile.mp4infile.idxinfile.sub,并且您希望将它们合并为outfile.mkv,则您需要以下内容:

ffmpeg -i infile.mp4 -i infile.idx -i infile.sub -map 0:v -map 0:a -c copy -map 1 -c:s:1 dvd_subtitle -metadata:s:s:1 language=fre outfile.mkv

答案3

ffmpeg -i the_equalizer3.mpg -i the_equalizer3.sub -i the_equalizer3.idx -filter_complex "[0:v][2:s]overlay" -vcodec mpeg4 -vb 6000000 -r 59.94 -aspect 16:9 -acodec libmp3lame -async 48000 -vol 1250 the_equalizer-captioned2.mp4

上面的内容-filter complex是重要的部分 - 输入 0 是视频,输入 2 是字幕,用于覆盖。

如果您有单独的 vobsub 文件和 idx 文件,我使用上述命令取得了一定程度的成功(使用 ffmpeg 的最新静态 git 版本)。有趣的是,我必须指定.idx覆盖文件而不是文件.sub。也许提取字幕流,然后在编码时导入提取的文件可能会有效?

相关内容