[FFmpeg-devel] Calculating audio frame rate

Eran Kornblau eran.kornblau at kaltura.com
Tue Mar 3 11:48:31 EET 2020


> 
> 
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Hendrik Leppkes
> Sent: Tuesday, March 3, 2020 11:08 AM
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] Calculating audio frame rate
> 
> On Tue, Mar 3, 2020 at 8:22 AM Eran Kornblau <eran.kornblau at kaltura.com> wrote:
> >
> > Hi all,
> >
> > First, I apologize for asking a question not directly related to ffmpeg development, but hope you can still help me...
> >
> > I'm looking for some code to calculate the frame rate of audio, based 
> > on parameters such as the codec id, sampling rate, channels, codec private data etc.
> > For example, if the codec is AAC and the sampling rate is 44.1KHz, the 
> > frame rate would be 44100/1024= ~43 fps (assuming each frame has 1024 
> > samples, not 960)
> >
> > Has anyone ever written/bumped into something that implements this across multiple codecs?
> >
> 
> The frame size of audio codecs is pretty much only dependent on the codec itself, which means you would need to basically hard-code this for every codec you care about.
> Ultimately I wonder however, when does this information really matter?

Thanks Hendrik. 

What I'm trying to do is to estimate the final bitrate of the stream, that includes the muxing overhead.
I'm generating an HLS stream, and would like to output the right 'bandwidth' attribute for the master m3u8.
For example, when using MPEG-TS container I may need to add up to 10% to the original bitrate, in order to get 
the 'real' bitrate of the segments, when using fMP4 it's much less.

I don't have the audio/video frames at hand, and would like to calculate this estimate based on the media info.
For example, with video, I'm assuming on average a padding of 1/2 MPEG-TS packet per frame, to that I'm adding 
the size of the PES header and multiplying everything by 188/184 to account for the MPEG-TS header.
So, I wrote some formula that depends on - net bitrate, frame rate and segment duration.
The audio frame rate probably has a tiny effect here, but if there is an easy solution for it, I rather add it.

Eran
> 
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel&data=02%7C01%7Ceran.kornblau%40kaltura.com%7C41e1faaab1f94cd1a5dc08d7bf538194%7C0c503748de3f4e2597e26819d53a42b6%7C0%7C0%7C637188237699697648&sdata=7ISLTWU8u7IWXG1rdMVos%2BvzwyWhP%2B%2FPcegXFHHJSUM%3D&reserved=0
> 
> To unsubscribe, visit link above, or email ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list