How cut videos into clips using ffmpeg

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'll show you all simple trick today that allows you to cut two sections of a video and audio file out without actually having to use an editor it was normally if you wanted to say take a section of the video and use it for something else you'd have to open up a Premiere Pro or DaVinci Resolve or something like you have to do that but that we have kernel programs so we will pop over here for a second now I have a recording of my wife doing something on Animal Crossing it won't look through real fast and there's some I want this like first part here before she starts making stuff so let's say I don't know with like the first five seconds of it taste seconds per se seconds of it so normally you'd have to yeah like I said you don't have to open up like a GUI editor to do this but if you have ffmpeg which you probably do because a lot of things use ffmpeg in the background you don't need the so I want the first eight seconds of this to be his own video so we're going to use that the pimp egg - I to indicate what the input file is it's gonna be over watch beanie now to get only the first 15 seconds we're gonna pass in this - T which and 8 so what - T says is whenever ffmpeg is reading this video file only write out the the first eight seconds and then stop just stop writing out the file and we're also going to do - C copy what this is doing is normally when you would cut out a slice of a video using an editor it would read encode the audio file which makes this tape they would read encode the video file which makes us take substantially longer but this just copies it over as is so you don't have to mess with that and ever going to call it intro dot mp4 plug it ad that's hook like half a second so we feed this to check it intro you will see that it's only 20 seconds on that that's a you know fraction of time it would've took using editor now there was another section of this that I wanted at the the end let's see I want right so right about 16 minutes in I want the end of it so there's another flag you can pass in called SS s - SS is basically tells ffmpeg I will only want you to start writing data out to a file when you get to this timestamp and it's in like a standard like time format so we want there's no our 0 0 16 minutes and 0 seconds again copy because we're about changing the video file I just want a piece of it over watch me out road before and this will take a minute because it has to go through the video file until it actually gets to the point that it wants to start reading out and boom you got that whole section in 9 seconds so we're going to overwatch beany out true and look at that we have the last 35 seconds of the video without again touching it editor now I also want the the middle portion by itself so the actual like creation process and the way we're going to do this is you can combine those multiple flags I use to get the first in the last half so let's see I want to start around 15 seconds and what do I want to stop at there's another flag you can pass that instead of saying a duration you can set a stop timestamp so instead of a duration of saith but at the first I said I only what a second stop what you can do instead it says I want you to stop at a specific time stamp so let's say I'm gonna let this it's gotta be around here I want to see the end way okay so 15:51 so we can combine those two flags to set a start and a stop point for writing out the file data so then pay and file so we're going to - - yes as 0 0 and it was like what it was it was 15 seconds and then for remember duration was - T now if you're setting it based on a timestamp it's - key oh and you're gonna do 0 0 15 minutes and 51 seconds and we're gonna copy the whole thing again cuz we're not changing it and we will call this watch B before and this is going to be similar where it it's only gonna start writing it when it got to the specified time stamp and then stop writing it once I got to the second timestamp I specified which was about 15 minutes and 51 seconds into it so this is gonna let this run okay okay 20 seconds we got that whole thing in 20 seconds so I don't know how long this would have taken a normal header but I guarantee you would probably would not have taken under a few minutes to do this so if we look here now we have we have the three main sections of this video cut out without using an editor and what I can only imagine is a fraction of the time now so you may ask but that's really helpful for videos but what I thought if I have like an audio file that I want to cut sections out of well guess what you can do the exact same we're going to go over to this screen now and I had this track that I was going to use in one of my wife's some of my wife's videos the dude on the YouTube channel basis says or you can use this as long as you credit me for it so we go look at it it's just like a bit remix of the animal crossing happy home designer thing and let's just say hmm well we're gonna take a listen to it real fast just to see what it sounds like so we got Animal Crossing let's say I want let's do something similar to what I did with the video file I I only want the first 15 seconds of it for whatever reason it's basically the same thing as the video you pass in the input in this case is the animal crossing song instead of the video file you're gonna do - my brain farted - tea for 15 and we're copying because we're not changing it and I'm gonna call it a happy home designer 15 dot mp3 boom took fraction of second so we're going to look at that real quick and you will notice that hey it's only the first 15 seconds of it nice so what if I wanted again what if I wanted like a specific section of it where you say maybe you want on though the you want to start with in the first minute and then maybe get like the last like go for like 30 seconds so we can do it have been paying - I animal crossing - SS I want to start at one minute in and I want 30 seconds after that right yes 30 seconds copy a happy home I can't spell today $30 okay so happy home 30 and it started I'm in it in and then this is a 30-second clip so there you go now you can edit out pieces of videos and audio files without ever touching a GUI editor so last forgot to mention one other kind of important thing you can do with this so those flags I was passing in to say like when to start interacting with the video or audio file or when the stop so you can actually use those on the input file itself and sometimes that actually causes a rather significant difference in the speed of what you're trying to achieve so if we recall in order to get the end of the little animal crossing recording we did - i before - SS earlier 16 right and we're gonna run this again just to see about how long it takes to do this take the process so we let it run on the thing last time I recall it took about nine seconds to do this and I'm going to show you the other way to do this that is actually much faster okay yeah so nine seconds now the reason why it takes nine seconds is because you're starting from the beginning of the video file and reading the whole thing but you're not actually writing it out to another file until you get to the specified timestamp what you can do instead is is tell if if MPEG to start reading the file at a specific point which will achieve the same effect but actually will be much faster so we're going to do ever been pay then the same flag - SS 0 0 16 which is your Hall was basically the same thing we had before then we pass in the input which in this case which is the the the anal crossing which and we're gonna do coffee recall this beanie altro ask that MP for now see how long this one takes took a second now wow that one was so much faster because it didn't have to read over the entire video file to get to the party one on the right out it just started at the 16-minute mark and then just wrote everything else out you can combine the this concept of having those flags to indicate when you want to start and stop interacting with input and output but it gets a little confusing if you're using both and what I mean is for example if I did this similar command right but then say after this I said well I want 15 so what this is gonna do is it's gonna start reading this file 16 minutes in write out 15 seconds and then stop it's not going to write out the first 15 seconds but the first 15 seconds starting at the 16 minutes which maybe seems a little weird one that's probably that confused me initially more was if you're trying to do the timestamp approach so if you're doing the timestamp approach let's say that I I made the mistake of saying that I wanted the I wanted the video to stop at 16 minutes and 30 seconds say what ignorant me thought this was the same thing as the saying well I just want the 15 seconds but what you'll actually see is this is not right because when you get to the other side of the in put this this these timestamps it's using to write out the file that there is no 16 minute time stamp because this part only sees what it sees from this part so I think that most of this goes is like 30 seconds so you're just gonna get the whole the whole video file basically which you'd said would have to do is do that that would be equivalent because what is saying okay that the output data I want to stop 15 seconds into the output data it's a little it's a little confusing but if you just kind of if you can understand that basically when you're messing with ever been peg if it then Peck has two sides has an input and an output the input and the output have no knowledge of each other so if you start if you if you start giving the output data from another file but you didn't start to be at the beginning the output doesn't note that they don't know the thing the output noses oh okay I'm just getting data don't know where the hell it came from and you're telling me to stop at 16 minutes well I'm going and I'm going oh the stream ran out because there's not 16 minutes of data left there's like 30 seconds of data live so using the timestamp flags on the input can actually speed these process up processes up substantially just as long as you don't accidentally confuse yourself if you would like to see more of these little non editor based editing tricks do me a favor leave me like down below subscribe if you haven't and comment down below what trick you would like me to figure out or just tell you if I have if I already know what it is and what there having been said y'all have y'all come on back now and I'll see you next time [Music] you [Music]
Info
Channel: Donald Feury
Views: 7,965
Rating: undefined out of 5
Keywords: donald feury ffmpeg, ffmpeg cut video, donald feury ffmpeg tricks, donald feury, ffmpeg cut audio, web developer, programming, ffmpeg, feurious, spotifyd, spotify-tui, spotify tui, automated video editing, automated, video editing, cut video, cut audio, automation, video editing automation, no editor, ffmpeg tutorial, tutorial, how to, how to use, help, quickstart, quick start, quick, basics, getting started, conversion, filters, effects, ffmpeg help, video, audio, images, linux, Ffmpeg linux
Id: Q2Wc-cDFixs
Channel Id: undefined
Length: 14min 44sec (884 seconds)
Published: Thu Apr 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.