#๐Ÿ”’ Exporting a video to a different folder

15 messages ยท Page 1 of 1 (latest)

quick hawk
#

I'm pretty new to Python, so I hope this isn't too confusing. I'm using a module called Moviepy and I'm trying to export a video to a folder within the folder that the python script is in. If that made no sense, here is the folder structure:

VideoCreator |-- VideoCreator.py |-- BackgroundClips | |-- input.mp4 |-- OutputVideos | |-- output.mp4

Here is my current code:

# input video
clip = VideoFileClip("Video_Test_4k.mkv").subclip(50,60)

# random example text
txt_clip = TextClip("Example Text",fontsize=70,color='white')

# Overlay the text clip on the first video clip
video = CompositeVideoClip([clip, txt_clip])

# export video
video.write_videofile("Video_Test_4k_edited.mp4")

Right now, this script takes a video within the VideoCreator folder and exports it within the same folder. What I want it to do is pull a video from BackgroundClips, edit it within VideoCreator.py, and export it to OutputVideos. I'm not sure if this is something that can be done within python or if it takes something directly from the module itself, but I read the documentation for this method (https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html?highlight=write_videofile#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.write_videofile) and couldn't find anything. Thanks!

viscid valleyBOT
#

@quick hawk

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

vestal mason
#

eg. /path/to/VideoCreator/OutputVideos/xyz.mp4
or just OutputVideos/xyz.mp4 might work

quick hawk
#

okay ill try that out

sage parrot
quick hawk
#

no idea why i didnt think of that haha

#

sorry im quite new to python and don't really understand those terms, do you have an example?

#

i know i got it working but no harm in learning more

sage parrot
# quick hawk sorry im quite new to python and don't really understand those terms, do you hav...

and combine that with pathlib to make your life easier

from pathlib import Path

current_file = __file__  # this is a string containing the absolute path to the current python script
script_directory = Path(current_file).parent  # this is the folder containing the script you're currently running; in your code that'd be `VideoCreator`
output_directory = script_directory / 'OutputVideos'
output_video = output_directory / 'video.mp4'

video.write_videofile(str(output_video))  
quick hawk
#

ohh okay i understand

#

thanks for the help :)

viscid valleyBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.