在AAC中转换后ffmpeg音频文件错误 [英] ffmpeg wrong audio file after conversion in AAC

查看:377
本文介绍了在AAC中转换后ffmpeg音频文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用FFmpeg进行acc编码时遇到问题. 我有带有AAC音频的au mp4文件.我试图用ffmpeg复制音频. 在源mp4文件中,第一个音频噪声出现在0.30秒处. 使用ffmpeg -i inputfile.mp4 -c:a copy outputfile.aac进行转换后,生成的文件错误,第一个音频噪声出现在0.32秒处. 文件的持续时间也不一样.

I have a problem with encoding in acc with FFmpeg. I have au mp4 file with aac audio. I tried to copy the audio with ffmpeg. In the source mp4 file, the first audio noise appears at 0.30 seconds. After conversion using ffmpeg -i inputfile.mp4 -c:a copy outputfile.aac, the resulting file is wrong, the first audio noise appears at 0.32 seconds. The duration of the file is not the same too.

当我强制将编码器设置为libfaac时,它可以工作,但是文件太大.

When i force the encoder to libfaac, it works but the file is too big.

那么,为什么在使用默认编码器(aac,libfdk_aac)时它不起作用? 请注意,当我从audacity转换时,也会出现相同的情况.

So why it doesn't work when the default encoder is used (aac, libfdk_aac) ? Note that the same thing appears when i convert from audacity.

非常感谢

推荐答案

音频流中有一个填充帧,解码器需要此填充帧才能解码第一帧.这是MDCT音频编解码器(如AAC)的技术要求.在定时采样容器(如MP4/MKV)中,该第一帧的显示时间戳为负.在原始AAC比特流中,该第一帧被天真的解码.每个帧有1024个样本,因此持续时间为21-23毫秒.您时间上的差异是由于该偏移量造成的.重新包装到M4A之类的容器中,以免发生这种情况.

There is a padding frame in the audio stream which is needed by the decoder in order to decode the first frame. This is technical requirement of MDCT audio codecs like AAC. In a timed sample container like MP4/MKV, that first frame has a negative presentation timestamp. In a raw AAC bitstream, that first frame is naively decoded. Each frame has 1024 samples and so has a duration of 21-23 ms. Your difference in timing is due to that offset. Rewrap to a container like M4A to avoid this.

Apple :

AAC要求数据超出源PCM音频样本的范围,以便 由于音频的性质,可以正确编码和解码音频样本 编码算法. AAC编码使用连续的变换 2048个音频样本集,每1024个音频样本应用一次 (重叠).为了正确解码音频,两种格式都可以转换为 需要1024个音频采样周期.因此,编码器添加了 在第一个真实"音频样本之前,至少需要1024个静音样本, 并经常添加更多.这被称为启动" 样本"或编码器延迟".

AAC requires data beyond the source PCM audio samples in order to correctly encode and decode audio samples due to the nature of the encoding algorithm. AAC encoding uses a transform over consecutive sets of 2048 audio samples, applied every 1024 audio samples (overlapped). For correct audio to be decoded, both transforms for any period of 1024 audio samples are needed. For this reason, encoders add at least 1024 samples of silence before the first ‘true’ audio sample, and often add more. This is called variously "priming", "priming samples", or "encoder delay".

缺少对编码器延迟和余数的明确表示 样本不是AAC编码所独有的问题.使用MPEG-4和 ADTS/MPEG-2比特流和文件容器,仍然没有 对于编码器延迟或 其余样本. MP3还具有这些数据依赖性和延迟 比特流,以及专用编解码器(例如AC-3等).

The lack of explicit representation for encoder delay and remainder samples is not a problem unique to AAC encoding. With MPEG-4 and ADTS/MPEG-2 bitstreams and file containers, there is still no satisfactory, explicit representation for either the encoder delay or remainder samples. MP3 also has these data dependencies and delays in its bitstream, as do proprietary codecs such as AC-3 and others.

这篇关于在AAC中转换后ffmpeg音频文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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