aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2024-02-09 12:56:16 +0200
committerMartin Storsjö <martin@martin.st>2024-02-20 16:49:51 +0200
commit58ffe0db4d50a5aa633d4efb9b53c879aedcd1e1 (patch)
treee7921d0cf777c8dc5d0600170359d0a6825da790
parent8c00fe64082d3ce10a1bbbe130e3afcc47d04f4b (diff)
downloadffmpeg-58ffe0db4d50a5aa633d4efb9b53c879aedcd1e1.tar.gz
flvdec: Honor the "flv_metadata" option for the "datastream" metadata field
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). Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/flvdec.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index e25b5bd163..d898341871 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -627,12 +627,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
else if (!strcmp(key, "audiodatarate") &&
0 <= (int)(num_val * 1024.0))
flv->audio_bit_rate = num_val * 1024.0;
- else if (!strcmp(key, "datastream")) {
- AVStream *st = create_stream(s, AVMEDIA_TYPE_SUBTITLE);
- if (!st)
- return AVERROR(ENOMEM);
- st->codecpar->codec_id = AV_CODEC_ID_TEXT;
- } else if (!strcmp(key, "framerate")) {
+ else if (!strcmp(key, "framerate")) {
flv->framerate = av_d2q(num_val, 1000);
if (vstream)
vstream->avg_frame_rate = flv->framerate;
@@ -654,6 +649,11 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
vpar->width = num_val;
} else if (!strcmp(key, "height") && vpar) {
vpar->height = num_val;
+ } else if (!strcmp(key, "datastream")) {
+ AVStream *st = create_stream(s, AVMEDIA_TYPE_SUBTITLE);
+ if (!st)
+ return AVERROR(ENOMEM);
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
}
}
}