IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Calculating the duration
Sebastian Mares
post Nov 3 2003, 20:14
Post #1





Group: Members
Posts: 3538
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



Hello!

I have a small question about calculating the duration of an MPEG Audio file.
At the moment, I use the following formula to calculate the play time in seconds:


MPEG 1.0 Layer I:
Seconds = Frame Number * 384 / Sampling Rate

MPEG 1.0 Layer II:
Seconds = Frame Number * 1152 / Sampling Rate

MPEG 1.0 Layer III:
Seconds = Frame Number * 1152 / Sampling Rate

MPEG 2.0 Layer I:
Seconds = Frame Number * 192 / Sampling Rate

MPEG 2.0 Layer II:
Seconds = Frame Number * 1152 / Sampling Rate

MPEG 2.0 Layer III:
Seconds = Frame Number * 576 / Sampling Rate

MPEG 2.5 Layer I:
Seconds = Frame Number * 192 / Sampling Rate

MPEG 2.5 Layer II:
Seconds = Frame Number * 1152 / Sampling Rate

MPEG 2.5 Layer III:
Seconds = Frame Number * 576 / Sampling Rate


Is the above method correct?

Regards,
Sebastian Mares

This post has been edited by Sebastian Mares: Nov 4 2003, 13:07
Go to the top of the page
 
+Quote Post
Sebastian Mares
post Nov 3 2003, 20:22
Post #2





Group: Members
Posts: 3538
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



Basicly:


Layer I will have 384 samples per frame in MPEG 1, and 192 samples per frame in MPEG 2(.5).

Layer II will always have 1152 samples per frame.

Layer III will have 1152 samples per frame in MPEG 1, and 576 samples per frame in MPEG 2(.5).


Is that correct?

This post has been edited by Sebastian Mares: Nov 3 2003, 20:23
Go to the top of the page
 
+Quote Post
smack
post Nov 4 2003, 11:41
Post #3





Group: Members
Posts: 171
Joined: 16-January 02
Member No.: 1046



Yes, the samples-per-frame for MPEG-1 are correct.
As for MPEG-2 and 2.5: Layer III seems to be correct, but are Layer I and II actually specified? I thought only Layer III is used with with the LSF and VLSF extensions but I might be wrong.

Maybe you can find the answer in the source codes of a well-written decoder like amp11 by Niklas Beisert - I found it very helpful when I wrote my own decoder some time ago...
Go to the top of the page
 
+Quote Post
Sebastian Mares
post Nov 4 2003, 12:02
Post #4





Group: Members
Posts: 3538
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



I have just tested the above combinations and everything seems to be in order. For MPEG 2(.5) Layer I 192 samples per frame are used.

However, in an online document I have seen that only Layer III has different samples per frame in MPEG 2 (as only one granule is used instead of two) and that Layer II and Layer I are constant, but when I use MPEG 2 Layer I with 384 samples per frame, the duration is twice as large as original one. blink.gif

This post has been edited by Sebastian Mares: Nov 4 2003, 12:06
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 9th February 2010 - 18:11