[Libav-user] How to split AVFrame to smaller AVFrames
nfxjfg at googlemail.com
Fri Jun 20 14:29:51 CEST 2014
On Fri, 20 Jun 2014 02:14:43 +0000
Neerav Patel <neeravpatel at hotmail.com> wrote:
> I am trying to use avcodec_encode_audio2 and I can see that the nb_samples of the decoded data is 22050, but the encode context only has a frame size of 1152. I am assuming I need to copy the AVFrame to a smaller AVFrame so I can pass it in. How does one copy a portion of a AVFrame. Do I use av_samples_copy? how do I use that and allocate a AVFrame from it?
> Any help would be greatly appreciated.
> I have tried:uint8_t * data = ( decodeAudio.data );
> AVFrame * tempAudio = av_frame_alloc();
> tempAudio.data = data;
> tempAudio.nb_samples = 1152;
> But I dont think that is right, as I am not copying any of the other fields...
> Thanks in advance
Allocate a frame, allocate the audio data with av_frame_get_beffer()
(you must set the format first), then use av_samples_copy().
More information about the Libav-user