Opened 20 months ago

Closed 20 months ago

Last modified 12 months 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 Changed 20 months ago by julian

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

comment:2 Changed 20 months ago by cehoyos

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

comment:3 Changed 20 months ago by julian

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 Changed 20 months ago by cehoyos

  • Component changed from avcodec to undetermined
  • Keywords sub added; movtextenc subtitle removed
  • Priority changed from important to normal
  • Resolution set to invalid
  • Status changed from new to closed

comment:5 Changed 20 months ago by julian

  • Component changed from undetermined to avcodec
  • Keywords movtextenc subtitle added; sub removed
  • Priority changed from normal to important

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

comment:6 Changed 20 months ago by julian

sorry my commend changed some things without my doing

comment:7 Changed 20 months ago by cehoyos

  • Component changed from avcodec to undetermined
  • Keywords sub added; movtextenc subtitle removed
  • Priority changed from important to normal

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

comment:8 Changed 20 months ago by julian

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 Changed 12 months ago by erikbs

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 Changed 12 months ago by julian

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 Changed 12 months ago by erikbs

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.