Skip to content

fix: shift video positions to the start of video clips - #179

Closed
saraburns1 wants to merge 2 commits into
openedx:mainfrom
saraburns1:video-clip-offset
Closed

saraburns1 wants to merge 2 commits into
openedx:mainfrom
saraburns1:video-clip-offset

Conversation

@saraburns1

Copy link
Copy Markdown
Contributor

Description

Video blocks can be set to play only a clip of the source video (start/end time in Studio). The player reports time against the full source video but length as the clip duration, so video positions in dashboards can be past the end of the video (e.g. 4:00 in a 3-minute video), and watched segments / completion are off.

Depends on openedx/platform-plugin-aspects#259, which adds video_start_time / video_end_time to xblock_data_json.

Changes:

  • dim_most_recent_course_blocks and the dim_course_block_names dictionary carry video_start_time and video_end_time.
  • video_playback_events looks up the block in dim_course_block_names and subtracts the clip start from the position (clamped at 0), before the existing rounding up. It only shifts when the event's length matches the clip (within 1s), so events from players that play the full video are left alone. Unclipped videos and blocks not yet in ClickHouse are unchanged.
  • All Superset video datasets read from video_playback_events / fact_video_segments, so they all pick up the fix.

Upgrade notes

  • dim_most_recent_course_blocks gets new columns, so it needs a full refresh (dbt run --full-refresh -s dim_most_recent_course_blocks). A normal run only updates the view's query. The table is small.
  • Existing events in video_playback_events are only corrected by a full refresh of video_playback_events+, which reprocesses all xAPI events. That's optional and can be expensive on large instances.
  • If clip times change after events were stored, older events keep the offset that applied when they were inserted.

Testing

  • New unit test test_video_playback_events_clipped_videos covers clipped, before-clip-start, full-player, unclipped and start-only cases. It fails against the old model.
  • Expected seeds for dim_most_recent_course_blocks and dim_course_block_names have the new columns (all 0, as the generated test data has no clipped videos).
  • Ran locally against ClickHouse 25.8: built the models with sample course blocks and xAPI events, then inserted more events to check the live insert path. A 60–240s clip now gives positions and fact_video_segments in 1–180 instead of up to 240. sqlfmt --check and doc coverage pass.

🤖 Generated with Claude Code

Video blocks can be configured to play only a clip of the source video.
The player reports positions against the full source video but the
duration of only the clip, so positions could be past the end of the
video. Shift positions by the clip start time from the course block
data, when the reported duration matches the clip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Completed events report the video duration as the position, which is
already relative to the clip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@saraburns1 saraburns1 closed this Oct 8, 2026
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.

1 participant