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

Erkki Seppälä erkki.seppala.ext at nokia.com
Wed Aug 31 14:35:58 EEST 2016


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 at nokia.com>
Signed-off-by: OZOPlayer <OZOPL at nokia.com>
---
 libavformat/movenc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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);
         }
-- 
2.7.4



More information about the ffmpeg-devel mailing list