Search code examples
pythonmoviepypython-os

Choosing an output directory for MoviePy


So I'm walking a directory that has clips that need to be concatenated.
I'm having a problem where my output (final_clip) is being written to the directory where the script is stored. How can I change this?
I looked in the documentation but couldn't find anything.

for count, file in enumerate(os.listdir(r"Z:/channel/clips to use/")):
    clip1 = VideoFileClip(r"Z:/channel/resources/comp1.avi")
    clip2 = VideoFileClip(r"Z:/channel/clips to use/"+file)
    final_clip = concatenate_videoclips([clip1,clip2])
    final_clip.write_videofile("done"+file)

Solution

  • use os.chdir(path) to navigate to the desired directory and then perform write operation or you can use os.path.join to concatenate path