[FFmpeg-cvslog] flvdec: Remove AVFMTCTX_NOHEADER if both flags and metadata claim 1 stream

Asad Mehmood git at videolan.org
Wed Sep 21 21:08:29 CEST 2011


ffmpeg | branch: release/0.8 | Asad Mehmood <asad78611 at googlemail.com> | Wed Sep  7 23:18:07 2011 +0100| [64556c200ee372130bcebb79f0fb37a9aa46f9c5] | committer: Michael Niedermayer

flvdec: Remove AVFMTCTX_NOHEADER if both flags and metadata claim 1 stream

If there is only 1 stream in an flv avformat_find_stream_info will continually
read until probesize is reached. This should stop it reading if the metadata
also claims there to be 1 stream.
(cherry picked from commit bcc531f04a0590732d42da133c11c138e8d08b59)

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

 libavformat/flvdec.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 4fb562f..a2a3c5c 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -269,6 +269,10 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
                 vcodec->bit_rate = num_val * 1024.0;
             else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0))
                 acodec->bit_rate = num_val * 1024.0;
+        } else if(amf_type == AMF_DATA_TYPE_OBJECT){
+            if(s->nb_streams==1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))){
+                s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object
+            }
         } else if (amf_type == AMF_DATA_TYPE_STRING)
             av_dict_set(&s->metadata, key, str_val, 0);
     }



More information about the ffmpeg-cvslog mailing list