Recently, a ffmpeg-based player has been developed to learn more about timestamp (time stamp) in FFmpeg. Here is a summary.
There are two types of timestamps in FFmpeg: DTS (decoding time Stamp), and pts (Presentation times Stamp). As the name implies, the former is the decoding time, the latter is the time of the display. To understand these two concepts carefully, you need to first understand the concepts of packet and frame in ffmpeg.
In FFmpeg, the avpacket structure is used to describe the pre-decoded or encoded compressed packets, and the AVFRAME structure is used to describe the signal frames before decoding or encoding. For video, Avframe is a frame image of the video. When the frame image is displayed to the user, it depends on its pts. DTS is a member of the Avpacket that indicates when the package should be decoded. If the encoding of each frame in the video is done sequentially in the order of input (that is, the display order), then the decoding and display time should be consistent. In fact, in most codec standards, such as H. T or HEVC, the encoding sequence and input order are inconsistent. The two different timestamps of PTS and DTS are required.