[Libav-user] converting pcm sample rate
Michael Niedermayer
michaelni at gmx.at
Fri Nov 4 16:58:25 CET 2011
On Wed, Nov 02, 2011 at 05:48:16PM +0700, Anton Adamansky wrote:
> Hello!
>
> I'm converting sample rate for raw pcm buffer:
>
> input: 2ch, in_srate: 22050 sample: 16bits
> output: 2ch, out_srate: 44100 sample: 16bits
>
> So I'm using swr_convert() function:
>
> int out_samples =
> swr_convert(swr_ctx, buff_in, resampled_size /
> (out_channels * 2),
> buff_out, input_pcm_len /
> (input_pcm_channels * 2));
>
> I've got as result samples buffer with rate of 44100 and duration:
> (out_samples * 2 / out_srate) as half of original samples duration.
>
> How can i convert this pcm buffer with preserved samples duration, so:
> (out_samples * 2 / out_srate) === (in_samples * 2 / in_srate) ?
>
> What I'm missing?
you can pass 0,NULL as input to swr_convert() to flush the samples at
the end out.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111104/783186ac/attachment.asc>
More information about the Libav-user
mailing list