How to Trim Videos Using Python and FFMPEG
HTML-код
- Опубликовано: 1 авг 2024
- In this exciting video we are going to learn how to trim a video using Python and FFMPEG.
I will guide you through setting up the python project in VSCode. I assume you have Python 3 and Pipenv installed. Using the FFMPEG-Python package we will trim a video.
I will show you how to install the FFMPEG command line tool on Mac and Windows
FFMPEG Python video has no sound after trim? As we will discover the video and audio must be trimmed separately and then concatenated together. If you don't do this then your video will have no audio.
GitHub
github.com/CodingWith-Adam/tr...
FFMPEG-Python
github.com/kkroening/ffmpeg-p...
Brew Package Manager for Mac
brew.sh/
Chocolatey Package Manager for Windows
chocolatey.org/install#indivi...
Chapters
00:00 Intro
00:43 FFMPEG installed?
1:12 FFMPEG Mac Install
1:40 FFMPEG Win Install
2:03 Project setup
3:15 Install FFMPEG-Python
3:46 Code
10:59 Probe Trim
12:02 Trim duration off by a little bit?
#python #programming #coding #ffmpeg #ffmpeg-python - Наука
Thank you so so much, I've been trying for over two hours to figure out the syntax for trim. Not only do I know how to use trim, but I found a better way to cut audio with the filter method 👍
You’re welcome! I’m really glad the tutorial helped. Happy to hear you also found a better way to cut audio 😁
Great tutorial, thanks! Very useful.
Thanks! You’re welcome!
This was very helpful, thanks!
You’re welcome!
Thank you sir. It helped me alot.
You’re welcome! Happy it helped!
Thank you for the help, it was excatly what I needed.
You’re welcome!
Excellent teaching! Keep it up! You’ve got a skill most programmers don’t!
Thank you!
Really? If so, he may join in the microsoft, right?
Hi, could you tell me why the video resolution is reduced by the code?
Hi, on line 10 of app.py why do you check for the format before checking for the duration, why not just call get on the duration key instead?
The format is a key on the in_file_probe_result the format then has a key on it called duration. Hope that helps!
Thanks for this tutorial! Is it possible to trim based on a condition, for example, I want to trim based on a sentence
That's an interesting question. There is nothing I know that is built into FFMPEG that would do that. For this to be possible the video would have to transcribed and time coded to the transcription. It's a very interesting topic and if you figure it out please let me know.
@@CodingWithAdam Sure, I'm still working on it.
How to use this in Google Colab? How to ensure the installation of FFMPEG?
can you set it to cut multiple times in on video like take out 5 seccend every 30 second or so
I have not tried it but It seems like you should be able to. You would then join all the parts together to form a complete video.
I just landed on this tutorial and haven't tried this much but once you have a function that works for a (startTime, endTime) interval, you could make use of this function to run it in the range you desire. It's just an idea of how to begin with.
Why do you use `probe_result.get("format").get("duration")` when you can use simply `probe_result["format"]["duration"]` ?
When you use get you can specify a default value if it is not found. I believe I specified a empty object as the default. You are 100% right that you can simply use the array key value. Both are valid approaches 😀
Could you put that code on github to share?
Thanks for noticing the code was not linked. I updated the description and here is the link github.com/CodingWith-Adam/trim-videos-with-ffmpeg-python
@@CodingWithAdam Thanks Adam! You da man! Can i ask.. how long have you been programming? I'm newer here.. thanks
You’re welcome! I’ve been programming for a long time almost 19 years. It’s a fun career with lots of learning. I started this channel as a hobby project to help mentor through interesting projects. Congratulations on learning to code it can be a lot of fun!
@@CodingWithAdam So awesome Adam! I can tell you know this stuff much deeper than most youtubers. Please keep your channel up! Youre a great teacher!
Thank you John! I really appreciate the kind words. I’ll do my best :)