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

How to retain the audio of the vidoes? #107

Open
purnimakumarr opened this issue May 5, 2024 · 1 comment
Open

How to retain the audio of the vidoes? #107

purnimakumarr opened this issue May 5, 2024 · 1 comment

Comments

@purnimakumarr
Copy link

Hi, I'm using the pre-trained SRGAN model to enhance some videos. The vidoes I'm putting as input also contains audio. But I'm loosing the audio in the output videos. Can anyone suggest how I can retain the audio?

@HectorPulido
Copy link

Using moviepy:
With this code, you can extract the audio from the input video

    video = VideoFileClip(video_path)
    video.audio.write_audiofile(mp3_path)

Then add the audio to your output video with this other code

from moviepy.editor import *

videoclip = VideoFileClip(new_video_path)
audioclip = AudioFileClip(mp3_path)

new_audioclip = CompositeAudioClip([audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile(new_video_path_with_audio)

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

2 participants