Closed jantic closed 5 years ago
It's easy for ffmpeg to remux the audio track back from the original one. Such as
ffmpeg -i original.video -vn -acodec copy temp.aac ffmpeg -i results.video -i temp.aac -codec copy final.video
Thanks! I'll try this soon.
This is what you need:
from moviepy.editor import *
# get the original video
videoclip = VideoFileClip('original.mp4')
# extract the audio from video
audioclip = videoclip.audio
# DeOldify video as usual and get the colorized output
video = VideoFileClip('colorized_output.mp4')
# set audio
final = video.set_audio(audioclip)
# save with required settings (mostly to make Quicktime happy and recognize the audio): https://github.com/Zulko/moviepy/issues/820
final.write_videofile("final_output.mp4", codec='mpeg4', audio_codec='aac', temp_audiofile='temp-audio.m4a', remove_temp=True)
You can look at the options for saving here: https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html
Quicktime is really annoying and won't recognize the audio so you have to set those codecs for it.
Love the project. Great job! :)
Working pretty well :)
https://www.youtube.com/watch?v=JACcWJRUkYc&feature=youtu.be
Sweet! One more thing I should mention. I realized that writing the Video to mpeg4 leads to bad quality video (for some reason). If you change the codec to libx264, the quality is much better!
final.write_videofile(out, codec='libx264', audio_codec='aac', temp_audiofile='temp-audio.m4a', remove_temp=True)
Bonus: You can add a thread parameter to leverage multithreading which leads to a much faster operation. Example:
final.write_videofile(out, codec='libx264', threads=64, audio_codec='aac', temp_audiofile='temp-audio.m4a', remove_temp=True)
Yep also saw the bad quality, fixing it
Ok guys, this functionality is merged in now. Thanks!
Title says it all. Having audio dropping from videos sucks.