Opened 6 years ago

Closed 6 years ago

#7783 closed defect (fixed)

Copy of VobSub stream from MP4 to Matroska fails

Reported by: martchus Owned by:
Priority: minor Component: avformat
Version: git-master Keywords: mkv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

When using -c:s copy ffmpeg fails to copy a subtitle stream of the format dvd_subtitle from an MP4 file to a Matroska file. Instead one gets the following error message:

[matroska @ 0x563513bfa400] Tag mp4s incompatible with output codec id '94208' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Error initializing output stream 0:0 --
Conversion failed!

How to reproduce:

ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input_with_dvd_subtitle.mp4 -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -map 0:5 -c:v hevc_nvenc -profile:v main10 -preset slow -rc vbr_hq -cq 1 -c:a copy -c:s copy output.mkv
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181127
  configuration: --prefix=/usr --extra-cflags=-I/opt/cuda/include --extra-ldflags='-L/opt/cuda/lib64 -Wl,-rpath -Wl,/opt/intel/mediasdk/lib64:/opt/intel/mediasdk/plugins' --toolchain=hardened --disable-rpath --enable-gpl --enable-version3 --enable-nonfree --disable-static --disable-stripping --enable-shared --enable-swresample --enable-cuda-sdk --enable-libnpp --enable-libmfx --enable-ffnvcodec --enable-libdrm --enable-libmfx --enable-nvenc --enable-nvdec --enable-omx --enable-omx-rpi --enable-alsa --enable-avisynth --enable-chromaprint --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gpl --enable-gray --enable-iconv --enable-ladspa --enable-libaom --enable-libass --enable-libcodec2 --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcelt --enable-libcodec2 --enable-libdavs2 --enable-libdc1394 --enable-libfdk-aac --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libklvanc --enable-libkvazaar --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libndi_newtek --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libopencv --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-librtmp --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libsrt --enable-libssh --enable-libtensorflow --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvidstab --disable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxavs2 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-lzma --enable-openal --enable-opencl --enable-opengl --enable-openssl --enable-rkmpp --enable-sndio --enable-sdl2 --enable-vapoursynth --enable-v4l2-m2m --enable-vaapi --enable-vdpau --enable-xlib --enable-zlib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x563513a8d2c0] stream 0, timescale not set
[AVBSFContext @ 0x56351408ab00] Invalid NAL unit 0, skipping.
    Last message repeated 11 times
[h264 @ 0x563513aa6280] Invalid NAL unit 0, skipping.
    Last message repeated 11 times
