计算 MPEG 帧长度(毫秒)

发布于 2024-11-14 17:10:27 字数 891 浏览 4 评论 0原文

我在互联网上查找有关计算帧长度的信息,这很困难...我能够成功计算 MPEG-4、AAC 的帧长度(以毫秒为单位),使用:

frameLengthMs = mSamplingRate/1000

这有效,因为有一个AAC 上每帧的样本。对于 MPEG-1 或 MPEG-2 我很困惑。每帧有 1152 个样本,好吧,那我该怎么办呢? :P

框架示例:

MPEGDecoder(23069): mSamplesPerFrame: 1152
MPEGDecoder(23069): mBitrateIndex: 7
MPEGDecoder(23069): mFrameLength: 314
MPEGDecoder(23069): mSamplingRate: 44100
MPEGDecoder(23069): mMpegAudioVersion 3
MPEGDecoder(23069): mLayerDesc 1
MPEGDecoder(23069): mProtectionBit 1
MPEGDecoder(23069): mBitrateIndex 7
MPEGDecoder(23069): mSamplingRateFreqIndex 0
MPEGDecoder(23069): mPaddingBit 1
MPEGDecoder(23069): mPrivateBit 0
MPEGDecoder(23069): mChannelMode 1
MPEGDecoder(23069): mModeExtension 2
MPEGDecoder(23069): mCopyright 0
MPEGDecoder(23069): mOriginal 1
MPEGDecoder(23069): mEmphasis 0
MPEGDecoder(23069): mBitrate: 96kbps

I'm looking all over the Internet for information in regards to calculating the frame length and it's been hard... I was able to successfully calculate the frame length in ms of MPEG-4, AAC, using:

frameLengthMs = mSamplingRate/1000

This works since there is one sample per frame on AAC. For MPEG-1 or MPEG-2 I'm confused. There are 1152 samples per frame, ok, so what do I do with that? :P

Frame sample:

MPEGDecoder(23069): mSamplesPerFrame: 1152
MPEGDecoder(23069): mBitrateIndex: 7
MPEGDecoder(23069): mFrameLength: 314
MPEGDecoder(23069): mSamplingRate: 44100
MPEGDecoder(23069): mMpegAudioVersion 3
MPEGDecoder(23069): mLayerDesc 1
MPEGDecoder(23069): mProtectionBit 1
MPEGDecoder(23069): mBitrateIndex 7
MPEGDecoder(23069): mSamplingRateFreqIndex 0
MPEGDecoder(23069): mPaddingBit 1
MPEGDecoder(23069): mPrivateBit 0
MPEGDecoder(23069): mChannelMode 1
MPEGDecoder(23069): mModeExtension 2
MPEGDecoder(23069): mCopyright 0
MPEGDecoder(23069): mOriginal 1
MPEGDecoder(23069): mEmphasis 0
MPEGDecoder(23069): mBitrate: 96kbps

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

从来不烧饼 2024-11-21 17:10:27

MPEG 音频帧的持续时间是采样率和每帧样本数的函数。公式是:

frameTimeMs = (1000/SamplingRate) * SamplesPerFrame

在您的情况下,这将是

frameTimeMs = (1000/44100) * 1152

每帧产生约 26 毫秒。对于不同的采样率,您将获得不同的持续时间。关键是 MPEG 音频始终代表每帧固定数量的样本,但每个样本的持续时间取决于采样率。

The duration of an MPEG audio frame is a function of the sampling rate and the number of samples per frame. The formula is:

frameTimeMs = (1000/SamplingRate) * SamplesPerFrame

In your case this would be

frameTimeMs = (1000/44100) * 1152

Which yields ~26ms per frame. For a different sampling rate you would get a different duration. The key is MPEG audio always represents a fixed number of samples per frame, but the time duration of each sample is dependent on the sampling rate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文