How cut videos into clips using ffmpeg

Поділитися
Вставка
  • Опубліковано 21 кві 2020
  • 🎨 Artist/Thumbnail Creator: jawhaj.art
    📝 Blog: donaldfeury.xyz/topics
    👥Memberships: vod.strms.net/j/UCTHij3Ac5Giz...
    In this video I show you how to cut sections of video and audio out into separate files for use in your projects by only using ffmpeg. This is part of a series about automating video editing.
    THANK YOU ###
    Newest Channel Member -
    Newest Subscriber - Phillip Lineburg
    WANT TO SUPPORT THE CHANNEL? ###
    💰 Support Links: donaldfeury.xyz/donate
    WANT TO ASK ME A QUESTION? ###
    💬 Contact Me: donaldfeury.xyz/contact
    SOCIAL PLATFORMS ###
    🗣 Matrix: donaldfeury.xyz/matrix
    💬 Pleroma: donaldfeury.xyz/pleroma
    🗨️ Discord: donaldfeury.xyz/discord
    🐦 Twitter: donaldfeury.xyz/twitter
    VIDEO PLATFORMS ###
    🎦 Twitch: donaldfeury.xyz/twitch
    🎥 Odysee: donaldfeury.xyz/odysee
    OTHER THINGS ###
    📁 GitLab: donaldfeury.xyz/gitlab
    🎥 My Gear: kit.co/dfeury
    SOFTWARE I USE ###
    🌐 Brave Browser - brave.com/
    🎞 ffmpeg: ffmpeg.org/
    📽️ Open Broadcaster Software: obsproject.com/
    🎨 GIMP: www.gimp.org/
    📙 Neovim: neovim.io/
    Thank ya'll for your time and support!
    #ffmpeg #cutvideo #videoediting
  • Наука та технологія

