I am trying to write a program that can download videos from Reddit posts. I believe that Reddit stores the audio and video for each post separately, so I am currently downloading the mp3 and the mp4 and then combining them to make a final video file. I am not very familiar with audio or video files or how they are stored, but I thought that combining the two would be quick to compute.
However, the combining part is very slow and I was wondering if there is a faster way of combining a soundless video clip with an audio file and writing it to my drive?
I am currently using the moviepy library for the combining.
def download_video(data_url,current_post,subreddit):
#Get the audio url of Reddit video
audioURL = data_url + "/audio"
#Get the soundless video url of reddit video
videoURL = str(current_post).split("'fallback_url': '")[1].split("'")[0]
#Get the title of the post
postname = (current_post['title'])
#Download the two files as mp4 and mp3
urllib.request.urlretrieve(videoURL, subreddit + '/video_name.mp4')
urllib.request.urlretrieve(audioURL, subreddit + '/audio.mp3')
#Combine the mp3 and mp4
videoName = str(subreddit + "/" + get_valid_filename(current_post['title'])) +".mp4"
video = mpe.VideoFileClip(subreddit + '/video_name.mp4')
video.write_videofile(videoName, audio=subreddit + "/audio.mp3")
#Remove video file with no audio
del video
os.remove(subreddit + '/video_name.mp4')