Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1828 closed enhancement (fixed)

Start timestamp ignored when muxing dvd_subtitle

Reported by: billie Owned by: ubitux
Priority: normal Component: avformat
Version: git-master Keywords: dvdsub
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by ubitux)

When adding a dvd_subtitle to a video file the starting time-stamp is ignored which causes all subsequent subtitles to be displayed to early by this time-stamp. I will attach a sample video file and the subtitle.idx/sub files. The subtitle file contains three subtitles starting after 5, 15 and 25 seconds with a duration of 2 seconds. When playing the resulting video file including the subtitle the subtitles are displayed after 0, 10 and 20 seconds.

The following command line can be used to reproduce the issue:

% ffmpeg -i test.mkv -i subtitle.sub -map 0 -map 1 -c: copy -f matroska test_subs.mkv
ffmpeg version N-45643-g6a762b6 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 17 2012 17:29:33 with gcc 4.5.4 (Gentoo 4.5.4 p1.0, pie-0.4.7)
  configuration: --cc=i686-pc-linux-gnu-gcc --cxx=i686-pc-linux-gnu-g++ --ar=i686-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe -fomit-frame-pointer' --extra-cflags='-march=native -O2 -pipe -fomit-frame-pointer' --extra-cxxflags='-march=native -O2 -pipe -fomit-frame-pointer' --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --disable-vdpau --disable-ffplay --enable-gnutls --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libaacplus --enable-nonfree --enable-libfaac --enable-nonfree --enable-libcdio --enable-libdc1394 --enable-openal --disable-indev=v4l --disable-indev=jack --enable-x11grab --enable-libv4l2 --disable-outdev=sdl --enable-frei0r --enable-libfreetype --enable-libass --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libgsm --enable-libmodplug --enable-libschroedinger --enable-libspeex --enable-libvp  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 66.100 / 54. 66.100
  libavformat    54. 33.100 / 54. 33.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.103 /  3. 19.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, matroska,webm, from 'test.mkv':
  Metadata:
    ENCODER         : Lavf53.32.100
  Duration: 00:00:30.01, start: 0.000000, bitrate: 38 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 320x240, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s (default)
Input #1, mpeg, from 'subtitle.sub':
  Duration: 00:00:20.00, start: 5.079989, bitrate: 2 kb/s
    Stream #1:0[0x20]: Subtitle: dvd_subtitle
Output #0, matroska, to 'test_subs.mkv':
  Metadata:
    encoder         : Lavf54.33.100
    Stream #0:0: Video: h264, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, 32 kb/s (default)
    Stream #0:2: Subtitle: dvd_subtitle
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #1:0 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame=  750 fps=0.0 q=-1.0 Lsize=     143kB time=00:00:30.01 bitrate=  39.0kbits/s    
video:13kB audio:117kB subtitle:1 global headers:0kB muxing overhead 8.907932%

Attachments (3)

test.mkv (141.5 KB) - added by billie 4 years ago.
sample video file
subtitle.sub (6.0 KB) - added by billie 4 years ago.
subtitle file (sub)
subtitle.idx (675 bytes) - added by billie 4 years ago.
subtitle file (idx)

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by billie

sample video file

Changed 4 years ago by billie

subtitle file (sub)

Changed 4 years ago by billie

subtitle file (idx)

comment:1 Changed 4 years ago by ubitux

  • Description modified (diff)

comment:2 Changed 4 years ago by ubitux

  • Component changed from undetermined to avformat
  • Keywords vobsub added
  • Owner set to ubitux
  • Status changed from new to open
  • Type changed from defect to enhancement

The index file (.idx) contains timing information which are simply ignored (ffmpeg only uses the timestamps in the MPEG stream of the .sub): FFmpeg doesn't support yet VobSub?. A demuxer is in development (still not usable), see http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2012-September/130546.html.

I'll update this ticket when it's done and applied.

Last edited 4 years ago by ubitux (previous) (diff)

comment:3 follow-up: Changed 4 years ago by Cigaes

In the meantime before the vobsub demuxer is complete, you can use mkvmerge to merge the two vobsub files into a single Matroska file with just the subtitle stream: ffmpeg will be able to read it, with the correct timestamps.

comment:4 in reply to: ↑ 3 Changed 4 years ago by billie

Replying to Cigaes:

In the meantime before the vobsub demuxer is complete, you can use mkvmerge to merge the two vobsub files into a single Matroska file with just the subtitle stream: ffmpeg will be able to read it, with the correct timestamps.

Thank you for the tip but this is the workaround I am currently using.

comment:5 follow-up: Changed 4 years ago by ubitux

  • Resolution set to fixed
  • Status changed from open to closed

Added in 710c4baf.

You can try to mux with -i sub.idx.

comment:6 Changed 4 years ago by cehoyos

  • Keywords dvdsub added; vobsub removed

comment:7 in reply to: ↑ 5 ; follow-up: Changed 4 years ago by billie

Replying to ubitux:

Added in 710c4baf.

You can try to mux with -i sub.idx.

Thank you very much for your work. Does this also work when directly using vob files as input? I tested one and it did work so I guess it does. When using version 0.10.5 I get errors like this for the subtitle streams:

Application provided invalid, non monotonically increasing dts to muxer in stream 2: 203320 >= 203320
av_interleaved_write_frame(): Invalid argument

comment:8 in reply to: ↑ 7 Changed 4 years ago by ubitux

Replying to billie:

Replying to ubitux:

Added in 710c4baf.

You can try to mux with -i sub.idx.

Thank you very much for your work. Does this also work when directly using vob files as input? I tested one and it did work so I guess it does. When using version 0.10.5 I get errors like this for the subtitle streams:

Application provided invalid, non monotonically increasing dts to muxer in stream 2: 203320 >= 203320
av_interleaved_write_frame(): Invalid argument

No, the ticket was about supporting idx/sub, so I added support for idx/sub :)

About demuxing DVD subtitles properly and being able to mux them as VobSub? belongs to another issue.

Note: See TracTickets for help on using tickets.