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
  • НаукаНаука

Комментарии • 31

  • @nash-p
    @nash-p Год назад +2

    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 👍

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! I’m really glad the tutorial helped. Happy to hear you also found a better way to cut audio 😁

  • @yao_barna
    @yao_barna Год назад +3

    Great tutorial, thanks! Very useful.

  • @mangoship
    @mangoship Год назад +2

    This was very helpful, thanks!

  • @birukgetnet6062
    @birukgetnet6062 Год назад +2

    Thank you sir. It helped me alot.

  • @CarlosHenrique-er7zq
    @CarlosHenrique-er7zq Год назад +3

    Thank you for the help, it was excatly what I needed.

  • @JohnCarrFitness
    @JohnCarrFitness 2 года назад +3

    Excellent teaching! Keep it up! You’ve got a skill most programmers don’t!

  • @adityachauhan4325
    @adityachauhan4325 Год назад

    Hi, could you tell me why the video resolution is reduced by the code?

  • @HoorayforOranges
    @HoorayforOranges Год назад +1

    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?

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      The format is a key on the in_file_probe_result the format then has a key on it called duration. Hope that helps!

  • @hanaalalawi4321
    @hanaalalawi4321 Год назад +2

    Thanks for this tutorial! Is it possible to trim based on a condition, for example, I want to trim based on a sentence

    • @CodingWithAdam
      @CodingWithAdam  Год назад +2

      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.

    • @hanaalalawi4321
      @hanaalalawi4321 Год назад +1

      @@CodingWithAdam Sure, I'm still working on it.

  • @AndreGomes-em5vy
    @AndreGomes-em5vy 3 месяца назад

    How to use this in Google Colab? How to ensure the installation of FFMPEG?

  • @mylesgxtreme2106
    @mylesgxtreme2106 2 года назад +1

    can you set it to cut multiple times in on video like take out 5 seccend every 30 second or so

    • @CodingWithAdam
      @CodingWithAdam  2 года назад +1

      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.

    • @yao_barna
      @yao_barna Год назад +1

      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.

  • @alkispiskas3580
    @alkispiskas3580 Год назад

    Why do you use `probe_result.get("format").get("duration")` when you can use simply `probe_result["format"]["duration"]` ?

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      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 😀

  • @JohnCarrFitness
    @JohnCarrFitness 2 года назад +1

    Could you put that code on github to share?

    • @CodingWithAdam
      @CodingWithAdam  2 года назад +2

      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

    • @JohnCarrFitness
      @JohnCarrFitness 2 года назад +2

      @@CodingWithAdam Thanks Adam! You da man! Can i ask.. how long have you been programming? I'm newer here.. thanks

    • @CodingWithAdam
      @CodingWithAdam  2 года назад +2

      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!

    • @JohnCarrFitness
      @JohnCarrFitness 2 года назад +2

      @@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!

    • @CodingWithAdam
      @CodingWithAdam  2 года назад +1

      Thank you John! I really appreciate the kind words. I’ll do my best :)