КОМЕНТАРІ • 64

  • @DonaldFeury
    @DonaldFeury  4 роки тому +19

    Fun Fact - I edited this entire video without an editor, only used ffmpeg

    • @sytzebuz
      @sytzebuz 4 роки тому +2

      You know your stuff...legend!

    • @DonaldFeury
      @DonaldFeury  4 роки тому

      Nah, I'm just teaching things as I figure them out

    • @DonaldFeury
      @DonaldFeury  4 роки тому

      @11Lips You can get the full duration of your video using ffprobe, which you probably already have if you have ffmpeg installed, try something like this in your script somewhere:
      ffprobe -i %%a -show_entries format=duration -v quiet -of csv="p=0"
      Store that in a variable and subtract 5 and bam you have your new video duration, then just do:
      -to (VIDEO_DURATION_VARIABLE_HERE), instead of -ss 15

    • @DonaldFeury
      @DonaldFeury  4 роки тому

      @11Lips Thats probably not going to run since I doubt you have the "bc" program installed. I would advise you look up a basic batch scripting tutorial, otherwise, most of what I show or tell you isn't going to make sense.

    • @DonaldFeury
      @DonaldFeury  2 місяці тому

      @@plowe6751 Premier Pro is definitely not free from what I remember. Other than DaVinci I think there is kdenlive and olive I remember seeing www.youtube.com/@BrodieRobertson make a video or two on

  • @softengi4043
    @softengi4043 Рік тому +4

    @12:28 You can actually use the `-to` option to specify a direct timestamp to stop at in combination with the preemptive `-ss` option acting upon the input file; but it takes some extra options to make it work.
    ffmpeg -ss 00:16:00 -i ow-beanie.mp4 -to 00:16:15 -copyts -avoid_negative_ts make_zero -c copy ow-beanie-outro-fast.mp4
    The `-copyts` option will copy the timestamps over from the input so that the `-to` option targets correctly. But you also need the `-avoid_negative_ts make_zero` option so that your output video will then start at 00:00 - otherwise you'll see the video start playing with a 16:00 timestamp at the beginning, having been copied over from the input without being adjusted.

  • @rpatros
    @rpatros 2 роки тому +5

    I do wanted to add that I was also able to parse a 30 minute video in small chunks using ffmpeg which tool maybe 5 seconds and this is a thank you to Donald for clearly showing the power of ffmpeg:
    ffmpeg -i hybrid_setup-2021-02-19_12.11.06.mkv -ss 00:00:00 -to 00:15 -c copy hybrid1.into.mkv -ss 00:00:50 -to 00:01:57 -c copy hybrid-sync.mkv -ss 00:2:33 -to 00:05:14 -c copy hybrid-cloud-ui.mkv -ss 00:25:05 -to 00:25:35 -c copy hybrid-pac.mkv
    [rpatros@patros-pc Videos]$ ls -lh hybrid*.mkv
    -rw-r--r-- 1 rpatros rpatros 378K Nov 14 10:32 hybrid1.into.mkv
    -rw-r--r-- 1 rpatros rpatros 7.3M Nov 14 10:32 hybrid-cloud-ui.mkv
    -rw-r--r-- 1 rpatros rpatros 1.5M Nov 14 10:32 hybrid-pac.mkv
    -rw-r--r-- 1 rpatros rpatros 76M Feb 19 2021 hybrid_setup-2021-02-19_12.11.06.mkv
    -rw-r--r-- 1 rpatros rpatros 3.3M Nov 14 10:32 hybrid-sync.mkv
    You can see the sizes for each file output vs, the original being at 76mb. This is really nice since we don't have to re-encode the video as we kept the file format the same. With the video editor, it would have taken much much longer.

    • @DonaldFeury
      @DonaldFeury  2 роки тому +1

      Very nice, well done

    • @SheolicSeraph
      @SheolicSeraph 6 місяців тому

      Thank you so much! This is an absolute godsend lol; I've spent the past three days trying to album split with ffmpeg and can finally do it.

    • @nottyseel949
      @nottyseel949 3 місяці тому

      THANKS!! Been searching for this exact solution as I need so segment 100s of videos of various talks that are not of similar length. I have the timestamps and was hoping I could break the one video into its various segments with a single function.
      Just to be sure, though, the time after the "-to" represents a duration after the "-ss (timestamp)" or is it a second timestamp? Meaning for the "hybrid-pac.mkv" the file size looks like it's a 30s video, not a 25m35s video. I had read a moment ago (and thought he explained in the video 13:00) that the time value after the "-to" was read as a duration after the "-ss (timestamp)".

  • @adewolemayowa
    @adewolemayowa 3 роки тому +4

    Thanks for taking the time out to do this. Great job bro. Very helpful.

  • @Shockwaveo
    @Shockwaveo 2 роки тому +2

    i just use this for cutting video or audio ( ffmpeg -ss 00:00:00.000 -i "input.mp4" -to 00:00:10.000 -c copy "output.mp4" )

  • @monsieurBoutte
    @monsieurBoutte 3 роки тому +5

    These videos are so incredibly helpful! 🙏

  • @ArturoJReal
    @ArturoJReal 4 роки тому +2

    Wildly helpful, thanks!

  • @dodgewagen
    @dodgewagen Рік тому +1

    Thank you! Very useful!

  • @JohnCarrFitness
    @JohnCarrFitness 2 роки тому +1

    for python users: import os then use os.system() function to put that command and run it off of your editor. I had to learn this since your mostly a linux programmer. I appreciate the video!

  • @kurnitb
    @kurnitb 2 роки тому +1

    Thank's mate, these vids are really helpful! And of course, have subscribed and hit the like button, :)

    • @DonaldFeury
      @DonaldFeury  2 роки тому +1

      Thanky, I'm glad they helped

  • @benoy47
    @benoy47 3 роки тому

    A very good video about this item. Thanks.

  • @user-lc1ph5jg5k
    @user-lc1ph5jg5k 3 роки тому +1

    thanks. it's very helpful video

  • @umuden
    @umuden 3 місяці тому

    'olly 'ell nice to meet you man

  • @dragon3602010
    @dragon3602010 3 роки тому +2

    hey, that's freakin awesome.
    Did you already make a vertically scrolling of an image until the end , so to make it like a video ?Thanks

    • @DonaldFeury
      @DonaldFeury  3 роки тому +1

      Never had a need to so I did not

  • @blocksrey
    @blocksrey 6 місяців тому +1

    What shell do you use?

  • @hernandoramos
    @hernandoramos 4 роки тому +4

    Hi
    I'm a video editor an i really like ffmpeg and what you are doing. I think in this times when video is a very important part of our lives this kind of approach to video editing is really useful for many reasons.
    I want to say thank you for let us see how you are doing your video editing, seeing the process is so much helpful than seeing a man page or a written tutorial.
    Do you think is there a way to generate a list of in points and out points for a group of video files in a directory, then pass the list file to ffmpeg to do the trimming?
    I know is not easy, I try myself but couldn't achieve the list file.
    If there were a way to generate this list you could review all the video files in the order you want those in your final video, set the in and out points for each video file, the run something like your script that takes the list with the in and out point for each file and bam! In theory you have a workflow for get your editing done just after reviewing your shots for your video.
    Thanks again and see you around.

    • @DonaldFeury
      @DonaldFeury  4 роки тому +2

      In theory it sounds possible, you would have to clarify on what basis the in and out points are being generated.
      As for how to generate them in a way that could be passed into ffmpeg, you could maybe do something like a CSV file? Where you do each row has (FILE_PATH,IN,OUT), then in the language of your choosing, iterate over the CSV file, and for each entry, generate a ffmpeg command to write only that section out to a seperate file using the -ss flag to set the IN timestamp and the -to flag to set the OUT timestamp. Since you would just be writing a section of the stream out, you can use -c copy to avoid re-encoding and it should be pretty quick.

    • @hernandoramos
      @hernandoramos 4 роки тому +1

      @@DonaldFeury Oh! maybe a cvs file, I don't have any experience programming so I really don't know. I'm thinking in learning python just for this because is really useful, for example to generate a selects reel or put together a quick edit, or generate an edl/xml file to bring specific materials to your NLE.
      As an editor I really spend a lot of time in the file manager, namely windows explorer or apple finder, always thought my edits start right there, reviewing and organizing the material, to then put that in the NLE. But if there where a layer in the file manager that allows you with this kind of workflows it will be invaluable.
      Question. Do you think python is adequate for this purpose?
      I guess i will keep looking for something like I want. Cheers!!!

    • @DonaldFeury
      @DonaldFeury  4 роки тому +1

      @@hernandoramos python would be great for it. Check a python library someone on reddit made me aware of called moviepy, i'm messing with it to do auto trimming based on silence

  • @ajadavis2000
    @ajadavis2000 Рік тому

    liked and subscribed! trick request: trying to figure out a similar "preview" feature that a video editor has using streams

  • @rpatros
    @rpatros 2 роки тому

    You got a subscriber here for the way you show ffmpeg usage.
    One question is, can you splice the input video into multiple output files using different timestamp in a command.
    edited: I did manage to create multiple video outputs and included it in the next comment.

    • @DonaldFeury
      @DonaldFeury  2 роки тому +1

      This is probably close but it's splitting into even segments rather than at specific timestamps
      medium.com/@taylorjdawson/splitting-a-video-with-ffmpeg-the-great-mystical-magical-video-tool-%EF%B8%8F-1b31385221bd

  • @MoreChannelNoise
    @MoreChannelNoise 4 роки тому +1

    suggestion for video. take a long album track and cut it up into single tracks going by the short silences inbetween tracks. I dont know how to do that. Guess you would need to make a timestamp file first?

    • @DonaldFeury
      @DonaldFeury  4 роки тому

      Hmm that's not a bad idea, ye you would need to generate timestamps using something like the detectsilence filter.

  • @Zatra
    @Zatra 5 місяців тому

    OVERWATCH 😍😍😍😍😍😍

  • @maxpolaris99
    @maxpolaris99 2 роки тому +1

    yall come back now ya hear.

  • @sokvattanak4895
    @sokvattanak4895 2 роки тому

    Hello sir,
    I want to remove last 5 second of video. Help me please

  • @robinreso6240
    @robinreso6240 3 роки тому +2

    Do you maybe know if it is possible to do an B-roll insert edit,L-cut or J-cut using ffmpeg using losseless copy techniques?thx

    • @DonaldFeury
      @DonaldFeury  3 роки тому +1

      Possibly, actually there is a good tool for that exact thing built on top of ffmpeg called editly, you should check it out - github.com/mifi/editly

    • @robinreso6240
      @robinreso6240 3 роки тому +2

      @@DonaldFeury thx i will check it out

    • @DonaldFeury
      @DonaldFeury  3 роки тому +2

      Np, let me know how it goes

    • @robinreso6240
      @robinreso6240 3 роки тому +1

      @@DonaldFeury i will.thx

  • @user-lc1ph5jg5k
    @user-lc1ph5jg5k 3 роки тому +1

    hi. should i care about TS while cut video?

    • @DonaldFeury
      @DonaldFeury  3 роки тому +2

      timestamps? I haven't really run into an issue with timestamps before when cutting clips out like this.
      Now, if you go to concat them back together with re-encoding you may have weird issues. If that happens just let the re-encode happen.

  • @centralindian
    @centralindian 3 роки тому

    how to clip multiple clips with one command?

  • @ZuroiA
    @ZuroiA Рік тому +1

    What kind of command prompt are you using? Where can I get one?

  • @Neverrite
    @Neverrite Рік тому

    it keeps saying no such file or directory

  • @MoreChannelNoise
    @MoreChannelNoise 4 роки тому +1

    I keep using -acodec copy -vcodec copy, so there is no need for that? I can just use
    ffmpeg -ss 32 -i input.mov -c copy output.mov

    • @DonaldFeury
      @DonaldFeury  4 роки тому

      Ye, *-c* is just a shorthand to tell ffmpeg to copy both video and audio codecs. *-c copy* is the same as *-vcodec copy -acodec copy*

  • @techwithshudarsan559
    @techwithshudarsan559 2 роки тому +1

    ffmpeg -i 1raw.mp3 -t 15 -c copy output.mp3
    [mp3 @ 0x558ad1bb4740] Invalid audio stream. Exactly one MP3 audio stream is required.
    Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
    Getting this error. What's wrong here?

    • @DonaldFeury
      @DonaldFeury  2 роки тому

      donaldfeury.xyz/contact/ contact me through any of these methods and I'll be glad to help

  • @danielfrancis1889
    @danielfrancis1889 3 роки тому +1

    I'm trying to remove green screen, can you help me?
    "-vcodec": "libx264",
    "-r": 25,

    "-filter_complex":"[1:v]colorkey=color=00FF00:similarity=0.85:blend=0.0[ckout];[0:v][ckout]overlay[out]",
    "-map": "[out]"

    • @DonaldFeury
      @DonaldFeury  3 роки тому +1

      I'm afraid I've never removed a green screen with ffmpeg, so I would know as much or less about it as you.
      If I happen to need to figure it out, I will let you know. If YOU figure it out, it would be awesome if you told ME how to do it. 😂

  • @charnjit525
    @charnjit525 3 роки тому +1

    i have two commands to run one after one sepratly.
    "ffmpeg -i input.mp4 -ss 00:01:30 -to 00:09:45 -c:v copy -c:a copy output.mp4"
    & "ffmpeg -i output.mp4 -vf scale=320:240,setsar=1:1 final.mp4"
    can do both function at once means
    Can i do complete action ( input.mp4. To final.mp4) once
    Please write these two commands into one . Without losing source file . {input.mp4---to-- final.mp4 } once Thank you...

    • @DonaldFeury
      @DonaldFeury  3 роки тому

      You certainly can, also keep in mind you can't copy codecs if you're running them through a filter. You could copy the audio stream over since you're only running a filter on the video stream.
      It would look something like this:
      *ffmpeg -i input.mp4 -ss **00:01:30** -to **00:09:45** -vf scale=320:240,setsar=1:1 -c:a copy final.mp4*

  • @triplezs6307
    @triplezs6307 Рік тому

    thankyou for the tip boss, i will reciprocate with a little tip of my own - cut out the nose candy, it will lead to no good for you ok

  • @loydloyd726
    @loydloyd726 2 роки тому

    Nice job, but can you write code to how to take for example an hour long video and cut it in 10 min increments, no encoding?
    Thank You