[FFmpeg-cvslog] avformat/hls: Fix probing mpegts audio streams that use probing

Anssi Hannula git at videolan.org
Mon Nov 7 19:11:36 EET 2016


ffmpeg | branch: release/3.2 | Anssi Hannula <anssi.hannula at iki.fi> | Sat Nov  5 18:05:31 2016 +0200| [fc20e300580cf3f9f73fa15c4a782a4a4a1fa2cf] | committer: Anssi Hannula

avformat/hls: Fix probing mpegts audio streams that use probing

Commit 04964ac311abe670f ("avformat/hls: Fix missing streams in some
cases with MPEG TS") caused a regression where subdemuxer streams that
use probing (e.g. dts/eac3/mp2 in mpegts) no longer get probed properly.

This is because the codec parameters from the subdemuxer stream, once
probed, are not passed on to the main stream.

Fix that by updating the codec parameters if the codec id changes.

Signed-off-by: Anssi Hannula <anssi.hannula at iki.fi>
(cherry picked from commit 3d2f636497f7d4404921bf77387381fa6c98d1b3)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fc20e300580cf3f9f73fa15c4a782a4a4a1fa2cf
---

 libavformat/hls.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 6fb652c..ce52bf5 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1536,6 +1536,8 @@ static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls
         avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
     else
         avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
+
+    st->internal->need_context_update = 1;
 }
 
 /* add new subdemuxer streams to our context, if any */
@@ -1950,6 +1952,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
     /* If we got a packet, return it */
     if (minplaylist >= 0) {
         struct playlist *pls = c->playlists[minplaylist];
+        AVStream *ist;
+        AVStream *st;
 
         ret = update_streams_from_subdemuxer(s, pls);
         if (ret < 0) {
@@ -1972,15 +1976,23 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
             return AVERROR_BUG;
         }
 
+        ist = pls->ctx->streams[pls->pkt.stream_index];
+        st = pls->main_streams[pls->pkt.stream_index];
+
         *pkt = pls->pkt;
-        pkt->stream_index = pls->main_streams[pls->pkt.stream_index]->index;
+        pkt->stream_index = st->index;
         reset_packet(&c->playlists[minplaylist]->pkt);
 
         if (pkt->dts != AV_NOPTS_VALUE)
             c->cur_timestamp = av_rescale_q(pkt->dts,
-                                            pls->ctx->streams[pls->pkt.stream_index]->time_base,
+                                            ist->time_base,
                                             AV_TIME_BASE_Q);
 
+        /* There may be more situations where this would be useful, but this at least
+         * handles newly probed codecs properly (i.e. request_probe by mpegts). */
+        if (ist->codecpar->codec_id != st->codecpar->codec_id)
+            set_stream_info_from_input_stream(st, pls, ist);
+
         return 0;
     }
     return AVERROR_EOF;



More information about the ffmpeg-cvslog mailing list