[Ffmpeg-devel] How can generate TS PES streams from the ES streams using ffmpeg

Sibnath GHOSH sibnath.ghosh
Fri Apr 27 16:52:22 CEST 2007


Hi,

I am using ffmpef parser and demux within my application. I use the libraries libavcodec.a, libavformat.a and libavutil.a in my application. I would like to generate TS PES streams from the video elementart streams from an AVI file. At present I am using a video only AVI stream. 

Is there an example in the ffmpeg tree for generating PES for both video and audio streams.

I get the following pts values from the ffmpeg.

pts:0 dts:0 size:29115 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:1 dts:1 size:10502 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:2 dts:2 size:11432 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:3 dts:3 size:11458 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:4 dts:4 size:11644 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:5 dts:5 size:11728 idx:0 dur:1 rate_num:30000 rate_den:1001

In order to fill up the PES headers I would like to calculate the PTS values like the following.

PTS = (rate_den / rate_num ) * pts(obtained from ffmpeg) * 90000

I will get PTS values as 0, 3003, 6006, 9009....

Since the PTS are 33 bits, I will have to take care of the bit wrapping when the calculated PTS value reaches 2^33(=8589934592). But ffmpeg itself take care of the wrapping on the pts values it generates, which is actually gives the picture ordering (correct me if I am wrong). 

My question is, how I can handle is bit wrapping, alongwith the wrapping that ffmpeg does inside libavformat/utils.c. The PTS value I will calculate will reach the value 8589934592 earlier than the wrapping is handled by ffmpeg.

Please advise how I can proceed with the PES encapsulation.

I am using the svn version 8847. 
For building I do the following:
make distclean
./configure --cross-compile --cross-prefix=sh4-linux- --arch=sh4 --disable-encoders --disable-decoders --disable-muxers
make lib

Regards
Sibnath Ghosh






pts:0 dts:0 size:29115 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:1 dts:1 size:10502 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:2 dts:2 size:11432 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:3 dts:3 size:11458 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:4 dts:4 size:11644 idx:0 dur:1 rate_num:30000 rate_den:1001
pts:5 dts:5 size:11728 idx:0 dur:1 rate_num:30000 rate_den:1001





More information about the ffmpeg-devel mailing list