I'm trying to concatenate videos in each folder so that I get one video in each folder instead of multiple short ones. This is an external USB drive if that matters.
My code seems to iterate over the files as expected, but I keep getting this error after the audio is written, during the "writing video" action, I believe: b"[NULL @ 000002a8340ae640] Unable to find a suitable output format for 'D:\\taxes\\folder\\test'\r\nD:\\taxes\\folder\\test: Invalid argument\r\n"
I haven't found a way to force an output format yet. Any thoughts?
import os
from moviepy.editor import *
startingDir = r'D:\taxes'
avoid = ['0incomplete', 'old', 'that', 'this']
for thing in os.listdir(startingDir):
clips = []
name = ''
if thing in avoid:
print(' avoided {}'.format(thing))
continue
folder = os.path.join(startingDir, thing)
if os.path.isdir(folder):
for clip in os.listdir(folder):
print (clip)
clips.append(VideoFileClip(os.path.join(folder, clip)))
print('\n')
try:
final = concatenate_videoclips(clips)
final.write_videofile(os.path.join(folder, 'test'), audio=True, codec='libx264', threads=10)
final.close()
except Exception as e:
print (e)
print('\n Continuing... \n\n')
continue