[h264 @ 0x563513aa6280] no frame!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x563513a8d2c0] Stream #7: not enough frames to estimate rate; consider increasing probesize
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x563513a8d2c0] decoding for stream 7 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x563513a8d2c0] Could not find codec parameters for stream 7 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 
    title           : 
    artist          :
    album           : 
    comment         :
    encoder         : DVDFab 9.1.5.2
  Duration: 02:26:06.12, start: 0.000000, bitrate: 10090 kb/s
    Chapter #0:0: start 0.000000, end 258.508208
    Metadata:
      title           : Chapter 1
    Chapter #0:1: start 258.508208, end 586.627625
    Metadata:
      title           : Chapter 2
    Chapter #0:2: start 586.627625, end 916.206833
    Metadata:
      title           : Chapter 3
    Chapter #0:3: start 916.206833, end 1153.568958
    Metadata:
      title           : Chapter 4
    Chapter #0:4: start 1153.568958, end 1564.229167
    Metadata:
      title           : Chapter 5
    Chapter #0:5: start 1564.229167, end 1897.770708
    Metadata:
      title           : Chapter 6
    Chapter #0:6: start 1897.770708, end 2143.307625
    Metadata:
      title           : Chapter 7
    Chapter #0:7: start 2143.307625, end 2497.536500
    Metadata:
      title           : Chapter 8
    Chapter #0:8: start 2497.536500, end 2745.617667
    Metadata:
      title           : Chapter 9
    Chapter #0:9: start 2745.617667, end 3014.094208
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 3014.094208, end 3302.715875
    Metadata:
      title           : Chapter 11
    Chapter #0:11: start 3302.715875, end 3511.174083
    Metadata:
      title           : Chapter 12
    Chapter #0:12: start 3511.174083, end 3821.358958
    Metadata:
      title           : Chapter 13
    Chapter #0:13: start 3821.358958, end 4202.197708
    Metadata:
      title           : Chapter 14
    Chapter #0:14: start 4202.197708, end 4470.924458
    Metadata:
      title           : Chapter 15
    Chapter #0:15: start 4470.924458, end 4728.848792
    Metadata:
      title           : Chapter 16
    Chapter #0:16: start 4728.848792, end 4937.599000
    Metadata:
      title           : Chapter 17
    Chapter #0:17: start 4937.599000, end 5095.089667
    Metadata:
      title           : Chapter 18
    Chapter #0:18: start 5095.089667, end 5283.194250
    Metadata:
      title           : Chapter 19
    Chapter #0:19: start 5283.194250, end 5554.173250
    Metadata:
      title           : Chapter 20
    Chapter #0:20: start 5554.173250, end 5860.229000
    Metadata:
      title           : Chapter 21
    Chapter #0:21: start 5860.229000, end 6157.567708
    Metadata:
      title           : Chapter 22
    Chapter #0:22: start 6157.567708, end 6474.133917
    Metadata:
      title           : Chapter 23
    Chapter #0:23: start 6474.133917, end 6828.112500
    Metadata:
      title           : Chapter 24
    Chapter #0:24: start 6828.112500, end 7050.960125
    Metadata:
      title           : Chapter 25
    Chapter #0:25: start 7050.960125, end 7287.988542
    Metadata:
      title           : Chapter 26
    Chapter #0:26: start 7287.988542, end 7542.159083
    Metadata:
      title           : Chapter 27
    Chapter #0:27: start 7542.159083, end 7782.732750
    Metadata:
      title           : Chapter 28
    Chapter #0:28: start 7782.732750, end 7996.029167
    Metadata:
      title           : Chapter 29
    Chapter #0:29: start 7996.029167, end 8087.120167
    Metadata:
      title           : Chapter 30
    Chapter #0:30: start 8087.120167, end 8765.005708
    Metadata:
      title           : Chapter 31
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x800, 9200 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
      encoder         : JVT/AVC Coding
    Stream #0:1(deu): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 438 kb/s (default)
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
    Stream #0:2(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 445 kb/s
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
    Stream #0:3(eng): Subtitle: dvd_subtitle (mp4s / 0x7334706D) (default)
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
    Stream #0:4(deu): Subtitle: dvd_subtitle (mp4s / 0x7334706D)
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
    Stream #0:5(deu): Subtitle: dvd_subtitle (mp4s / 0x7334706D)
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
    Stream #0:6(und): Data: bin_data (text / 0x74786574)
    Metadata:
      creation_time   : 2015-07-13T17:59:49.000000Z
    Stream #0:7: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #0:4 -> #0:4 (copy)
  Stream #0:5 -> #0:5 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x563513bfa400] Tag mp4s incompatible with output codec id '94208' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Error initializing output stream 0:0 --
Conversion failed!

I didn't shorten it so you can see the ffmpeg version and compile flags I'm using. If you need a sample file, let me know. But likely any MP4 file with dvd_subtitle will do.

further notes:

It works when using MP4 also as the output container. It also works when using -c:s dvd_subtitle instead of -c:s copy. I'm not 100 % sure whether this is a bug or whether passing the MP4-internal tag to the output muxer is actually wanted when using "copy". Nevertheless, at least the error message is not very intuitive to understand. A suggestion to use -c:s dvd_subtitle would be very nice.

By the way, when not specifying the codec for subtitles at all, ffmpeg attempts a conversion to ASS. That makes sense for Matroska. However, that fails since the conversion from VobSub has not been implemented yet. So it would be nice if for the default codec the input format would be considered as well to avoid defaulting to conversions which are not implemented. That would have prevented me from running into this issue in the first place because my first attempt was actually to use ffmpeg's default for the subtitles.

Change History (1)

comment:1 by Carl Eugen Hoyos, 6 years ago

Component: ffmpegavformat
Keywords: mkv added; mp4s dvd_subtitle matroska removed
Resolution: fixed
Status: newclosed
Version: 4.1git-master

For future tickets: Please remember that only current FFmpeg git head is supported on this bug tracker.

Should be fixed in 715186456c556d94265e6376a38941c17d6a0ad6, thank you for the report!

Note: See TracTickets for help on using tickets.