Subject: Re: Re: Re: [AVT] RTP timestamp calculation for MPEG1 Video and Audio ESsothat itworks with RTSP client like RealOne/QuickTime

From: Deepak Kotian <[email-masked]>
Date: Wed, 27 Aug 2003 21:58:52 +0530

Thanks for the information.

I think, there is no soft copy available for this one. Do you
know where I can buy it online please.

Could please shell out a formula something like audio for Video ES.

The PTS of 33 bits, I meant from docs similar to these.
http://www.cs.columbia.edu/~hgs/rtp/drafts/draft-hoffman-rtp-mpeg-encap-01.t
xt
*****Extract*****
These PES
packets contain presentation time stamps (PTS). The MPEG2 System standard
specifies that the time interval between contiguous PTS's should not be
greater than 0.7 seconds. We propose that PTS's should be present in every
RTP fixed header. In the MPEG2 System standard the PTS is defined to 33
bits with an accuracy of 90 kHz.  However, in this RTP encapsulation we use
only the 32 LSB's. Consequently, the PTS would cycle every 13.26 hours.
*****Extract*****

Also, I have heard that for B picture frame the timestamp needs to reduced
as well.
Could you elaborate on those lines as well.

Thanks very much for the help extended, really appreciated.
Some more help would make my life easier.

Thanks and Regards
Deepak

----- Original Message -----
From: "Neo Anderson" <[email-masked]>
To: <[email-masked]>; <[email-masked]>
Sent: Wednesday, August 27, 2003 6:42 PM
Subject: Re: Re: Re: [AVT] RTP timestamp calculation for MPEG1 Video and
Audio ESsothat itworks with RTSP client like RealOne/QuickTime

> >>...Which is usually 33 bits, that too is mystery to me as
> >>the RTP timestamp is 32 bits.
>
> First, I am not able to relate the 33 bits you have mentioned to any
> timestamp at all (kindly enlighten with reference)!
> and you might have to buy ISO/IEC 11172-2 for reference if u need
> to...
>
> TS calc in a nutshell:
> If u are streaming from a stored file:
>
> Else, some public source decoder will help to get how to extract the
> temporal_reference and the picture_rate/frame_rate_code fields from
> the MPEG-1 ES. From these two parameters, timestamp can be calculated.
>
> When u have the encoder running live at the constant frame rate, the
> timestamp to be carried MAY be directly given by the encoder or we
> can sample the system clock (gettimeofday() etc.) for the RTP
> timestamp (which implies PTS will be sent in the RTP packet) at the
> instant when the frame is generated.
>
> For Audio,
> If it is constant bitrate (which I presume will be in most cases of
> streaming), then you will have to increment the timestamp based on
> the samples per frame. RTP timestamp will be the timestamp for the
> first audio frame in the RTP packet (it is most likely that multiple
> audio frames are carried in the RTP packet). convert this into the
> resolution as required by rfc2250 (90kHz). Also check out the RTP FAQ
> on this.
> Example:
> Sampling Rate = Fs Hz
> Calculated Samples per frame = x
> Timestamp in 90kHz units = ((x/Fs) * 90000)
>
> For variable bit rate audio,
> Calculate the number of samples per frame for each individual audio
> frame. Based on the sampling frequency, calculate the timestamp which
> is to be sent for each frame and use the timestamp of the first audio
> frame in the rtp packet.
>
> To calculate the number of samples, you will find lot of info on the
> web for the MPEG1 audio frame structure and related formula.
> http://www.wotsit.org is one of them. Check for mp3 frame format for
> audio.
>
> >>You guys are my last hope on this, the helix guys have redirected me
> >>to this forum.
> Hopefully now...
>
>
>
> --Neo
> Get your own Free E-mail at Witch Wisdom http://www.witchwisdom.com
> __________________
> http://www.zzn.com

_______________________________________________
Audio/Video Transport Working Group
[email-masked]
https://www1.ietf.org/mailman/listinfo/avt

---

From: Deepak Kotian <[email-masked]>
Date: Sat, 30 Aug 2003 01:28:58 +0530

About the audio encapsulation part.

These are points I am not clear.

1. I am encapsulating the audio frames based on Audio Frame Sync code.
    I determine the end of the frame if I get a next frame sync code.
    So, one RTP packet consists of one frame.
    Is this correct ?

2.  About the formula
> Timestamp in 90kHz units = ((x/Fs) * 90000)
How do I calculate samples per frame, Could you please stick the extract
over here. I tried the http://www.wotsit.org/search.asp?page=5&s=music
but it says .
If I check mpeghdr.htm file,
It says
******
How to calculate frame size

Read the BitRate, SampleRate and Padding (as value of one or zero) of the
frame header and use the formula:

                                                  FrameSize = 144 * BitRate
/ SampleRate + Padding

Example: BitRate = 128000, SampleRate=441000, Padding=0  ==>  FrameSize=417
bytes
******
But, I am not sure from where 144 has come from. And where does the padding
bit come from.
Moreever, it seems the decimal value is truncated.
Could not find samples per frame calulation.

Could one please let elaborate more on this.
Now we seem to be OK with video and we just need  help on audio.
Please let us know

Thanks and Regards
Deepak