On Tue, Dec 14, 2010 at 1:10 AM, Tomas Härdin <[email protected]>wrote:

> On Mon, 2010-12-13 at 19:49 -0800, Pushkar Pradhan wrote:
> > I need to compute the 33 bit 90 khz Packetized Elementary Stream
> timestamp
> > from a FLV timestamp (in millisecs). Can anyone tell me where is the
> > function in ffmpeg that does this calculation?
> > I am not sure about some aspects of the formula like:
> > 90 kHz = 90000 cycles/sec or 90x1024 cycles/sec?
> > Is it as simple as 1 sec = 90 K cycles => 1 millisec = 90 cycles?
> > Of course this is before the formatting into the PES timestamp format.
> >
> > Thanks,
> > pushkar
>
> pes_ts = av_rescale_q(flv_ts, (AVRational){1,1000},
> (AVRational){1,90000});
>
> But, since it sounds like you're remuxing you'll probably want to make
> the code a bit more general, like:
>
> pes_ts = av_rescale_q(flv_ts, flv_st->time_base, ts_st->time_base);
>
> Where flv_st is the AVStream in the FLV demuxer and ts_st is the
> AVStream in the TS muxer.
>
> /Tomas
>
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
> Tomas,
Thanks, it's working fine. av_rescale_q returns the timestamp as a 64 bit
signed value so I truncate the result to 33 bits so that the timestamps
rollover:
  int64_t pes_ts = av_rescale_q(first_pts, (AVRational){1,1000},
(AVRational){1,90000});
  pes_ts &= 0x1FFFFFFFFLL;

I am converting AAC contained in FLV to ADTS stream segments. I put the PES
timestamp of the first audio sample in the segment in a ID3 tag as defined
by the Live HTTP streaming draft.

-- 
pushkar
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to