This patch will fix cutting hls segments into exactly same length. Because it will intialize only on first ref_packet, which is video frame, not audio frame (old behavior)

Now it should be possible to create segments at exactly same length if we use new -force_key_frames hls:time_in_seconds parameter.

This is required to support adaptive HLS.

This patch was splitted to two parts, this is first independent part

--
Miroslav Slugeň











>From 2d0bbf0a68bc5f85f24c65a65e3ae70c362e82dc Mon Sep 17 00:00:00 2001
From: Miroslav Slugen <thunde...@email.cz>
Date: Mon, 13 Feb 2017 14:13:18 +0100
Subject: [PATCH 1/1] hlsenc: intialize only on ref_pkt

---
 libavformat/hlsenc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 930e94b..e107fff 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1279,10 +1279,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         oc = hls->avf;
         stream_index = pkt->stream_index;
     }
-    if (hls->start_pts == AV_NOPTS_VALUE) {
-        hls->start_pts = pkt->pts;
-        hls->end_pts   = pkt->pts;
-    }
 
     if (hls->has_video) {
         can_split = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
@@ -1293,6 +1289,11 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         is_ref_pkt = can_split = 0;
 
     if (is_ref_pkt) {
+        if (hls->start_pts == AV_NOPTS_VALUE) {
+            hls->start_pts = pkt->pts;
+            hls->end_pts   = pkt->pts;
+        }
+
         if (hls->new_start) {
             hls->new_start = 0;
             hls->duration = (double)(pkt->pts - hls->end_pts)
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to