Video bitrate decreased after writing a video

Viewed 563

I am trying to write a python function to add a video from one video to another video(which has no sound) using moviepy. First of all, I tried with just

clip = mpe.VideoFileClip(video-to-add-sound.mp4)
clip = clip.set_audio(mpe.AudioFileClip(video-that-has-sound.mp4))

which doesn't do anything. So, I realized that I did not write_videofile to clip So, I create a function

def addAudioBack(original_vid, processed_vid):

    clip = mpe.VideoFileClip(processed_vid)
    clip = clip.set_audio(mpe.AudioFileClip(original_vid))
    clip.write_videofile(processed_vid,codec='libx264')

which will add the audio from original_vid to processed_vid and overwrite the old processed_vid to a new one that has an audio from orignal_vid. The sound worked well but the problem is that my video bitrate and datarate is decreasing in a way that it make the video quality look worse. I tried adding bitrate='3000k' to the last line but it doesn't work. The original one has about 3000kbps but the edited one decreased to about 300 or below.

PS. I edited the last line to not overwrite the old file and write a new file. The bitrate improve to about 900kbps but what I want is the video with the similar bitrate to my old video(that going to add the sound)

So, how can I write a video based on my purpose above that make the same or almost the same bitrate to my original video?

Thank you

0 Answers
Related