Opened 12 years ago

Closed 11 years ago

Last modified 10 years ago

#862 closed defect (fixed)

Corrupted subtitles exported from matroska file.

Reported by: Vladimír Matěna Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: sub srt
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I am trying to extract subtitles from matroska file to the SubRip file. I think the following command should extract subtitles from source.mkv, but target.srt is created empty.

ffmpeg -scodec srt -i source.mkv target.srt

I also tried using -scodec copy, but it only stores subtitle text in target.srt and the timecodes are missing. It looks like matroska decoder is not adding timecodes stored in matroska blocks back to subtitles.

I implemented a function matroska_fix_srt_packet similar to matroska_fix_ass_packet and added it to libavformat/matroskadec.c . The changes are in attached patch.

With the patch the command produces the desired output.

I am sorry if I just didn't understand ffmpeg params and the changes are actually not needed.

Attachments (4)

SRT-in-MKV-support.patch (1.7 KB ) - added by Vladimír Matěna 12 years ago.
Add timecodes to srt subtitles exported from matroska.
ffmpeg.verbose.log (2.5 KB ) - added by Vladimír Matěna 12 years ago.
Output of "ffmpeg -loglevel verbose -scodec srt -i source.mkv -y target.srt"
target.srt (192 bytes ) - added by Vladimír Matěna 12 years ago.
Expected output(subtitles with timecodes).
source.mkv (266.1 KB ) - added by Vladimír Matěna 12 years ago.
Sample source file. Contains video audio and srt subtitle track.

Download all attachments as: .zip

Change History (11)

by Vladimír Matěna, 12 years ago

Attachment: SRT-in-MKV-support.patch added

Add timecodes to srt subtitles exported from matroska.

comment:1 by Cigaes, 12 years ago

Please show the full console output of ffmpeg, ideally with -loglevel verbose. Also, consider making a small excerpt of your matroska file available as an attachment.

With the information you provided, I was unable to guess exactly what you are trying to do, and in particular what format the original subtitles were.

by Vladimír Matěna, 12 years ago

Attachment: ffmpeg.verbose.log added

Output of "ffmpeg -loglevel verbose -scodec srt -i source.mkv -y target.srt"

by Vladimír Matěna, 12 years ago

Attachment: target.srt added

Expected output(subtitles with timecodes).

by Vladimír Matěna, 12 years ago

Attachment: source.mkv added

Sample source file. Contains video audio and srt subtitle track.

comment:2 by Vladimír Matěna, 12 years ago

Added verbose output of the command I use. I also attached sample source.mkv and expected target.srt. With current git I get empty target.src.

comment:3 by Cigaes, 12 years ago

Component: avformatFFmpeg
Keywords: text subtitles added; srt matroska mkv removed
Reproduced by developer: set
Status: newopen

Thanks. We are still very fuzzy about various subtitles formats, and format conversion (or lack of thereof).

The same problem appears when reading a simple srt file: I guess the bug is in ffmpeg rather than lavf.

In the meantime, I suppose you know you can use mkvextract to extract the subtitles tracks.

in reply to:  3 comment:4 by Vladimír Matěna, 12 years ago

Replying to Cigaes:

Thanks. We are still very fuzzy about various subtitles formats, and format conversion (or lack of thereof).

The same problem appears when reading a simple srt file: I guess the bug is in ffmpeg rather than lavf.

In the meantime, I suppose you know you can use mkvextract to extract the subtitles tracks.

For me reading srt files works fine. I tried something like "ffmpeg -i subs.srt subs.ass" and it works. I only have problems with writting ass subtitles to mkv files, but it is separate and more complicated issue.

I do know mkvextract, but ffmpeg is more handy for what I am doing. The patch I attached is sufficient walkaround for me.

I still believe that there is missing function for adding srt timecodes in livavformat. There is similar function for ass subtitles and ass are exported from mkv files without problems.

in reply to:  3 comment:5 by get8p, 12 years ago

Replying to Cigaes:

Thanks. We are still very fuzzy about various subtitles formats, and format conversion (or lack of thereof).

The same problem appears when reading a simple srt file: I guess the bug is in ffmpeg rather than lavf.

In the meantime, I suppose you know you can use mkvextract to extract the subtitles tracks.

Well r u planing on at least embedd srt/ass support? So it would be possilbe to mux/demux them properly?
Thanks.

Last edited 12 years ago by get8p (previous) (diff)

comment:6 by Clément Bœsch, 11 years ago

Resolution: fixed
Status: openclosed

This bug has likely been fixed with all the work we did on subtitles.

Re-encode:

% ./ffmpeg -i ~/source.mkv -y out.srt
ffmpeg version N-48391-g1e28fa2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan  2 2013 08:03:04 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-libx264 --enable-libmp3lame --enable-x11grab --enable-libvorbis
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 85.100 / 54. 85.100
  libavformat    54. 59.100 / 54. 59.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 30.102 /  3. 30.102
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '/home/ubitux/source.mkv':
  Metadata:
    ENCODER         : Lavf53.29.100
  Duration: 00:00:05.02, start: 0.000000, bitrate: 434 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 23.98 fps, 23.98 tbr, 1k tbn, 47.96 tbc (default)
    Stream #0:1(eng): Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Stream #0:2(cze): Subtitle: subrip (default)
Output #0, srt, to 'out.srt':
  Metadata:
    encoder         : Lavf54.59.100
    Stream #0:0(cze): Subtitle: subrip (default)
Stream mapping:
  Stream #0:2 -> #0:0 (subrip -> subrip)
Press [q] to stop, [?] for help
size=       0kB time=00:00:03.48 bitrate=   0.4kbits/s    
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead 58.620690%
% cat out.srt
1
00:00:00,601 --> 00:00:00,601
Takže když foton narazí
na desku se dvěma štěrbinami

2
00:00:03,485 --> 00:00:03,485
a obě ty štěrbiny pozoruješ,
neprojde oběma naráz.

Stream copy:

[~/src/ffmpeg]☭ ./ffmpeg -i ~/source.mkv -c copy -y out.srt
ffmpeg version N-48391-g1e28fa2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan  2 2013 08:03:04 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-libx264 --enable-libmp3lame --enable-x11grab --enable-libvorbis
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 85.100 / 54. 85.100
  libavformat    54. 59.100 / 54. 59.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 30.102 /  3. 30.102
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '/home/ubitux/source.mkv':
  Metadata:
    ENCODER         : Lavf53.29.100
  Duration: 00:00:05.02, start: 0.000000, bitrate: 434 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 23.98 fps, 23.98 tbr, 1k tbn, 47.96 tbc (default)
    Stream #0:1(eng): Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Stream #0:2(cze): Subtitle: subrip (default)
Output #0, srt, to 'out.srt':
  Metadata:
    encoder         : Lavf54.59.100
    Stream #0:0(cze): Subtitle: subrip (default)
Stream mapping:
  Stream #0:2 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=       0kB time=00:00:03.48 bitrate=   0.4kbits/s    
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead 58.620690%
% cat out.srt
1
00:00:00,601 --> 00:00:00,601
Takže když foton narazí
na desku se dvěma štěrbinami

2
00:00:03,485 --> 00:00:03,485
a obě ty štěrbiny pozoruješ,
neprojde oběma naráz.

Feel free to re-open if something is still wrong.

comment:7 by Carl Eugen Hoyos, 10 years ago

Keywords: sub srt added; text subtitles removed
Note: See TracTickets for help on using tickets.