Repository navigation
recording: Fix processing hangs from seeking in screenshare files with video - #25252
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR implements original_duration tracking throughout the record-and-playback EDL pipeline. Event handlers record segment start/stop timestamps and compute original_durations for audio and video segments, attaching those values to EDL entries. During audio rendering, referenced files are probed, A/V inputs with video streams are remuxed to audio-only outputs, remux metadata is re-probed with original_duration preserved, and EDL filenames are rewritten. Downstream logic uses original_duration for gap detection, speed correction, and pts gap calculations. Sequence Diagram(s)sequenceDiagram
participant Generator as EDL Generator
participant Renderer as EDL Render
participant Remuxer as FFmpeg Remux
participant Probe as Metadata Probe
Generator->>Renderer: Emit EDL entries (with original_duration when available)
Renderer->>Probe: Probe referenced media files
Probe-->>Renderer: Return streams/duration or mark corrupt
Renderer->>Remuxer: Remux A/V inputs -> -audio.mkv
Remuxer->>Probe: Re-probe remuxed outputs
Probe-->>Renderer: Return remux metadata (carry original_duration)
Renderer->>Renderer: Rewrite EDL audio filenames -> remuxed paths
Renderer->>Generator: Use original_duration for gap/speed corrections
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
record-and-playback/core/lib/recordandplayback/generators/events.rb (1)
541-551: 💤 Low valueLine 543 is now dead code.
The condition at line 543 sets
original_durations[filename]from the XML<duration>element, but line 551 unconditionally overwrites it with the timestamp-based calculation whenever a start time exists. This makes line 543's assignment dead code.Based on the PR objectives (preferring event timestamps over media file duration), this appears intentional. Consider removing lines 542-543 to avoid confusion.
🧹 Suggested cleanup
when %w[Deskshare DeskshareStoppedEvent], %w[bbb-webrtc-sfu StopWebRTCDesktopShareEvent] raise "Couldn't determine video filename" if filename.nil? - # Save the original duration of the deskshare video if provided (it will be added to the EDL later) - duration = event.at_xpath('duration') - original_durations[filename] = duration.content.to_i * 1000 if duration # Create a new EDL entry with the deskshare video removed last_entry = deskshare_edl.last new_entry = offset_entry.call(last_entry, timestamp - last_entry[:timestamp]) new_entry[:timestamp] = timestamp new_entry[:areas][:deskshare].reject! { |file| file[:filename] == filename } deskshare_edl << new_entry original_durations[filename] = timestamp - start_times[filename] if start_times.include?(filename)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@record-and-playback/core/lib/recordandplayback/generators/events.rb` around lines 541 - 551, The assignment that sets original_durations[filename] from the XML duration node (the local variable duration and the line using duration.content.to_i * 1000) is dead because later code unconditionally overwrites original_durations[filename] using timestamp and start_times; remove that duration-based assignment and its surrounding nil-check (the duration local and the conditional that assigns to original_durations) in recordandplayback/generators/events.rb so only the timestamp-based calculation (the later original_durations[filename] = timestamp - start_times[filename]) remains; keep the rest of the block that builds new_entry via offset_entry, updates deskshare_edl, and references start_times as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback/generators/events.rb`:
- Around line 541-551: The assignment that sets original_durations[filename]
from the XML duration node (the local variable duration and the line using
duration.content.to_i * 1000) is dead because later code unconditionally
overwrites original_durations[filename] using timestamp and start_times; remove
that duration-based assignment and its surrounding nil-check (the duration local
and the conditional that assigns to original_durations) in
recordandplayback/generators/events.rb so only the timestamp-based calculation
(the later original_durations[filename] = timestamp - start_times[filename])
remains; keep the rest of the block that builds new_entry via offset_entry,
updates deskshare_edl, and references start_times as-is.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 92b01cdc-d919-430d-b6a0-13005c53089c
📒 Files selected for processing (4)
record-and-playback/core/lib/recordandplayback/edl/audio.rbrecord-and-playback/core/lib/recordandplayback/edl/video/video_source.rbrecord-and-playback/core/lib/recordandplayback/generators/audio.rbrecord-and-playback/core/lib/recordandplayback/generators/events.rb
| corrupt_audios << filename | ||
| out_filename = "#{process_dir}/#{File.basename(filename, '.*')}-audio.mkv" | ||
| extract_cmd = [*FFMPEG, '-copyts', '-i', filename, '-map', '0:a:0', '-c', 'copy', '-f', 'matroska', out_filename] | ||
| exitstatus = BigBlueButton.exec_ret(*extract_cmd) | ||
| next if exitstatus != 0 |
There was a problem hiding this comment.
if the extraction fails, the original file will be removed from the edl, wouln't be better to fail the processing instead?
There was a problem hiding this comment.
In general, we've decided that corrupt media files in recordings should cause the media to be dropped from the recording (but the recording should continue to process), and the only notable cases where this copy command could fail would be if the input file is corrupt, or if the server runs out of disk space (which will cause the processing to fail in a later step anyways)
The "original_duration" property in the EDLs is present to provide a way for the recording scripts to know what the duration of a recorded media file, according to BigBlueButton as reported by events. But following various refactoring of the EDL code, it was no longer populated for audio files or most video files. I've rearranged the format of the audio EDL so the original_duration is tracked separately for each audio file (the original design assumed only one audio file active at a time), and restored or corrected the code which populates the original_duration field for both audio and video files. The media file gap checking code is now passed the original_duration field where available, allowing it to to a better job of avoiding seeking past the end of an input file.
Files from deskshare can contain both audio and video, but due to browser quirks and strange timing issues, there can be portions of the file which contain either only audio or only video. The ffmpeg command line tool always seeks based on video if video is present, even if video processing is disabled using the '-vn' option, which causes some issues (hangs) in recording processing on seeks which should be valid for audio, but where ffmpeg ended up starting at different point in the file. The easiest way to fix this issue is to copy the audio out of the deskshare files to a separate audio-only file, and use that as the input for the audio processing.
febaa97 to
fb9e841
Compare
|
🚨 Automated tests failed |
564efff
into
bigbluebutton:v3.0.x-develop



What does this PR do?
I discovered a recording which was hanging during audio processing following the gap removal changes in #24776. Upon investigation, I located two problems that could cause this issue:
To resolve this issues, I've done the following:
I've restored (corrected functionality of, and added where missing) the code the calculates "original_duration" for audio and video tracks in the EDL. This restores the functionality of some workarounds for legacy recording bugs (from BBB 0.9 and earlier), and I added code to forward the original duration to the gap detection logic to allow it to detect (and trim) more cases where there might be an EDL cut that tries to seek past the end of the media.
I've also added a step which extracts the audio from the screenshare recordings to a separate audio-only file. With the audio-only file, ffmpeg is forced to seek based on audio timestamps, and this avoids cases where ffmpeg would sometimes seek into audio gaps or past the end of the audio even tho the provided seek time was within a non-gap audio section.
How to test
Check is that recordings containing audio and video (especially recordings with screenshare audio) process without hanging, and verify that the audio is in sync.
The specific case that led me to discovering the bug was from a customer's live recording, and I am unable to share an example file which triggers the bug.
More