]> git.sesse.net Git - ffmpeg/commitdiff
flvdec: read audio sample size and channels metadata
authorJustin Ruggles <justin.ruggles@gmail.com>
Thu, 21 Mar 2013 12:23:51 +0000 (08:23 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 28 Mar 2013 10:27:28 +0000 (06:27 -0400)
This is needed in order for the FLV demuxer not to detect a codec change when
using the "flv_metadata" option.

libavformat/flvdec.c

index 2821dd8c3477cf017bc7112ac71467c728fa2d81..2f68653882aa9a1e2bc9df2aea0c00f823d3057e 100644 (file)
@@ -400,7 +400,7 @@ 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 (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) {
             if (!strcmp(key, "duration"))
                 s->duration = num_val * AV_TIME_BASE;
             else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
@@ -422,6 +422,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
                 } else
                 if (!strcmp(key, "audiosamplerate") && acodec) {
                     acodec->sample_rate = num_val;
+                } else if (!strcmp(key, "audiosamplesize") && acodec) {
+                    acodec->bits_per_coded_sample = num_val;
+                } else if (!strcmp(key, "stereo") && acodec) {
+                    acodec->channels = num_val + 1;
+                    acodec->channel_layout = acodec->channels == 2 ?
+                                             AV_CH_LAYOUT_STEREO :
+                                             AV_CH_LAYOUT_MONO;
                 } else
                 if (!strcmp(key, "width") && vcodec) {
                     vcodec->width = num_val;