I apologize if this is the incorrect forum for my question, so please point me to the right place if it doesn't belong here.

I thought I understood how SMPTE timecode works, but I cannot seem to grasp the conversion from sample number to time/frame.

I have a tiny mp4 file (227 frames = 233,472 samples = ~5 seconds) that I read into a Python program using PyAV (Python bindings for ffmpeg). Looking at the data within Python I see that this short file has a sample rate of 44,100 Hz and I count 1024 samples for every frame. However, this math does not make sense.

(44100 samples/sec)/(1024 samples/frame) = 43.06641 frames/sec.

While I can't find where the fps value is in Python, I uploaded the file to https://www.onlinemp4parser.com/ and it tells me it's at 25 fps.

So none of these numbers make sense. Is it 43.06 frames per second or 25? Why would this not be a standard frame rate anyway? I need an accurate way of converting sample number to time.

Thanks for the help!

1 Answer 1


OK you are getting confused between frames as in "SMPTE" frames and audio buffers. The frames you are referring to are actually buffers. They are not 'vision' frames. 25fps refers to vision frames.

  • 44100 samples/second is correct.
  • 1024 samples per 'buffer'. (Note these will be 'stereo' samples - possibly interleaved depending on your input format)

Strictly speaking when dealing with audio samples, the term 'frame' refers to one sample 'group'. So if you are dealing with mono, this will be one sample. If you are dealing with stereo, this will be two samples (one left, one right). If you are dealing with a 16-channel poly-wav file, this will be 16 samples. Each of these unique groupings constitute one 'audio frame'.

From this point in, I will use the term frame in its correct meaning as 'audio frame'.

The simple way of converting frame number to time is:

  • ( FrameNumber ) / ( SampleRate ) which will give you a value in seconds.

So in your case, if you have 44100 Frames at a SampleRate of 44100 samples / second, you have one second of audio. For stereo audio, this will be 88200 samples.

Applications generally won't count 'sample numbers' as unless you are dealing with complete audio frames, this is fairly meaningless. So generally you count frames.

Your buffers in the question above refer to raw samples in the buffer, so you have to know how many samples in a frame. Usually with mp4 this will be two. So your 1024 sample buffer will contain 512 audio frames.

  • Many thanks, very helpful! In PyAV/FFMPEG the audio buffer is called a frame and so that caused some confusion. It seems you are saying that a frame is the set of samples collected at exactly the same instant, or what I call samples from both channels. So the 1024 samples are actually both channels interleaved and that's how you get 512 frames? Does that mean that the 44,100 samps/sec are spread across both channels? Why then are the total 233472 samples (adding all buffers) for 5.29 seconds if they are spread across two channels? Shouldn't there be twice the number of samples?
    – HonestMath
    Sep 27, 2019 at 16:19
  • I went back and looked through the audio structures in Python and for ffmpeg the audio is broken into channels. I don't know whether that's the case for all audio programs, but that's how it appears here. So for my case each audio buffer contains samples from only one channel which is why the 233,472 samples add up to ~5 seconds. Both channels added up would indeed be twice that. Many thanks again. I will add another question shortly about displaying samples if you would like to answer that as well!
    – HonestMath
    Sep 27, 2019 at 20:46
  • I'll try. Apologies - just got back after a long day so havn't quite got my head around your response yet. Sounds like Python is performing some jiggery-pokery with the samples. Yes the use of the word 'frame' is difficult because it gets re-interpreted across many different software applications. Yes, a frame is the set of samples collected at exactly the same instant. Yes, the 1024 samples are likely both channels interleaved. 44100 when used as a sampling rate is - strictly - 44100 audio frames per second. However, sampling rate is usually defined for mono channels.
    – Mark
    Sep 28, 2019 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.