Timestamp Miscellaneous (2)

Source: Internet
Author: User

A timestamp consists of a time reference and a timestamp value.

Time benchmark: the criteria for dividing the time unit (s.

For example, 1/25 indicates 25 units per second. Each unit interval contains 1 unit.

3001/90000 indicates that each second is divided into 90000 units, and each unit interval contains 3001 units.

Timestamp value: the time representation based on the time reference, that is, the number of unit time intervals.


1) The timestamp is used to accurately mark the relative position and duration of audio and video streams.

2) using a timestamp based on the time benchmark, rather than using an integer, means that the timestamp can avoid division failures.

3) There is an error in timestamp conversion between different time benchmarks. Unnecessary conversions should be avoided.

If conversion is required, ensure that the timestamp after conversion is not earlier than before conversion.

4) Compare the direct timestamps of different time benchmarks, which should be first converted to a more detailed unit (1/1hns.

5) The system clock is equivalent to 1/1000 of the timestamp. The audio and video playback synchronization is actually a comparison between the stream's own Timestamp and the system timestamp.

As there is an error in time stamp conversion, there is also an error in playback synchronization. Therefore, do not tangle with equal signs, but try to set a tolerable error duration.



Timestamp conversion in FFMPEG

Avformatcontext-> avpacket-> avframe-> avpacket-> avformatcontext

Avstream avcodeccontext avstream

Decoding process: Because avstream and avcodeccontext are created in the file parsing process, the time_base of the two should be consistent.

The timestamp value from avpacket to avframe remains unchanged.

Encoding Process: The time_base of avcodeccontext is set by the user (the default value is 1/90000), and The time_base in avstream is the default value 1/90000 (the value of FFMPEG in write_header is modified to match avcodeccontext). The values are not necessarily equal, therefore, time stamp value conversion is required.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.