Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#5429 closed defect (invalid)

mov_text subtitles crash "QuickTime Player" and iOS devices

Reported by: julian Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: mov_text sub
Cc: niklesh.lalwani@iitb.ac.in Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

1.) download https://dl.dropboxusercontent.com/u/7221986/ffmpeg_bug_qtcrash.mkv
2.) ffmpeg -i ffmpeg_bug_qtcrash.mkv -map 0:1 -map 0:2 -map 0:0 -scodec mov_text -vcodec copy -acodec copy -y out.mp4
3.) open out.mp4 in Quicktime Player on Mac OS X 10.11.4 and watch it until second 21 or just scroll forward a bit after opening
4.) Quicktime Player crashes completely repeatably in "com.apple.coremedia.textmediaconverter.callback" with something like

Thread 26 Crashed:: Dispatch queue: com.apple.coremedia.textmediaconverter.callback.0x7fc0a96785b0
0 libobjc.A.dylib 0x00007fff8e31a4dd objc_msgSend + 29
1 com.apple.CoreFoundation 0x00007fff97c5b8c2 CFAttributedStringSetAttributes + 914
2 com.apple.MediaToolbox 0x00007fff98c09b36 FigTextSampleBufferCopyAttributedString + 3110
3 com.apple.MediaToolbox 0x00007fff98c523f3 0x7fff98b0b000 + 1340403


the change in ffmpeg that introduced this problem was between version 2.7.2 and version 2.8.0, more specifically it was commit "cf9051deac498eed70ab68c562b761c55251d270" [movtextenc.c: Support for Bold, Italic and Underlined Styles]

the problem has not been fixed since, i tried releases up to 3.0.1 as well as recent git snapshots "N-79115-g65cff81" (compiled myself) and "N-79453-g5256250-tessus" (precompiled)

if i compile 2.8.6 with movtextenc.c from before the bad commit, the problem goes away and the resulting file doesn't crash Quicktime Player anymore


p.s. please host a copy of the file to reproduce the issue

Change History (11)

comment:1 by julian, 8 years ago

note that the quicktime player crash does not occur just for me or just on my machine

comment:2 by Carl Eugen Hoyos, 8 years ago

Why are you reporting this QT issue here? I don't think any FFmpeg developer can fix it...

comment:3 by julian, 8 years ago

of course it can be fixed, just revert the bad commit

the only purpose of the mov_text encoder is to view the files in quicktime, if that doesn't work it has missed its purpose

of course i also reported the issue to apple but they are gonna take years to fix it, so we need a solution on FFMPEG site as well

comment:4 by Carl Eugen Hoyos, 8 years ago

Component: avcodecundetermined
Keywords: sub added; movtextenc subtitle removed
Priority: importantnormal
Resolution: invalid
Status: newclosed

comment:5 by julian, 8 years ago

Component: undeterminedavcodec
Keywords: movtextenc subtitle added; sub removed
Priority: normalimportant

also if quicktime crashes on the files now, there is a good chance the subtitles are kind of invalid now

comment:6 by julian, 8 years ago

sorry my commend changed some things without my doing

comment:7 by Carl Eugen Hoyos, 8 years ago

Component: avcodecundetermined
Keywords: sub added; movtextenc subtitle removed
Priority: importantnormal

I don't think a revert is useful, if the encoder does something wrong, we should check the specification and fix it.

comment:8 by julian, 8 years ago

note to others that may be hitting this:

i can just take the movtextenc.c from 2.7.2 in 2.8.6 and 3.0.1 to fix the problem ,however when i do the same in current git head, there are no subtitles at all

comment:9 by erikbs, 7 years ago

I have experienced this problem too, but I think I have a solution. Only recently did ffmpeg add support for italic/bold text etc. when encoding mov_text subtitles. In 2.7.2 this feature was not added yet, so ffmpeg just stripped away the text styles and thus your file would play fine in QuickTime. It looks like the styles are encoded incorrectly, and coupled with bad error handling in QuickTime, that causes the crash. Your sample file has been deleted, but I guess that the subtitles contain italic or bold text (or other styling).

I have created a more detailed post on this issue, my possible fix is included as a comment to the original post. Please try applying my patch, then recompile and run ffmpeg and check if the movie still crashes QuickTime.

comment:10 by julian, 7 years ago

thanks for diagnosing this and working on this. i guess bug #6021 is essentially the same as this one just with more technical details ;)

i've used this patch to force ffmpeg to generate QuickTime compatible files:

--- ffmpeg_snap/libavcodec/movtextenc.c	2016-04-12 17:33:57.000000000 +0200
+++ ffmpeg_git/libavcodec/movtextencORIG.c	2016-02-27 19:20:04.000000000 +0100
@@ -203,7 +203,6 @@
 
 static void mov_text_style_cb(void *priv, const char style, int close)
 {
-return;
     MovTextContext *s = priv;
     if (!close) {
         if (!(s->box_flags & STYL_BOX)) {   //first style entry

comment:11 by erikbs, 7 years ago

Yes, I think it’s the same bug. Unfortunately I did not see your report until I had already written #6021 … I just submitted my patch (or at least tried), so hopefully we don’t have to avoid mov_text_style_cb anymore :)

Note: See TracTickets for help on using tickets.