[FFmpeg-devel] [PATCH] flvdec: Honor the "flv_metadata" option for the "datastream" metadata field

Martin Storsjö martin at martin.st
Mon Feb 19 13:30:46 EET 2024


On Fri, 9 Feb 2024, Martin Storsjö wrote:

> By default the option "flv_metadata" (internally using the field
> name "trust_metadata") is set to 0, meaning that we don't allocate
> streams based on information in the metadata, only based on
> actual streams we encounter. However the "datastream" metadata field
> still would allocate a subtitle stream.
>
> When muxing, the "datastream" field is added if either a data stream
> or subtitle stream is present - but the same metadata field is used
> to preemtively create a subtitle stream only. Thus, if the field
> was added due to a data stream, not a subtitle stream, the demuxer
> would create a stream which won't get any actual packets.
>
> If there was such an extra, empty subtitle stream, running
> avformat_find_stream_info still used to terminate within reasonable
> time before 3749eede66c3774799766b1f246afae8a6ffc9bb. After that
> commit, it no longer would terminate until it reaches the max
> analyze duration, which is 90 seconds for flv streams (see
> e6a084641aada7a2e4672172f2ee26642800a361,
> 24fdf7334d2bb9aab0abdbc878b8ae51eb57c86b and
> f58e011a1f30332ba824c155078ca701e29aef63).
>
> Before that commit (which removed the deprecated AVStream.codec), the
> "st->codecpar->codec_id = AV_CODEC_ID_TEXT", set within the demuxer,
> would get propagated into st->codec->codec_id by numerous
> avcodec_parameters_to_context(st->codec, st->codecpar), then further
> into st->internal->avctx->codec_id by update_stream_avctx within
> read_frame_internal in libavformat/utils.c (demux.c these days).
> ---
> libavformat/flvdec.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)

Will push soon if there are no objections.

// Martin


More information about the ffmpeg-devel mailing list