Video editing with Python

Hey!
Is there a python library that can import 2 video clips, change X & Y positions of each clip (and even stretch the clip’s aspect ratio making the clip bigger), then render it to 1 single mp4 file? Also if could set the output resolution that would be really good too…

Thanks in advance!

Sounds like you want ffmpeg. Your Python script can craft the arguments to ffmpeg, then use the subprocess module to invoke it.

This looks like a good Python wrapper for FFmpeg:

I write code that does video editing like this. I do not know whether or not there is a Python library which will do it. There is definitely a stand-alone command-line program which will, and that is FFmpeg. That is what I use.

However, FFmpeg is difficult to learn how to use. Python won’t help you much with the learning. The ffmpeg-python wrapper which @vbrozik pointed out can simplify some of the syntax manipulation, but it still requires you to figure out which FFmpeg filters to invoke, and which parameters to pass them. I do not use ffmpeg-python in my work. It did not solve any of the hard problems I faced. I wrote my own code to put together the filter names and parameters, and then invoked FFmpeg via subprocess.run().

Another library which does video editing and which you can call from Python is GStreamer. It is a library of C function calls, with a Python wrapper somewhere, rather than a command-line program. I have not used it, but there are days when I wish I could justify the work of switching from FFmpeg to GStreamer.

Good luck with your search. If you find other alternatives, please post back here and let us know about them.

2 Likes

Sounds like you want ffmpeg. Your Python script can craft the arguments to ffmpeg, then use the subprocess module to invoke it.

Moreover, you can check this…
https://discuss.python.org/t/moviepy-progress-bar-to-tkinter-one/10048