diff mbox

[FFmpeg-devel] avformat/hlsenc: Fixed initial setting for end_pts

Message ID 1511759038-31312-1-git-send-email-kjeyapal@akamai.com
State Accepted
Commit d5d2632e3a0f1709290834fd35457cd05cf48bc8
Headers show

Commit Message

Jeyapal, Karthick Nov. 27, 2017, 5:03 a.m. UTC
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.
---
 libavformat/hlsenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Steven Liu Nov. 27, 2017, 5:16 a.m. UTC | #1
2017-11-27 13:03 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
> 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.
> ---
>  libavformat/hlsenc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 30ccf73..6997a5c 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)
> --
> 1.9.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

LGTM,

Wait the reporter feedback


Thanks
Steven Liu Nov. 28, 2017, 12:09 p.m. UTC | #2
2017-11-27 13:16 GMT+08:00 Steven Liu <lingjiujianke@gmail.com>:
> 2017-11-27 13:03 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
>> 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.
>> ---
>>  libavformat/hlsenc.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 30ccf73..6997a5c 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)
>> --
>> 1.9.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> LGTM,
>
> Wait the reporter feedback
>
>
> Thanks

pushed


Thanks
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 30ccf73..6997a5c 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)