How is the basetime calculated by gstreamer pipeline?
Source: Internet
Author: User
When gstpipeline is converted from paused to playing, it selects a clock and calculates the basetime. These two items are assigned to each element in the pipeline. How is this basetime calculated every time?
It turns out that this basetime is the current clock time, but it was found to be incorrect later. For example, pause is used when the video is played for 2 seconds and play after 3 seconds. If the basetime is the current time, it is the time of 5 seconds. If the video is played again, we will find that the timestamp in the passed buffer starts from 3rd seconds, not from 0 seconds, because the last pause was at 2 seconds. Therefore, if basetime is set to 5 seconds, the sink component will play the buffer after 8 seconds (because the timestamp of the buffer starts from 3 seconds ).
So I went back to the research on the stst_pipeline_change_state function and found that it was actually very simple:
Base_time = start_time-stream_time + delay;
Start_time is the current clock time, And stream_time is the time that has been played (Note: Unlike running_time, running_time is the time that passes after it becomes playing, stream_time is the actual playback time of the sink after the playing state is changed. Therefore, stream_time is generally directly used in the position query and directly returned as the position (of course, there are some logic here, stream time is not directly returned. For details, refer to the stst_base_sink_get_position function). delay is a property of the ststpipeline and can be set.
This is the case. In the above example, we play for 2 seconds first, so stream_time is 2 seconds. After 3 seconds, we play for 5th seconds, so start_time is 5, in this case, base_time is 3 seconds (if delay is set to 0, the default value is 0), so the next buffer timestamp starts from 3 seconds, and the playing will happen.
If this is the first time you play a video without pause, the above formula is clear. In this case, basetime is the start time.
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