博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AAC---ffmpeg转码 参考/dec/sample/transcode_aac.c示例代码
阅读量:3919 次
发布时间:2019-05-23

本文共 2550 字,大约阅读时间需要 8 分钟。

transcode_aac流程:

init_resampler重采样初始化av_audio_fifo_alloc(output_codec_context->sample_fmt,output_codec_context->channels, 1)	//	只要一帧Sample bufferavformat_write_header(output_format_context, NULL))while (1) {
/* Use the encoder's desired frame size for processing. */ const int output_frame_size = output_codec_context->frame_size; int finished = 0; /* Make sure that there is one frame worth of samples in the FIFO * buffer so that the encoder can do its work. * Since the decoder's and the encoder's frame size may differ, we * need to FIFO buffer to store as many frames worth of input samples * that they make up at least one frame worth of output samples. */ while (av_audio_fifo_size(fifo) < output_frame_size) {
/* Decode one frame worth of audio samples, convert it to the * output sample format and put it into the FIFO buffer. */ if (read_decode_convert_and_store(fifo, input_format_context, input_codec_context, output_codec_context, resample_context, &finished)) goto cleanup; /* If we are at the end of the input file, we continue * encoding the remaining audio samples to the output file. */ if (finished) break; } /* If we have enough samples for the encoder, we encode them. * At the end of the file, we pass the remaining samples to * the encoder. */ while (av_audio_fifo_size(fifo) >= output_frame_size || (finished && av_audio_fifo_size(fifo) > 0)) /* Take one frame worth of audio samples from the FIFO buffer, * encode it and write it to the output file. */ if (load_encode_and_write(fifo, output_format_context, output_codec_context)) goto cleanup; /* If we are at the end of the input file and have encoded * all remaining samples, we can exit this loop and finish. */ if (finished) {
int data_written; /* Flush the encoder as it may have delayed frames. */ do {
data_written = 0; if (encode_audio_frame(NULL, output_format_context, output_codec_context, &data_written)) goto cleanup; } while (data_written); break; } } /* Write the trailer of the output file container. */

转载地址:http://cbhrn.baihongyu.com/

你可能感兴趣的文章
Volatile-1.保证可见性
查看>>
Volatile-2.不保证原子性
查看>>
剑指 Offer 25. 合并两个排序的链表
查看>>
剑指 Offer 26. 树的子结构
查看>>
剑指 Offer 27. 二叉树的镜像
查看>>
剑指 Offer 29. 顺时针打印矩阵
查看>>
剑指 Offer 31. 栈的压入、弹出序列
查看>>
剑指 Offer 32 - III. 从上到下打印二叉树 III
查看>>
剑指 Offer 33. 二叉搜索树的后序遍历序列
查看>>
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
查看>>
剑指 Offer 68 - II. 二叉树的最近公共祖先
查看>>
剑指 Offer 18. 删除链表的节点
查看>>
剑指 Offer 32 - II. 从上到下打印二叉树 II
查看>>
杭电oj-2011 多项式求和 C++
查看>>
杭电oj-2014 青年歌手大奖赛_评委会打分 C++
查看>>
杭电oj-2015 偶数求和 C++
查看>>
杭电oj-2016 数据的交换输出 C++
查看>>
杭电oj-2017 字符串统计 C++
查看>>
杭电oj-2018 母牛的故事 C++
查看>>
Educational Codeforces Round 87 (Rated for Div. 2)----题目+题解(A、B)
查看>>