OSDN Git Service

flvdec: Remove AVFMTCTX_NOHEADER if both flags and metadata claim 1 stream
authorAsad Mehmood <asad78611@googlemail.com>
Wed, 7 Sep 2011 22:18:07 +0000 (23:18 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 7 Sep 2011 22:26:28 +0000 (00:26 +0200)
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.

libavformat/flvdec.c

index 263a843..ef487a6 100644 (file)
@@ -275,6 +275,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);
     }