Skip to content

Media/embedded timecode sync#13432

Closed
sm9cc wants to merge 3 commits into
obsproject:masterfrom
sm9cc:media/embedded-timecode-sync
Closed

Media/embedded timecode sync#13432
sm9cc wants to merge 3 commits into
obsproject:masterfrom
sm9cc:media/embedded-timecode-sync

Conversation

@sm9cc
Copy link
Copy Markdown

@sm9cc sm9cc commented May 14, 2026

Description

Adds embedded timecode synchronization support to FFmpeg-backed media playback sources.

The change parses embedded S12M timecode metadata from decoded video frames and adds a media source option to align playback timestamps to those timecodes. This is intended for MPEG-TS media streams where embedded timecodes can be used to synchronize playback.

The PR also adds focused media playback tests for S12M parsing, including fractional frame-rate cadence handling.

Live stream:

https://www.twitch.tv/mrpol

Screenshot:

image

Demo video:

https://www.youtube.com/watch?v=QYW37yn7ZQQ

Motivation and Context

This allows OBS media sources to synchronize playback using embedded timecodes instead of relying only on local receive/decode timing.

The motivation for this change is a delivery driving stream with two live camera perspectives: one phone inside the car and one phone mounted outside the car. Both feeds need to remain synchronized in OBS even though each phone may be using a different mobile network with different delay, jitter, and temporary signal degradation.

This is useful for FFmpeg-backed media workflows where senders embed timecode metadata and the receiver needs stable timestamp alignment inside OBS.

How Has This Been Tested?

Tested on Linux with a local OBS Debug build.

Real-world test:

Two phones were used while driving through areas with varying mobile signal. Each phone streamed simultaneously to a separate ingest endpoint, and the streams were added to OBS as separate FFmpeg-backed media sources with the new timecode sync option enabled. The phones were on different mobile networks, and both were running Moblin with its timecodes feature enabled.

During the drive, each phone had connection degradation at different times. In each case, the affected source recovered and returned to sync with the other source without visible drift.

The linked demo video shows the synchronization result.

Commands run:

clang-format --dry-run --Werror shared/media-playback/media-playback/timecode.c shared/media-playback/media-playback/timecode.h shared/media-playback/media-playback/media.c shared/media-playback/media-playback/media.h test/media-playback/test_timecode.c
git diff --check
cmake --build build_ubuntu --target test_media_playback_timecode --parallel 32
ctest --test-dir build_ubuntu -R test_media_playback_timecode --output-on-failure
cmake --build build_ubuntu --target obs-ffmpeg --parallel 32
cmake --build build_ubuntu --target obs-studio --parallel 32

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

sm9cc added 3 commits May 14, 2026 12:02
Use FFmpeg S12M frame side data to align network media
sources by embedded timecode instead of packet arrival time.

Expose the setting for FFmpeg network sources and keep it
disabled for local files and full decode paths.
S12M non-drop timecode at fractional rates used wall-clock seconds
plus a frame offset. That made adjacent labels at a second boundary
shorter than one frame, causing timecode sync to jitter.

Use frame counts for fractional non-drop timecode so 30000/1001
and 60000/1001 sources keep a steady frame cadence. Keep exact
integer-rate and drop-frame paths unchanged.
@sm9cc sm9cc closed this May 15, 2026
@alinsavix

This comment was marked as abuse.

@sm9cc
Copy link
Copy Markdown
Author

sm9cc commented May 17, 2026

@sm9cc I'm curious you closed this, it seemed like a pretty cool feature!

AI code is not allowed, sadly.

@alinsavix

This comment was marked as abuse.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants