Ubuntu – How to burn vobsub subtitles using ffmpeg

ffmpegsubtitle

I have an MKV that I am using to create a DVD using DeVeDe

The MKV has embedded subtitles in vobsub format, which DeVeDe does not support (or bugged, not sure)

I decided to burn the subtitles to the output using the extra ffmpeg parameters option, which I took from here:

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

So I've updated to the latest ffmpeg and added the following extra parameters:

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

So the complete command is:

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

But out of DeVeDe I get:

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

Running it in a shell gets:

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

The documentation for the filter is here: http://ffmpeg.org/ffmpeg-filters.html#overlay-1

But I can't make head or tail of it.
The -map parameters a mystery as well.

Here's the details the streams:

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

Complete output from 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

If I copy that command to a shell the output is different:

    $ 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

How to I burn that subtitle stream to the output video?

Best Answer

The problems

I see several issues with your command:

  • All filtering should be within one filtergraph.

  • You have many contradicting commands: for example you use the scale video filter, then you use -target which will scale, and you use -s which will also scale. You use -acodec copy to stream copy the audio, but you also include -ac 2 to force stereo. These are mutually exclusive so something is being ignored.

  • You placed options after the output. I'm not sure how ffmpeg will interpret that. Option placement matters.

Example

Who's a good pig?

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

Note

Your video is 720x336, but your subtitles are 720x480. You may have to use crop on the subtitles before using overlay:

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

Or alternatively you could use a negative value on the y coordinate in overlay:

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