Skip to content

[bugfix] fix load audio from local video path when USE_AUDIO_IN_VIDEO (fix #8332)#8339

Open
alphadl wants to merge 1 commit intomodelscope:mainfrom
alphadl:fix/8332-use-audio-in-video-load-mp4
Open

[bugfix] fix load audio from local video path when USE_AUDIO_IN_VIDEO (fix #8332)#8339
alphadl wants to merge 1 commit intomodelscope:mainfrom
alphadl:fix/8332-use-audio-in-video-load-mp4

Conversation

@alphadl
Copy link

@alphadl alphadl commented Mar 14, 2026

[bugfix] fix load audio from local video path when USE_AUDIO_IN_VIDEO (fix #8332)

#8332

With USE_AUDIO_IN_VIDEO=True, loading audio from a local video path (e.g. .mp4) passed the path directly to librosa.load(). Librosa/soundfile do not support video containers, which caused:

soundfile.LibsndfileError: Error opening 'xxx.mp4': Format not recognised.

URLs were already handled via audioread.ffdec.FFmpegAudioFile. This PR applies the same ffmpeg-based decoding for local paths when the file extension is a video format (.mp4, .webm, .avi, .mov, .mkv), so that librosa.load receives a decoded audio stream instead of the raw path.

Changes:

  • swift/template/templates/qwen.py: In the use_audio_in_video branch, if video is a local path with a video extension, open it with audioread.ffdec.FFmpegAudioFile(video) before calling librosa.load(). No new dependencies (audioread/ffmpeg already used for URLs).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 bug preventing audio extraction from local video files when the USE_AUDIO_IN_VIDEO flag is active. By integrating FFmpeg-based decoding for local video paths, it ensures that audio can be successfully loaded from both local and remote video sources, enhancing the robustness of audio processing within the system.

Highlights

  • Bug Fix for Local Video Audio Loading: Addressed an issue where librosa.load() failed to extract audio from local video files (e.g., .mp4) when USE_AUDIO_IN_VIDEO was enabled, due to librosa/soundfile not supporting video containers directly.
  • Consistent Audio Extraction: Implemented audioread.ffdec.FFmpegAudioFile for local video paths with common video extensions (.mp4, .webm, .avi, .mov, .mkv), mirroring the existing handling for URL-based videos. This ensures librosa.load receives a decoded audio stream.

🧠 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
  • swift/template/templates/qwen.py
    • Added logic to pre-process local video paths using audioread.ffdec.FFmpegAudioFile before passing them to librosa.load when use_audio_in_video is true and the path has a video extension.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@alphadl
Copy link
Author

alphadl commented Mar 14, 2026

Please take a look when you have time. This fixes loading audio from local video files (e.g. .mp4) when USE_AUDIO_IN_VIDEO=True (fixes #8332). cc @Jintao-Huang @hjh0119

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 correctly addresses a bug where loading audio from local video files would fail. The fix extends the existing logic for handling video URLs to also cover local video file paths by using audioread to decode the audio stream before passing it to librosa. My review includes a suggestion to refactor the new logic to improve code clarity and reduce duplication.

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.

can't load audio when using USE_AUDIO_IN_VIDEO

1 participant