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

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

问题描述

我在使用 FFmpeg 进行 acc 编码时遇到问题.我有 au mp4 文件和 aac 音频.我试图用 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) 时它不起作用?请注意,当我从大胆转换时会出现同样的情况.

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.

非常感谢

推荐答案

音频流中有一个填充帧,解码器需要它来解码第一帧.这是 AAC 等 MDCT 音频编解码器的技术要求.在像 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天全站免登陆