Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1828 closed enhancement (fixed)

Start timestamp ignored when muxing dvd_subtitle

Reported by: Daniel Pielmeier Owned by: Clément Bœsch
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 Clément Bœsch)

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 Daniel Pielmeier 12 years ago.
sample video file
subtitle.sub (6.0 KB ) - added by Daniel Pielmeier 12 years ago.
subtitle file (sub)
subtitle.idx (675 bytes ) - added by Daniel Pielmeier 12 years ago.
subtitle file (idx)

Download all attachments as: .zip

Change History (11)

by Daniel Pielmeier, 12 years ago

Attachment: test.mkv added

sample video file

by Daniel Pielmeier, 12 years ago

Attachment: subtitle.sub added

subtitle file (sub)

by Daniel Pielmeier, 12 years ago

Attachment: subtitle.idx added

subtitle file (idx)

comment:1 by Clément Bœsch, 12 years ago

Description: modified (diff)

comment:2 by Clément Bœsch, 12 years ago

Component: undeterminedavformat
Keywords: vobsub added
Owner: set to Clément Bœsch
Status: newopen
Type: defectenhancement

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 12 years ago by Clément Bœsch (previous) (diff)

comment:3 by Cigaes, 12 years ago

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.

in reply to:  3 comment:4 by Daniel Pielmeier, 12 years ago

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 by Clément Bœsch, 12 years ago

Resolution: fixed
Status: openclosed

Added in 710c4baf.

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

comment:6 by Carl Eugen Hoyos, 12 years ago

Keywords: dvdsub added; vobsub removed

in reply to:  5 ; comment:7 by Daniel Pielmeier, 12 years ago

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

in reply to:  7 comment:8 by Clément Bœsch, 12 years ago

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.