diff mbox

[FFmpeg-devel,v2,15/18] avformat/movenc: mov_write_audio_tag can write the proper number of channels, not the hardcoded 2

Message ID 1472643361-10118-16-git-send-email-erkki.seppala.ext@nokia.com
State Superseded
Headers show

Commit Message

erkki.seppala.ext@nokia.com Aug. 31, 2016, 11:35 a.m. UTC
It does it only when the chnl box is to be written. The specification
for the chnl box (ISO 14496-12) requires proper number of channels to be
written here is it is used, and without the proper number of channels
available it becomes tricky to parse the data, as the number of channels
in this box comes from that value.

Signed-off-by: Erkki Seppälä <erkki.seppala.ext@nokia.com>
Signed-off-by: OZOPlayer <OZOPL@nokia.com>
---
 libavformat/movenc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6e179ef..bbd176f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1031,7 +1031,13 @@  static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
                 avio_wb16(pb, 16);
             avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
         } else { /* reserved for mp4/3gp */
-            avio_wb16(pb, 2);
+            /* parsing chln box requires the proper number of channels having been
+               written into the audio header */
+            if (av_stream_get_side_data(track->st, AV_PKT_DATA_AUDIO_TRACK_CHANNEL_LAYOUT,
+                                        NULL))
+                avio_wb16(pb, track->par->channels);
+            else
+                avio_wb16(pb, 2);
             avio_wb16(pb, 16);
             avio_wb16(pb, 0);
         }