sd-webui-mov2mov icon indicating copy to clipboard operation
sd-webui-mov2mov copied to clipboard

Feature request: Audio transfer from source to final video

Open IxalonDarkstone opened this issue 9 months ago • 2 comments

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 avatar May 06 '24 01:05 IxalonDarkstone

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

jcvijr avatar May 12 '24 23:05 jcvijr

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.

VBVerduijn avatar May 14 '24 09:05 VBVerduijn