How I Edit My Videos With Python - Python Task Automation

  Рет қаралды 73,334

Patrick Loeber

Patrick Loeber

Күн бұрын

In this tutorial, I show you how I edit my videos using Python and MoviePy.
MoviePy is a Python module for video editing, which can be used for basic operations like cuts, concatenations, title insertions, video compositing, video processing, and even to create advanced effects.
✅ Write cleaner code with Sourcery, instant refactoring suggestions in VS Code & PyCharm: sourcery.ai/?... *
⭐ Join Our Discord : / discord
🚀🚀 Get monthly Python and ML Tips:
www.python-engineer.com/newsl...
🚀🚀 SUPPORT ME ON PATREON:
/ patrickloeber
If you enjoyed this video, please subscribe to the channel!
Moviepy: zulko.github.io/moviepy/index...
Code:
github.com/patrickloeber/pyth...
You can find me here:
Website: www.python-engineer.com
Twitter: / patloeber
GitHub: github.com/patrickloeber
Music: www.bensound.com/
Photo by Jakob Owens on: unsplash.com/photos/l82NzBSYbj0
#Python
----------------------------------------------------------------------------------------------------------
* This is a sponsored or an affiliate link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏

Пікірлер: 86
@yuvrajsingh-gm6zk
@yuvrajsingh-gm6zk 3 ай бұрын
As a video editor who is now a coding wannabe, this is pure gold man!!
@thedebapriyakar
@thedebapriyakar 2 жыл бұрын
Straight to the point and just mind blowingly well explained.
@patloeber
@patloeber 2 жыл бұрын
glad you like it!
@brendensong8000
@brendensong8000 2 жыл бұрын
Thank you for sharing this! Love all your video! It's very informative!!!
@markusbuchholz3518
@markusbuchholz3518 3 жыл бұрын
Hello Patrick, there are some but not so many YT channels which are prepared so outstanding like your. The effort and performance you deliver are remarkable, brilliant and impressive. You cover all the latest SW technologies and share your passion. Keep fingers for your goals.
@patloeber
@patloeber 3 жыл бұрын
Thanks so much for the kind words Markus!
@markusbuchholz3518
@markusbuchholz3518 3 жыл бұрын
@@patloeber Good luck!
@vegaarcturus509
@vegaarcturus509 Жыл бұрын
Very useful for Minecraft ASMR mining blocks and putting blocks. I know that this is applicable in a lot of situations
@rajukani100
@rajukani100 3 жыл бұрын
That's it i looking for. Awesome Bro !
@patloeber
@patloeber 3 жыл бұрын
Thank you!
@ThorstenMueller
@ThorstenMueller Жыл бұрын
I just found your channel. Great and really helpful content, thanks for providing it 🙂. Subscribed directly, of course.
@Micetticat
@Micetticat 3 жыл бұрын
I found your great tutorial because I was thinking how convenient would be to have a way to edit videos using code for some workflows.
@saralgyaan
@saralgyaan Жыл бұрын
It's very helpful video, will be trying it for sure.
@terraflops
@terraflops 3 жыл бұрын
this is so cool! Python can do so many things. Happy to know Python can edit videos and audio. Thanks!
@patloeber
@patloeber 3 жыл бұрын
Glad you like it
@quagmirev252
@quagmirev252 Жыл бұрын
Hey, Nice work! Really helpful for me :D i really want to thank you for the help!
@sikkavilla3996
@sikkavilla3996 3 жыл бұрын
this channel deserves more subscribers
@patloeber
@patloeber 3 жыл бұрын
thanks :)
@jrnpaulsen9926
@jrnpaulsen9926 Жыл бұрын
I've been thinking of doing something similar myself, but I'm trying to find a more efficient method for the manual work (in Audacity). One method could be to just use the label-function in Audacity, then find a way to extract/export all of the label-data (from/to/labelname). Another (more basic) improvement to the current workflow could be to link a hotkey to a script that adds track-selection start/end-time to the clipboard. Anyways, great video! There's so many tasks that (in large parts) can be be automated :)
@WebStacks500
@WebStacks500 7 ай бұрын
Thank You, now I'm gonna go and make a Video Editor in python with GUI - Quite a bit of work :)
@EveryLastdrop-tw6rg
@EveryLastdrop-tw6rg 14 күн бұрын
you can actually just open your videos in audacity by the way, but that code is awesome thank you for showing
@abhimanyunegi4382
@abhimanyunegi4382 3 жыл бұрын
Loved it Wass willing to make it myself, but you made it easier....👌👌👌
@patloeber
@patloeber 3 жыл бұрын
Thanks :)
@abhimanyunegi4382
@abhimanyunegi4382 3 жыл бұрын
@@patloeber Welcome ;)
@kamel3d
@kamel3d Жыл бұрын
is there a library to visualise all of this I mean to give it a visual interface like in classic editing software?
@JuanGabrielOyolaCardona
@JuanGabrielOyolaCardona 2 жыл бұрын
Thanks for the great content. Thanks for sharing 😃🇨🇴
@shantanudhiman5263
@shantanudhiman5263 2 жыл бұрын
I mean wow, this is better than any video editor, freaking awesome....!!!!!!!!!!!!!!!!!!!!!
@patloeber
@patloeber 2 жыл бұрын
yeah it's cool :)
@SerapioSergiovich
@SerapioSergiovich 4 күн бұрын
Nice video shows methods to create a business..
@brandonallen2301
@brandonallen2301 2 жыл бұрын
Came for the video editing tips. Reminded me that I majored in deep learning, lol
@hishamsomroz6913
@hishamsomroz6913 3 жыл бұрын
Great man
@CodeWithTomi
@CodeWithTomi 3 жыл бұрын
This is a great tutorial..
@patloeber
@patloeber 3 жыл бұрын
Thanks :)
@LanaDominkovic
@LanaDominkovic 2 жыл бұрын
Awesome, didnt even think about this possibility! Maybe I try to edit videos with Python :D
@patloeber
@patloeber 2 жыл бұрын
Go for it!
@wassyppp
@wassyppp 2 жыл бұрын
Great video! Is there a way to play the video and save the cuts by pressing a button (start/stop). Then just running this function. Thanks
@lukajeliciclux3074
@lukajeliciclux3074 3 жыл бұрын
@PythonEngineer do I see Tech with Tim and Corey Schafer in your subscription. 😃
@patloeber
@patloeber 3 жыл бұрын
Yes 😄
@todologic
@todologic 2 жыл бұрын
Great info!
@patloeber
@patloeber 2 жыл бұрын
Glad it was helpful!
@CustAndCode
@CustAndCode Жыл бұрын
pretty nice! 🤗
@christiangeng6070
@christiangeng6070 2 жыл бұрын
Thanks for the lovely video! I have one question not directly related to the content presented, but as you are demoing your screencasts I think this is still relevant: How are you recording your screencasts - before cutting them? For me especially relevant would be appropriate command line switches for ffmgeg under Linux.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
I have only done screen grabbing on Linux under X11. On Wayland, things will be different. I once did a capture of a 1280×720 region using a command like ffmpeg -f x11grab -video_size 1280:720 -framerate 25 -i :0.0+«offset» -vcodec png «dir»/frame%04d.png
@oneeyedphotographer
@oneeyedphotographer 2 ай бұрын
I might use this approach to add a standard preamble, to trim dead space to make the video fit the target duration (good for YT #shorts), add a trailer for the next episode as required. I think a standard GUI editor would be my go to for normal work. If I'm talking, make an error and reshoot that segment, this isn't going to handle it well. Similar if I record an interview, it might take an hour of shooting but need to be condensed to 15 minutes. Python can probably be made to drive Premiere Pro too, it can drive Photoshop.
@hoclaptrinh882
@hoclaptrinh882 3 жыл бұрын
Amazing!
@patloeber
@patloeber 3 жыл бұрын
thanks!
@azarmahmood1421
@azarmahmood1421 2 жыл бұрын
Hi with python pillow can it improve the video image quality or is it just pictures it does thankyou
@saurrav3801
@saurrav3801 3 жыл бұрын
Nice video bro 🤙🤙
@patloeber
@patloeber 3 жыл бұрын
thanks!
@rachit6099
@rachit6099 3 жыл бұрын
Thankyou so much :)
@patloeber
@patloeber 3 жыл бұрын
thanks!
@RozBizMedia
@RozBizMedia 9 ай бұрын
DUDE, I was wondering if this was possible :)
@efiratoglu
@efiratoglu 10 күн бұрын
Great video about MoviePy. But I really wonder how you were planning to define silent parts of a video to extract automaticaly. Would you please drop a few lines about the algorithm of that? TBH, I could not find the command to analyze the sound level in an audio clip to create croppin time stamps and that would be more than enough... Many thanks again for that great tutorial!
@muhammad_talha
@muhammad_talha 3 жыл бұрын
thanks
@narendrarao5989
@narendrarao5989 2 жыл бұрын
i want to add an audio test.mp3 of 2 secs to a video file of test.mp4 of 15 secs at multiple places like at 4th, 8 th , 12 th. what would be the approach?
@ClashBaseDeveloper
@ClashBaseDeveloper 9 ай бұрын
This is insane
@seanivore
@seanivore 7 ай бұрын
I have a database of images and text and can't find a no-code bulk automator for making video shorts. Canva came out with one but you can't change the background. I've never used code... will this be too hard for me???
@GoodBoyDanny
@GoodBoyDanny 3 жыл бұрын
I want to add a looping gif over music with out making a million cuts. Is that possible?
@JJSeattle
@JJSeattle 2 жыл бұрын
Ahahha okay, that was a funny disclaimer, "I don't use it myself for my KZbin videos, but you could." Ahahahaha that just tickled me.
@future9728
@future9728 2 жыл бұрын
Can we add an audio file that plays when with text overlay
@errorhostnotfound1165
@errorhostnotfound1165 3 жыл бұрын
--I'm not sure why __name__ is italicized and missing an _ on the right and left side in this comment, but I didn't write it like that. --What does if __name__ == '__main__': edit_video(loadtitle, savetitle, cuts) --do? --What is "libx264"? Does the video have to be ".mov" to ".mp4" or can it be ".mp4" to ".mp4"? Videoquality is "24", what happens if I increase/decrease that number? Instead of having title separate from loadtitle and savetitle, could I have loadtitle and savetitle be paths? What are cut[0] and cut[1] in for cut in cuts: clip = video.subclip(cut[0], cut[1]) clips.append(clip) --? Are they individual cuts or are they start of a number of cuts? If I have cuts = [('00:01:00.00', '00:00:02.00'), ('00:00:05.00', 00:00:07.00')] is it for cut in cuts: clip = video.subclip(cut[0], cut[4]) clips.append(clip) --or for cut in cuts: clip = video.subclip(cut[0], cut[1], cut[3], cut[4]) clips.append(clip) --? Also, I haven't been able to run it fully yet, but it seems that for Windows txt = mpy.TextClip('Please Subscribe!', font='Courier') fontsize=120, color='white', bg_color='gray35' txt = txt.set_position(('center', 0.6), relative=True) txt = txt.set_start((0, 3)) # (min, s) txt = txt.set_duration(4) txt = txt.crossfadein(0.5) txt = txt.crossfadeout(0.5) ... final_clip.write_videofile(savetitle, threads=4, fps=24) codec=vcodec, preset=compression, ffmpeg_params=["-crf", videoquality]) --needs to be rewritten as txt = mpy.TextClip('Please Subscribe!', font='Courier') txt = txt.mpy.TextClip(fontsize=120, color='white', bg_color='gray35') txt = txt.set_position(('center', 0.6), relative=True) txt = txt.set_start((0, 3)) # (min, s) txt = txt.set_duration(4) txt = txt.crossfadein(0.5) txt = txt.crossfadeout(0.5) ... final_clip.write_videofile(savetitle, threads=4, fps=24, codec=vcodec, preset=compression, ffmpeg_params=["-crf", videoquality]) --to avoid an unexpected indent error.
@abuazfaar3662
@abuazfaar3662 3 жыл бұрын
Beautiful 👍. Hey, I have some questions. Where do I reach out to you?
@patloeber
@patloeber 3 жыл бұрын
KZbin or Discord
@user-yz8yn4zc2i
@user-yz8yn4zc2i 3 жыл бұрын
Hi, I'm a student. I want to know how to clip the photos into a vedio with python like a function of the photo album and add some special effects when a photo changes. Thank you for your replying.
@yusun5722
@yusun5722 2 жыл бұрын
There might be a simpler way, but at least you can save the video frames as images, embed the photo to the correpsonding images and export the video.
@todologic
@todologic 2 жыл бұрын
Out of curiosity, why did you stop using this method and what software do you use otherwise?. Thanks.
@patloeber
@patloeber 2 жыл бұрын
It's not super convenient and limited in the features. You cannot do fancy video transitions or something. I switched to Davinci Resolve afterwards
@todologic
@todologic 2 жыл бұрын
@@patloeber thanks for the info. The problem that I have is that I can not find a good video editor that is parametric. I know you can use JS with Premiere, but it is limited.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
There is also “melt”, which uses the MLT framework. You can drive that via an XML control file.
@todologic
@todologic 2 жыл бұрын
I saw that Davinci Resolve has Python Scripting support. Have you tried it?
@patloeber
@patloeber 2 жыл бұрын
no I haven't but that's interesting
@todologic
@todologic 2 жыл бұрын
@@patloeber Would be nice for a video perhaps? ;).
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
I did a quick search, and it seems it has trouble with newer versions of Python.
@todologic
@todologic Жыл бұрын
@@lawrencedoliveiro9104 oh. Pitty…
@Kig_Ama
@Kig_Ama 3 жыл бұрын
How do we know the cut times? What if we have so many cut times? I am not sure, whether this works for my purpose.
@patloeber
@patloeber 3 жыл бұрын
Yes as I said, it is not suited for every workflow. You have to select the cut times manually by going through the video or audio line
@Kig_Ama
@Kig_Ama 3 жыл бұрын
@@patloeber true, ty. May be in future there will be an AI that decides this for u.🙃
@patloeber
@patloeber 3 жыл бұрын
@@Kig_Ama Yes, I think this is already possible (even without AI just by analyzing the sound intensity). But for my own recordings this task is more difficult because sometimes I don't talk but still write code on the screen. It's hard to detect this...
@Kig_Ama
@Kig_Ama 3 жыл бұрын
@@patloeber Amazing!
@AbdifatahNadir-fk7lc
@AbdifatahNadir-fk7lc 10 ай бұрын
Python is Every Think
@matthewpaquette
@matthewpaquette 2 жыл бұрын
cool. but like... nooooooo
@-raiwzo
@-raiwzo 2 жыл бұрын
Guys don't you feel weird while editing on python, I mean there should be a GUI there no ?
@suretmeyenateistoc4252
@suretmeyenateistoc4252 Жыл бұрын
ı'cant see ui? but nice click bait
@SerapioSergiovich
@SerapioSergiovich 4 күн бұрын
Nice video shows methods to create a business..
Video Data Processing with Python and OpenCV
32:05
Rob Mulla
Рет қаралды 65 М.
Making Automatic YouTube videos with Python
7:32
Shifty the Dev
Рет қаралды 172 М.
She’s Giving Birth in Class…?
00:21
Alan Chikin Chow
Рет қаралды 10 МЛН
ПООСТЕРЕГИСЬ🙊🙊🙊
00:39
Chapitosiki
Рет қаралды 16 МЛН
КАК СПРЯТАТЬ КОНФЕТЫ
00:59
123 GO! Shorts Russian
Рет қаралды 3,1 МЛН
Writing a Program that Edits my Videos
10:39
Devon Crawford
Рет қаралды 1,5 МЛН
The new MAZ X trailer - amazing!
23:40
808
Рет қаралды 364 М.
Automate your job with Python
6:07
John Watson Rooney
Рет қаралды 331 М.
5 Amazing Ways to Automate Your Life using Python
18:40
Internet Made Coder
Рет қаралды 190 М.
Using Python and AI to Automate My Video Editing Process
16:50
Awesome Python Automation Ideas
11:50
Patrick Loeber
Рет қаралды 112 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
How I Make Videos for Programmers (on Fireship.io)
9:03
Jeff Delaney
Рет қаралды 423 М.
Introducing Python in Excel
19:01
Leila Gharani
Рет қаралды 1,5 МЛН
Top 10 Python One Liners YOU MUST KNOW!
4:52
Patrick Loeber
Рет қаралды 137 М.
She’s Giving Birth in Class…?
00:21
Alan Chikin Chow
Рет қаралды 10 МЛН