0

So basically, my code is supposed to edit the videos in a given directory for the first 15 seconds, the middle 15 seconds, and the last 15 seconds. I'm on python 2.7 and i'm using the moviepy module.

import moviepy.editor as mp
from moviepy.editor import *
import os

for item in os.listdir(wildcard):
    clip = VideoFileClip(vid + item)
    dur = clip.duration
    firstHalf = (dur/2.0) - 7.5
    secHalf = (dur/2.0) + 7.5
    end = dur - 15.0
    clip1 = clip.subclip(0, 15.0)
    clip2 = clip.subclip(firstHalf, secHalf)
    clip3 = clip.subclip(end, int(dur))
    video = mp.concatenate([clip1,clip2,clip3])
    video.to_videofile(wildcard, fps=24, codec='mpeg4')

But I keep getting an error at the video = mp.concatenate() line. I'm not sure why, but it outputs the message "Errno 22: Invalid Argument."

lesley2958
  • 2,538
  • 4
  • 15
  • 15

1 Answers1

1

Can you post the whole error message ?

Here are some things you can try:

mp.concatenate

should be replaced with

mp.concatenate_videofiles

and

video.to_videofile(wildcard, fps=24)

should be replaced with

video.write_videofile("some_name.mp4", fps=24)
Zulko
  • 3,540
  • 1
  • 22
  • 18