[FFmpeg-devel] Devel question : how to calculate frame_size in audio encoder (adpcm_encode_init)

Vladimir Voroshilov voroshil
Wed Oct 3 22:42:03 CEST 2007

2007/10/4, Tom Van Braeckel <tomvanbraeckel at gmail.com>:
> Hi guys, we (at amv-codec-tools) are working on the adpcm_ima_amv encoder
> for the AMV format but have a question on how to access the video frame rate
> from the audio encoder.. or how to set the frame_size correctly.

I (as member of thosse project) want to add several words to info below.

> We should calculate the audio frame_size by calculating sample_rate /
> frame_rate right ?
> - First of all, is adpcm_encode_init the right place to calculate the number
> of samples (frame_size) ?
> Our code looks like this:
> avctx->frame_size =
> av_rescale(avctx->sample_rate,avctx->time_base.num,avctx->time_base.den);
> break;
> But this doesn't work because avctx->time_base = 1/22050 instead of 1/16 (if
> the video is 16 fps).

Actually, exact working (but, imho, hackish) string (in our
amv_write_header routine) is:

Audio and video frames in AMV files should be interleaved on-by-one.
We can archive this only by setting audio frame_size using video frame
rate value
(along with proper interleaving routine) to ensure that each video
frame will corresponds
one audio frame.

> - Second question is how we should correctly  access the frame rate from
> adpcm.c (in libavcodec) ?

Video frame rate from audio codec or more clean solution exists except
setting audio frame_size in audio encoder init routine?

Vladimir Voroshilov     mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719

More information about the ffmpeg-devel mailing list