PTS in video api


I use decoder-converter-encoder chain to trancode mpegts video stream with ffmpeg as reciever and transmitter.

How to use PTS (presentation timestamp) from mpegts to syncronize transcoded video and audio? How to pass pts to chain and obtain valid AVPacket for transcoded video?

ffmpeg is 3rdparty implementation. You may check if you can get help from

We don’t support ffmpeg with hardware acceleration on TX2. If you need hardware acceleration, please use gstreamer or tegra_multimedia_api.

I already use tegra_multimedia_api, it`s ok.
My problem is video and audio syncronization.

In ffmpeg source code, I can see muxer code at:


Since it is 3rdparty code and we haven’t traced into it. Other users may share their experiences.

I pass pts to encoder via v4l2_buffer timestamp. And recieve it back after encode.

It’s ok.

What about dts, when b-frames is enabled in encoder?

You can control timestamps by

"--copy-timestamp <st> Enable copy timestamp with start timestamp(st) in seconds"

If you set ‘-nbf 1’

"-nbf <num>            Number of B frames [Default = 0]"

The encoded frames are sent out in below orders:

IDR P B P B P B ...