Repository navigation
Fix fabricated source duration in OTIO exports - #580
nikhiljangid120 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
First off, thanks for reporting this and submitting a PR!
It looks like the current iteration just removes the duration field entirely. Can we instead fill it in with the real source duration (when we have it available)?
write_scene_list_fcp7 already does this via the source_duration parameter, and the
CLI passes video_stream.duration to it in scenedetect/_cli/commands.py. Could you update the PR to:
- Add
source_duration: FrameTimecode | None = Noneparameter towrite_scene_list_otio, documented like the one inwrite_scene_list_fcp7. - Write
available_rangewithstart_time 0andduration = source_duration.seconds * fps, rounded the same way as the clip'ssource_rangevalues. - Pass
source_duration=video_stream.durationfromsave_otioin scenedetect/_cli/commands.py. The golden tests in test_cli.py should then contain the real duration of goldeneye.mp4 instead of null. - Add a test case that passes source_duration and checks the resulting range at both CFR and NTSC rates.
If the source duration happens to be None, keep available_range: null as you have now. I agree the last scene's end time isn't a good stand-in for a subset of scenes.
Thanks!
Edit: Also filed #580, feel free to reference that and add a changelog entry too.
|
Thanks @Breakthrough — updated in ba4f5a8 to follow your requested approach:
Validation on Python 3.12.15:
Actual editor GUI imports and other operating systems were not tested. Prepared and validated with AI assistance; no claim of independent human line-by-line review. Ready for another look whenever convenient. |
Summary
Stop declaring every source media file as exactly 1,980 frames long in OTIO exports.
The existing
ExternalReference.1.available_rangealways starts at zero and lasts 1,980 frames regardless of the source. This can declare exported clips (for example, frames 2,400–4,800) outside the media's available range.Following the maintainer's review,
write_scene_list_otionow accepts optionalsource_duration. When supplied, it exports the full source duration, starting at zero and rounded to six decimal places at the output frame rate. When unknown, the available range remainsnull, which OpenTimelineIO supports. A selected scene subset's final frame is never substituted for the source duration.The CLI passes
video_stream.duration. Each clip'ssource_range, frame rate, media target, and track layout remain unchanged. The optional argument is appended to preserve existing positional calls.Regression coverage
Validation
Python 3.12.15 on Linux:
ruff check .,ruff format --check ., andgit diff --checkpass.test_fan_out_n1_matches_single_consumerandtest_fan_out_frame_equality_across_consumers. A previous complete-suite attempt exceeded this sandbox's 4 GiB memory limit in the former test, which retains both full decoded videos. No claim of a fully passing complete suite.Prepared and tested with AI assistance. No claim of independent human line-by-line review.