Hi, experts,
I try to save raw PCM file with audio frame when decoding some MP4 file,
when it has done, i try to play saved raw PCM file it just noise.
These are my codes for save audio frame data to pcm buffer:
case LFW_PACKET_AUDIO:
int offset = 0;
int i = 0;
int ch = 0;
// FYI: env->a_sample_size = av_get_bytes_per_sample()
cur_sample_frame_size = env->frame_buf->nb_samples *
env->a_sample_size *
env->a_codec_ctx->channels;
// LFW_AUDIO_PCM_BUFFER_SIZE = 128 * 1024
env->pcm_buf_size = LFW_AUDIO_PCM_BUFFER_SIZE;
unsigned char *buff = av_mallocz(env->pcm_buf_size);
if (env->pcm_buf_size < cur_sample_frame_size) {
new_pcm_buf_size = round_up(cur_sample_frame_size, 4);
env->pcm_buf_size = new_pcm_buf_size;
av_free(buff);
buff = av_mallocz(env->pcm_buf_size);
}
for (i = 0; i < env->frame_buf->nb_samples; i++) {
for (ch = 0; ch < env->a_codec_ctx->channels; ch++) {
memcpy(buff + offset, env->frame_buf->data[ch] +
env->a_sample_size * i, env->a_sample_size);
offset += env->a_sample_size;
}
}
_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".