I am writing an application, capturing a live MPEG2-TS from a dvb-S device
and saving its parts to files according to the user-defined schedule.
Basically, the main cycle is the following:

for(;;){
  av_read_frame(input,&pkt);

  if( [pkt is to be saved] ){

     [reassign pkt.stream_index to 0 or 1 depending on which elementary
stream incoming packet belongs to]

     av_write_frame(output[i],&pkt);
  }
}

When the application connects to the device it starts writing frames having
timestamps from the incoming stream, for example: 

input->streams[0]: first_dts=5626390592 cur_dts=5786608592
input->streams[1]: first_dts=5626403887 cur_dts=5786625487
...
input->streams[37]: first_dts=6032698660        cur_dts=6192910180      
...

Here input is AVFormatContext of the incoming transport stream,
input->streams[i] are the members of AVFormatContext::AVStream
[MAX_STREAMS], and first_dts and cur_dts are members of the respective
AVStream structs.

Currently these DTS values go to the output stream.
That's fine, unless timestamp value jumps over 33 bits (the length of the
PTS and DTS fields in the MPEG2-TS). In that case I can have the following
timestamps in the resulting file (doesn't matter, P or D TS):  8589924500,
8589934400, 250000, 320234, ...

av_write_frame complained about non-monotone time stamps (initially, now I
am checking for such situation and change output->streams[]-> cur_dts
accordingly ). Some media players also don't like that timestamps.


So, the main question is.
Is there any means in the libav* to make output timestamps begin with 0?

Simply saving first DTS and subtract it from all other time stamps wouldn't
do, because of that 33-bit overflow.

-- 
View this message in context: 
http://www.nabble.com/How-to-make-libav-to-begin-write-frames-having-PTS-about-0--tp18111426p18111426.html
Sent from the libav-users mailing list archive at Nabble.com.

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

Reply via email to