From b204c46d9d31af3d8beab359efde246d293cd676 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Tue, 11 Oct 2011 23:56:39 +0300 Subject: flvdec: Split out setting of numeric fields from storing metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/flvdec.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'libavformat/flvdec.c') diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index ad00c65e25..815618d5f8 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -287,17 +287,21 @@ 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(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_STRING) av_dict_set(&s->metadata, key, str_val, 0); } -- cgit v1.2.3 From 5e87222fd1dd57483c2a566e6643ca601b0e4e0c Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Wed, 12 Oct 2011 00:03:20 +0300 Subject: flvdec: Don't export metadata entries that aren't proper metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids writing these entries doubly if transcoding from flv to flv, since the muxer blindly writes any and all metadata keys set, in addition to the fixed fields that the muxer always writes. Signed-off-by: Martin Storsjö --- libavformat/flvdec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libavformat/flvdec.c') diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 815618d5f8..d2f3f51d28 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -296,6 +296,20 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst 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); -- cgit v1.2.3