[Libav-user] How to fill an AVFrame with audio data

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] How to fill an AVFrame with audio data

Denis Gottardello

 

Hi, this is a function taken from an ffmpeg example

How can I fill the frame with my data buffer (const uchar* data, int Length)?

 

***************************************

AVFrame *frame = OutputStreamAudio.pAVFrameTemp;

int j, i, v;

int16_t *q = (int16_t*)frame->data[0];

 

/* check if we want to generate more frames */

if (av_compare_ts(OutputStreamAudio.next_pts, OutputStreamAudio.pAVCodecContext->time_base, STREAM_DURATION, (AVRational){ 1, 1 }) >= 0) return NULL;

 

for (j = 0; j <frame->nb_samples; j++) {

v = (int)(sin(OutputStreamAudio.t) * 10000);

for (i = 0; i < OutputStreamAudio.pAVCodecContext->channels; i++) *q++ = v;

OutputStreamAudio.t += OutputStreamAudio.tincr;

OutputStreamAudio.tincr += OutputStreamAudio.tincr2;

}

 

frame->pts = OutputStreamAudio.next_pts;

OutputStreamAudio.next_pts += frame->nb_samples;

 

return frame;

***************************************

 

Regards


--

+39.347.4070897

http://www.labcsp.com

http://www.denisgottardello.it

GMT+1

Skype: mrdebug


_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".