[FFmpeg-devel] [PATCH] fix muxing pcm in MOV when using avcodec_encode_audio()

Andrew Wason rectalogic at rectalogic.com
Thu Feb 9 16:39:09 CET 2012


Muxing pcm audio in MOV using avcodec_encode_audio() is failing
because avcodec_encode_audio() returns an incorrect packet size of 4
bytes. This can be reproduced by modifying the sample
ffmpeg/doc/examples/muxing.c to encode PCM, see attached patch
muxing-test.diff

I git bisected and commit 89ddff92a385 is the one that broke this. In
mov_write_header() if st->codec->frame_size <= 1 it sets it to 1. Then
avcodec_encode_audio() sets frame->nb_samples = avctx->frame_size, and
frame->nb_samples of 1 is used to compute a packet size of 4 bytes.

Attached patch mov-pcm-framesize.diff changes mov_write_header() to
leave st->codec->frame_size as is instead of forcing it to 1.

Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: muxing-test.diff
Type: application/octet-stream
Size: 744 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120209/0d644333/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mov-pcm-framesize.diff
Type: application/octet-stream
Size: 564 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120209/0d644333/attachment-0001.obj>


More information about the ffmpeg-devel mailing list