MP3转码PCM

该博客主要探讨了MP3和AAC音频格式如何转码为PCM,重点关注了在转码过程中dst_nb_sample的计算,其中AAC的样本数大约为1024,而MP3的样本数为1152。提供了多个参考资料供深入学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

支持aac和mp3转码,主要是dst_nb_sample的计算,aac大致为1024,MP3为1152,

static int dst_nb_samples = 0;
#define SWR
int encoding(const char *in_file, const char *out_file)
{
    //注册所有的工具
    av_register_all();
 
    AVFormatContext *fmt_ctx = NULL;
    AVCodecContext  *cod_ctx = NULL;
    AVCodec         *cod   = NULL;
	int nRet;
 
    //分配一个avformat
    fmt_ctx = avformat_alloc_context();
    if (fmt_ctx == NULL)
        printf("alloc fail");
 
    //打开文件,解封装
    if (avformat_open_input(&fmt_ctx, in_file, NULL, NULL) != 0)
        printf("open fail");
 
    //查找文件的相关流信息
    if (avformat_find_stream_info(fmt_ctx, NULL) < 0)
        printf("find stream fail");
 
    //输出格式信息
    av_dump_format(fmt_ctx, 0, in_file, 0);
 
    //查找解码信息
    int stream_index = -1;
    for (int i = 0; i < fmt_ctx->nb_streams; i++)
        if (fmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            stream_index = i;
            break;
        }
 
    if (st
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值