[FFmpeg-devel] [PATCH] asfenc: too many payloads in a packet

Aaron Graham aaron at aarongraham.com
Tue May 13 00:26:11 CEST 2014


In the ASF specification:
http://www.microsoft.com/en-us/download/details.aspx?id=14995

the section on Multiple payloads (5.2.3.3) describes the bit fields used to
specify payload length type and number of payloads. The number of payloads
field is a 6-bit field, meaning a packet can hold a maximum of 63 payloads.

asfenc.c was not honoring this, and if more than 63 payloads would fit in a
packet, the "number of payloads" field would overflow into the "payload
length type" field, causing parsing errors in ffplay.

You can reproduce this with any AAC file that has several seconds of
silence in the beginning (lots of very small AAC frames). Use this ffmpeg
command:

$ ffmpeg -i silence.m4a -acodec copy silence.asf

Note that ffplay will get lots of errors.

Anyway, here's a patch to fix the problem:

diff -ur ffmpeg-mine/libavformat/asfenc.c ffmpeg-2.2.2/libavformat/asfenc.c
--- ffmpeg-mine/libavformat/asfenc.c    2014-05-12 15:23:12.093259469 -0700
+++ ffmpeg-2.2.2/libavformat/asfenc.c   2014-05-04 21:14:52.000000000 -0700
@@ -34,7 +34,6 @@

 #define ASF_INDEXED_INTERVAL    10000000
 #define ASF_INDEX_BLOCK         (1<<9)
-#define ASF_PAYLOADS_PER_PACKET 63

 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
 #define ASF_PACKET_ERROR_CORRECTION_FLAGS          \
@@ -819,8 +818,6 @@
             flush_packet(s);
         else if (asf->packet_size_left <=
(PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + PACKET_HEADER_MIN_SIZE + 1))
             flush_packet(s);
-        else if (asf->packet_nb_payloads == ASF_PAYLOADS_PER_PACKET)
-            flush_packet(s);
     }
     stream->seq++;
 }


More information about the ffmpeg-devel mailing list