[FFmpeg-devel] [PATCH] avformat/movenc: fix safari cannot play generated hls due to empty sdtp atom

Jay Zhang wangyoucao577 at gmail.com
Sat Nov 18 12:26:35 EET 2023


This issue can be reproduced by command 'ffmpeg -i small_bunny_1080p_60fps.mp4 -an  -c:v libx265 -tag:v hvc1 -f hls -hls_segment_type fmp4  out.m3u8'. After remove the empty sdtp atom, safari can play the out.m3u8 properly.

Signed-off-by: Jay Zhang <wangyoucao577 at gmail.com>
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e39f1ac987..34ac7e9dcc 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2827,7 +2827,7 @@ static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext
          track->par->codec_tag == MKTAG('r','t','p',' ')) &&
         track->has_keyframes && track->has_keyframes < track->entry)
         mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
-    if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->has_disposable)
+    if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->has_disposable && track->entry)
         mov_write_sdtp_tag(pb, track);
     if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS)
         mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);
-- 
2.34.1



More information about the ffmpeg-devel mailing list