[FFmpeg-devel] [PATCH] libavformat/hlsenc.c resend headers when generate a new segment in single_file mode

huheng heng.hu.1989 at gmail.com
Sat Jun 25 18:14:33 EEST 2022


Add pat and pmt table at start of each segment in single_file mode
enhanced compatibility of hls stream

Because some hls clients separate parsing segment of hls stream,
the absence of pat/pmt will cause parsing to fail

Signed-off-by: huheng <heng.hu.1989 at gmail.com>
---
 libavformat/hlsenc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3bafddfa61..ee5c5afe56 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2631,6 +2631,11 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
             vs->start_pos += vs->size;
             if (hls->key_info_file || hls->encrypt)
                 ret = hls_start(s, vs);
+
+            if (oc->oformat->priv_class && oc->priv_data) {
+                av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0);
+            }
+
         } else if (hls->max_seg_size > 0) {
             if (vs->size + vs->start_pos >= hls->max_seg_size) {
                 vs->sequence++;
-- 
2.36.1



More information about the ffmpeg-devel mailing list