0

I made my own rtmp server using libav and ffmpeg. I receive as input either an flv file or an rtmp streaming "containing" an flv file. Since I manipulate the flv file and the relative composition time of each frame, I would like to know if there is a way to get this composition time. I thought that given my AVPacket, I could analyze the raw buffer in order to extract the right information since I know that the flv header is 11 bytes and then in the next 16 bytes I should find the composition time. But it doesn't work.

This is a rough example of code:

AVPacket pkt;
AVFormatContext *ifmt_ctx
while(true)
{
    AVStream *in_stream, *out_stream;

    ret = av_read_frame(ifmt_ctx, &pkt);
    //get the composite time
}
Andrea
  • 1,597
  • 3
  • 18
  • 24

1 Answers1

1

AVPacket needs to be able to represent the data found in all media formats. Some formats (like mp4 and flv) have a decode_time and a composition_time, other (like transport streams) have a decode_time and a presentation_time. To make it easier for the programmer, AVPacket chose one method to store the information and converts when needed. Luckily its an an easy to convert back:

auto cts = pkt.pts - pkt.dts
szatmary
  • 29,969
  • 8
  • 44
  • 57