audio - 在AAC中转换后ffmpeg错误的音频文件

标签 audio ffmpeg aac

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

当我强制编码器使用 libfaac 时,它可以工作,但文件太大。

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

非常感谢

最佳答案

音频流中有一个填充帧,解码器需要它来解码第一帧。这是 AAC 等 MDCT 音频编解码器的技术要求。在像 MP4/MKV 这样的定时样本容器中,第一帧的呈现时间戳为负。在原始 AAC 比特流中,第一帧被天真地解码。每帧有 1024 个样本,因此持续时间为 21-23 毫秒。您的时间差异是由于该偏移量。重新包装到 M4A 之类的容器中以避免这种情况。

背景,来自 Apple :

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”.





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.

关于audio - 在AAC中转换后ffmpeg错误的音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42410479/

相关文章:

ios - 在 iOS 上从 RIFF 容器读取 AAC 音频

amazon-web-services - FFMPEG 在 AWS Lambda 中失败

java - 使用 Java Sound API 通过 UDP 发送语音

audio - 如何计算 ffmpeg astats 波峰因数

c++ - 尝试通过 RTP cpp 使用 ffmpeg 库发送视频流时丢包

ffmpeg如何缩短音量范围

android - 使用 Android NDK 时是否可以使用原生 AAC 解码器?

android - 图片+语音的视频编码器(手机支持)

windows - 将输出音频发送到特定程序

ffmpeg - 如何在 CMake 中检测 ffmpeg 与 libav?