History

avformat/movenc: fix HEVC fmp4 HLS init segment for Apple playback

HEVC fmp4 HLS video produced by ffmpeg is currently unplayable on Apple software (Safari, QuickTime, AVFoundation). This is caused by an empty sdtp atom being erroneously written to the fmp4 init segment. The `has_disposable` flag can be set for a track with B-frames, but the init segment contains no actual frames (track->entry == 0). Writing an sdtp atom in this case is incorrect and causes Apple's parsers to reject the file. This patch fixes the issue by ensuring the sdtp atom is only written if track->entry is non-zero. A similar patch was proposed in November 2023 by Jay Zhang, but it was never merged.

David McElroy committed 1 year ago

Commit 4b6f6af1 parent dc8e7531 file · +1 −1Browse files

Unified · Split

libavformat/movenc.c+1−1
@@ -3273,7 +3273,7 @@ static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext · 3272 unmodified lines
32733273 track->par->codec_tag == MKTAG('r','t','p',' ')) &&
32743274 track->has_keyframes && track->has_keyframes < track->entry)
32753275 mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
3276− if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->has_disposable)
3276+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->has_disposable && track->entry)
32773277 mov_write_sdtp_tag(pb, track);
32783278 if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS)
32793279 mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t