Skip to content

rtp: Use timestamp difference for video playback rate.#1909

Open
gareth-palmer wants to merge 1 commit into
asterisk:masterfrom
gareth-palmer:video-playback
Open

rtp: Use timestamp difference for video playback rate.#1909
gareth-palmer wants to merge 1 commit into
asterisk:masterfrom
gareth-palmer:video-playback

Conversation

@gareth-palmer
Copy link
Copy Markdown

When playing an audio file that has an associated video file that stream will not finish at the correct time due to incorrect scheduling of ast_readvideo_callback.

Non-zero scheduling between frames now only occurs when the frame timestamp changes and when-next is now
calculated using the difference in timestamps between frames.

Video frames were also sent out with an incorrectly calcuated timestamp because the flag AST_FRFLAG_HAS_TIMING_INFO was not set on frames read from a file.

UserNote: The on-disk format for H263 and H264 video streams has changed so any previous recordings are not be playable.

When playing an audio file that has an associated video
file that stream will not finish at the correct time
due to incorrect scheduling of ast_readvideo_callback.

Non-zero scheduling between frames now only occurs when
the frame timestamp changes and when-next is now
calculated using the  difference in timestamps between
frames.

Video frames were also sent out with an incorrectly
calcuated timestamp because the flag AST_FRFLAG_HAS_TIMING_INFO
was not set on frames read from a file.

UserNote: The on-disk format for H263 and H264 video
streams has changed so any previous recordings are not
be playable.
@sangoma-oss-cla
Copy link
Copy Markdown

sangoma-oss-cla Bot commented May 5, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Checklist Complete

@github-actions github-actions Bot added the has-pr-checklist A PR Checklist is present on the PR label May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Workflow Check completed successfully

@gareth-palmer
Copy link
Copy Markdown
Author

cherry-pick-to: 23
cherry-pick-to: 22
cherry-pick-to: 20

@github-actions github-actions Bot dismissed their stale review May 5, 2026 04:40

Pull Request Checklist Complete

@github-actions github-actions Bot removed the has-pr-checklist A PR Checklist is present on the PR label May 5, 2026
@AryanM200
Copy link
Copy Markdown

AryanM200 commented May 14, 2026

Hi @gareth-palmer ,

I tested your code and it is working. The video speed issue is fixed but During testing, in random scenarios the video playback is not working.

My code changes are also working. You have made changes in 5 files, while I made changes in 1 file.
#1753

Can you explain which calculation or logic you used for the video playback handling?

@gareth-palmer
Copy link
Copy Markdown
Author

The calculation is that fr->ts contains the frame timestamp in milliseconds. When the timestamp of the current frame differs from that of the next frame the difference is used to calculate the delay (*whennext = ts - desc->lastts). There is no delay for frames that have the same timestamp.

Because *whennext is used as a timeout value for ast_sched_add the delay is decremented by 1ms so that the callback runs on the 33rd millisecond rather that just after the 33rd millisecond, or whatever the frame rate is guessed to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants