summaryrefslogtreecommitdiff
path: root/libavformat/hlsenc.c
diff options
context:
space:
mode:
authorKarthick J <kjeyapal@akamai.com>2017-11-28 20:03:15 +0800
committerSteven Liu <lq@chinaffmpeg.org>2017-11-28 20:03:15 +0800
commitd5d2632e3a0f1709290834fd35457cd05cf48bc8 (patch)
tree6f8ab98278c365e241c140a952905b3854626af0 /libavformat/hlsenc.c
parent143552095dae9698f3779e93dd08548f46dc5686 (diff)
avformat/hlsenc: Fixed initial setting for end_pts
This patch fixes Bug #6868 Sometimes end_pts is getting initialized to audio stream's first pts, while the duration is calculated based on video stream's pts. In this patch the end_pts is initialized with the correct stream's first pts. Reviewed-by: Steven Liu <lq@onvideo.cn> Tested-by: beloko
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r--libavformat/hlsenc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 30ccf73d76..6997a5ced0 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1737,6 +1737,7 @@ static int hls_write_header(AVFormatContext *s)
vs->sequence = hls->start_sequence;
hls->recording_time = (hls->init_time ? hls->init_time : hls->time) * AV_TIME_BASE;
vs->start_pts = AV_NOPTS_VALUE;
+ vs->end_pts = AV_NOPTS_VALUE;
vs->current_segment_final_filename_fmt[0] = '\0';
if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & HLS_INDEPENDENT_SEGMENTS) {
@@ -2111,7 +2112,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
if (vs->start_pts == AV_NOPTS_VALUE) {
vs->start_pts = pkt->pts;
- vs->end_pts = pkt->pts;
}
if (vs->has_video) {
@@ -2123,6 +2123,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
is_ref_pkt = can_split = 0;
if (is_ref_pkt) {
+ if (vs->end_pts == AV_NOPTS_VALUE)
+ vs->end_pts = pkt->pts;
if (vs->new_start) {
vs->new_start = 0;
vs->duration = (double)(pkt->pts - vs->end_pts)