summaryrefslogtreecommitdiff
path: root/libavformat/flvdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r--libavformat/flvdec.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 828d25fda3..7efe156666 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -276,17 +276,35 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
+ if (amf_type == AMF_DATA_TYPE_NUMBER) {
+ if (!strcmp(key, "duration"))
+ s->duration = num_val * AV_TIME_BASE;
+ else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
+ 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;
+ }
+
+ if (!strcmp(key, "duration") ||
+ !strcmp(key, "filesize") ||
+ !strcmp(key, "width") ||
+ !strcmp(key, "height") ||
+ !strcmp(key, "videodatarate") ||
+ !strcmp(key, "framerate") ||
+ !strcmp(key, "videocodecid") ||
+ !strcmp(key, "audiodatarate") ||
+ !strcmp(key, "audiosamplerate") ||
+ !strcmp(key, "audiosamplesize") ||
+ !strcmp(key, "stereo") ||
+ !strcmp(key, "audiocodecid"))
+ return 0;
+
if(amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
av_dict_set(&s->metadata, key, str_val, 0);
} else if(amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(str_val, sizeof(str_val), "%.f", num_val);
av_dict_set(&s->metadata, key, str_val, 0);
- if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
- else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
- 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