[FFmpeg-devel] [PATCH 2/2] avformat/hls: Fix probing mpegts audio streams that use probing

Hendrik Leppkes h.leppkes at gmail.com
Sat Nov 5 19:27:23 EET 2016


On Sat, Nov 5, 2016 at 5:39 PM, Anssi Hannula <anssi.hannula at iki.fi> wrote:
> 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>
> ---
>  libavformat/hls.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 6fb652c..8527f33 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -1950,6 +1950,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,8 +1974,11 @@ 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)
> @@ -1981,6 +1986,11 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
>                                              pls->ctx->streams[pls->pkt.stream_index]->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);
> +

A better solution would be checking
ist->internal->need_context_update, and also setting this in the
output stream when you copy params over, so the generic code knows
things changed.

- Hendrik


More information about the ffmpeg-devel mailing list