[FFmpeg-devel] libavformat/hlsenc: only initialize the "start_pts" value if the incoming packet is a video packet.

Submitted by Boris Nagels on Nov. 1, 2018, 9:32 a.m.

Details

Message ID 54CFAA4E-478B-41A4-96EC-C937B4C1CF97@focusware.nl
State New
Headers show

Commit Message

Boris Nagels Nov. 1, 2018, 9:32 a.m.
The packet type should be checked before the start value is assigned. For example, if the first packet to arrive is an audio packet, the value of start-pts is in the timebase units of the audio stream. This will cause the stream to be split on every I-frame of the video stream since the pts value of the audio stream is typically much smaller than the pts value of the video stream.
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 902896ef81..85167761b9 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2201,7 +2201,7 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         end_pts = init_list_dur + after_init_list_dur ;
     }
 
-    if (vs->start_pts == AV_NOPTS_VALUE) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && vs->start_pts == AV_NOPTS_VALUE) {
         vs->start_pts = pkt->pts;
         vs->end_frame = st->nb_frames;
     }