I have a list of videos (all .mp4), that I would like to combine to one large .mp4 video. The names of the files are as following: vid0.mp4, vid1.mp4, vid2.mp4, .... After searching, I found a Quora question which explains that the main file should be opened, then all sub files should be read (as bits) and then written. So here is my code:
import os
with open("MainVideo.mp4","wb") as f:
for video in os.listdir("/home/timmy/sd/videos/"):
temp=open('/home/timmy/sd/videos/%s'%video)
h=temp.read()
'''
for i in h:
f.write(i) #Error
'''
f.write(h)
temp.close()
This is only writing the first video. Is there a way to write it without using outside libraries? If not, please refer me to one.
I also tried the moviepy library but I get OSError.
code:
from moviepy.editor import VideoFileClip, concatenate_videoclips
li1=[]
for i in range(0,30):
name_of_file = "/home/timmy/sd/videos/vid%d.mp4"%i
clip = VideoFileClip(name_of_file)
#print(name_of_file)
li1.append(clip)
I get OSError after the 9th clip. (I think this is because of the size of the list.)