How should I validate pts/dts after demuxing and then after decoding?
For me it is significant to have valid pts all the time for days and possibly weeks of continuous streaming.
After demuxing I check:
- dts <= pts
- prev_packet_dts < next_packet_pts
- I also discard packets with AV_NOPTS_VALUE and wait for packets with proper pts, because I don't know video duration at this case.
- pts of packets can be not increasing because of I-P-B frames Is it all right?
What about decoded AVFrames?
- Should 'pts' be increasing all the time?
- Why at some point 'pts' could lag behind 'dts'?
- Why pict_type is a parameter of AVFrame? Should be at AVPacket, because AVPacket is a compressed frame, not the opposite?
CodePudding user response:
Ideally, yes. Unless if your format allows discontinuities, or wraps timestamps around due to overflow, like MPEG-TS.
Writing error.
It is an informational field, indicating the provenance of the frame. It can be used by filters or encoders, e.g. keyframe alignment during a re-encode.
CodePudding user response:
At libav support I was advised to not rely on decoder output. It is more solid to produce pts/dts for encoding/muxing manually and I should search for ffmpeg tools sources to proper implementation. I will search for this approach.
For now I discard AVFrames only with AV_NOPTS_VALUE, and the rest of encoding/muxing works fine.
Validation of AVPackets after Demuxing remains the same, as described above.