如何使用配置文件FF_PROFILE_AAC_LOW将音频编码到AAC [英] How to encode audio to AAC with profile FF_PROFILE_AAC_LOW

查看:1390
本文介绍了如何使用配置文件FF_PROFILE_AAC_LOW将音频编码到AAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过以下设置将配置文件 FF_PROFILE_AAC_LOW 的音频编码到AAC。

I try to encode audio to AAC with profile FF_PROFILE_AAC_LOW by the following settings.

oc_cxt->profile = FF_PROFILE_AAC_LOW;

同样从 av_dump_format 的输出得到这个

Metadata:
encoder         : Lavf57.36.100
Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s

输出不同。一切都可以,除了输出是 AAC ,而不是 AAC(LC)。通过使用 ffprobe 来检测,输出信息是

But the output is different. Everything is ok, except the output is AAC, not AAC (LC). By using ffprobe to detect, the output information is

$ ffprobe o.m4a
...
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 195 kb/s (default)
...

AAC(LC)

但是从命令行, ffmpeg 可以生成 AAC( LC)输出。

But from the command line, ffmpeg can generate AAC (LC) output. Below is a small test.

$ ffmpeg -f lavfi -i aevalsrc="sin(440*2*PI*t):d=5" aevalsrc.m4a
$ ffprobe aevalsrc.m4a
...
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
...

可以选择 FF_PROFILE_LOW 来获取 AAC(LC)输出?

推荐答案

这是由我没注意到的新的ffmpeg api引起的。

This was caused by new ffmpeg api which I didn't notice.

在$ $ c $之后,额外的数据需要复制回 AVStream-> codecpar-> extradata C> avcodec_open2 。之后,ffprobe可以检测输出是我需要的格式, AAC(LC)

The extra data need to copy back to AVStream->codecpar->extradata after avcodec_open2. After that, the ffprobe can detect output is the format I need, AAC (LC).

以下是 ffmpeg.c 的代码段

if (!ost->st->codecpar->extradata && avctx->extradata) {
    ost->st->codecpar->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
    if (!ost->st->codecpar->extradata) {
        av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
        exit_program(1);
    }    
    ost->st->codecpar->extradata_size = avctx->extradata_size;
    memcpy(ost->st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
}

希望有人使用最新版本的ffmpeg(3。 x)。

Hopefully it would be helpful to anyone use the latest version of ffmpeg (3.x).

这篇关于如何使用配置文件FF_PROFILE_AAC_LOW将音频编码到AAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