Skip to content
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

Feature request: Audio transfer from source to final video #151

Open
IxalonDarkstone opened this issue May 6, 2024 · 2 comments
Open

Feature request: Audio transfer from source to final video #151

IxalonDarkstone opened this issue May 6, 2024 · 2 comments

Comments

@IxalonDarkstone
Copy link

Title is pretty specific, but basically I am hoping that we can get a feature to merge the audio from the source to the final video. ComfyUI has this in their vid2vid workflows, but honestly your extension is far superior to the videos I have been able to create with Comfy. Just putting this out there in case it is an easy fix.

Thanks!
Ix

@IxalonDarkstone IxalonDarkstone changed the title Feature request: Audio transfer from source to new video Feature request: Audio transfer from source to final video May 6, 2024
@jcvijr
Copy link

jcvijr commented May 12, 2024

I use clipchamp to disconnect audio and put it again after getting mov2mov result. As a workaround.

@VBVerduijn
Copy link

Perhaps it would be possible to pass the movie file to an ffmpeg command to copy the audio; perhaps incorporated in the save_video function from mov2mov.py:

def save_video(images, fps, extension='.mp4'):
    if not os.path.exists(shared.opts.data.get("mov2mov_output_dir", mov2mov_output_dir)):
        os.makedirs(shared.opts.data.get("mov2mov_output_dir", mov2mov_output_dir), exist_ok=True)

    r_f = extension

    print(f'Start generating {r_f} file')

    video = images_to_video(images, fps,
                            os.path.join(shared.opts.data.get("mov2mov_output_dir", mov2mov_output_dir),
                                         str(int(time.time())) + r_f, ))
    print(f'The generation is complete, the directory::{video}')

    return video

You can copy the audio of one video to another using this ffmpeg command:
ffmpeg -i input_video_with_audio.mp4 -i input_video_without_audio.mp4 -c:v copy -map 0:v:0 -map 1:a:0 -shortest output_video_with_audio.mp4

The -shortest option makes sure the audio stops when there is no longer any video channel.

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

No branches or pull requests

3 participants