[FFmpeg-devel] [PATCH]Fix AC3-in-avi for the remaining cases

Carl Eugen Hoyos cehoyos
Sat Jan 1 21:03:20 CET 2011


Hi!

Current svn produces avi files that don't playback on any player when muxing 
AC3 with 32kHz/320kB, 32kHz/384kB and 44.1kHz/384kB.
I believe Justin suggested to set blkalign to maximum frame size (first 
patch).
An alternative is to just fix the failing cases (second patch).

Opinions?

Please comment, Carl Eugen
-------------- next part --------------
Index: libavformat/riff.c
===================================================================
--- libavformat/riff.c	(revision 26183)
+++ libavformat/riff.c	(working copy)
@@ -370,12 +370,10 @@
         av_log(enc, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) and actually stored (%d) differ\n", enc->bits_per_coded_sample, bps);
     }
 
-    if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_AC3) {
+    if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
         blkalign = enc->frame_size; //this is wrong, but it seems many demuxers do not work if this is set correctly
         //blkalign = 144 * enc->bit_rate/enc->sample_rate;
-        //For high bitrate AC-3, set blkalign to maximum bytes per frame value
-        //to allow playback on WMP and MPlayer
-        if (enc->bit_rate > 384000)
+    } else if (enc->codec_id == CODEC_ID_AC3) {
             blkalign = 3840;
     } else if (enc->codec_id == CODEC_ID_ADPCM_G726) { //
         blkalign = 1;
-------------- next part --------------
Index: libavformat/riff.c
===================================================================
--- libavformat/riff.c	(revision 26183)
+++ libavformat/riff.c	(working copy)
@@ -375,7 +375,7 @@
         //blkalign = 144 * enc->bit_rate/enc->sample_rate;
         //For high bitrate AC-3, set blkalign to maximum bytes per frame value
         //to allow playback on WMP and MPlayer
-        if (enc->bit_rate > 384000)
+        if (enc->bit_rate > 384000 || enc->sample_rate == 44100 && enc->bit_rate > 320000 ||enc->sample_rate == 32000 && enc->bit_rate > 256000)
             blkalign = 3840;
     } else if (enc->codec_id == CODEC_ID_ADPCM_G726) { //
         blkalign = 1;



More information about the ffmpeg-devel mailing list