-
Notifications
You must be signed in to change notification settings - Fork 652
Fix double application of audio/video offset for concatenated segments #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix double application of audio/video offset for concatenated segments #155
Conversation
In clip(), the start and end variables already include start_ost and end_ost offsets after the clamping step, but the data slice for subsequent segments was applying the offsets a second time via data[start+start_ost*16:end+end_ost*16]. Use data[start:end] instead. Similarly in video_clip(), the time_acc_ost calculation was adding the offsets again even though start and end already incorporated them. Use (end - start) directly since the duration already reflects the offset-adjusted boundaries. Fixes modelscope#129 Fixes modelscope#144
Summary of ChangesHello @Mr-Neutr0n, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical bug where audio and video offsets were applied twice during the clipping of concatenated segments, leading to incorrect clip boundaries and subtitle timings. The changes ensure that offsets are correctly accounted for only once, improving the accuracy of multi-segment audio and video processing. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a critical bug where audio and video offsets were applied twice when clipping multiple concatenated segments. The changes in funclip/videoclipper.py correctly resolve this issue.
In the clip function, the redundant offset application during data slicing for subsequent segments is removed, which prevents incorrect audio clip boundaries.
Similarly, in the video_clip function, the calculation for time_acc_ost is corrected for both the first and subsequent segments to prevent double-counting the offsets, ensuring correct subtitle timing for concatenated video clips.
The fixes are accurate, well-targeted, and directly address the problem described in the pull request description. The code changes are of high quality.
Summary
When clipping multiple segments (concatenated clips), the audio and video offsets (
start_ost/end_ost) are applied twice — once when computingstart/end, and again when slicing the data or computingtime_acc_ost. This causes incorrect clip boundaries for any multi-segment operation.In
clip():startandendalready include the offsets after the clamping step (lines 128–129), but the data slice for subsequent segments wasdata[start+start_ost*16:end+end_ost*16], applying the offsets a second time. Fixed to usedata[start:end].In
video_clip():startandendalready incorporatestart_ost/1000.0andend_ost/1000.0, buttime_acc_ostwas calculated asend+end_ost/1000.0 - (start+start_ost/1000.0), double-counting the offsets. Fixed to useend - start.Note that the first segment in both methods was already handled correctly — the bug only affected the 2nd, 3rd, ... segments when multiple periods are matched and concatenated.
Fixes #129
Fixes #144
Test plan
start_ost/end_ost— should behave identically to before (no change for single segments)time_acc_ost) aligns correctly with concatenated video clips