How to Install FFmpeg in 30 Seconds
45sQuick installation guide with Homebrew, perfect for beginners who want to start using FFmpeg immediately.
▶ Play ClipThis tutorial covers the basics of FFmpeg, a powerful multimedia tool, focusing on installation, trimming videos, and converting formats. It demonstrates both fast (less accurate) and slow (accurate) methods for trimming, and shows how to batch convert files using a bash loop.
Open a terminal and type 'ffmpeg'. If you see output, it's installed. If not, install via Homebrew.
If Homebrew is installed, run 'brew install ffmpeg'. To install Homebrew, visit brew.sh and paste the installation command.
Use 'ffmpeg -i input.mp4 -ss 10 -c copy output.mp4' for fast copy (slightly inaccurate) or omit '-c copy' for accurate re-encoding.
Use 'ffmpeg -i input.mp4 -t 50 output.mp4' to keep from start to 50 seconds. Add '-c copy' for fast but less accurate trimming.
To keep from 5 to 45 seconds, use '-ss 5 -t 40' (duration) or '-ss 5 -to 45' (end point). Both work; '-c copy' speeds up but reduces accuracy.
For longer videos, use format HH:MM:SS, e.g., '-ss 00:00:20' for 20 seconds. This works for both start and end times.
Use 'ffmpeg -i input.mp4 -c copy output.mkv' to convert MP4 to MKV without quality loss. The '-c copy' flag copies streams without re-encoding.
Use a bash loop: 'for f in *.mp4; do ffmpeg -i "$f" -c copy "${f%.*}-converted.mkv"; done' to convert all MP4 files to MKV.
FFmpeg is a versatile tool for video trimming and format conversion. The fast method with '-c copy' is ideal for quick tasks where slight inaccuracy is acceptable, while the slow method ensures precise cuts.
"The title accurately reflects the beginner-friendly tutorial content covering installation, trimming, and conversion."
How do you check if FFmpeg is installed?
Type 'ffmpeg' in the terminal. If output appears, it's installed.
00:01
What command installs FFmpeg via Homebrew?
brew install ffmpeg
00:27
What does the '-ss' flag do in FFmpeg?
It sets the start time of the output video.
03:54
What is the difference between '-t' and '-to' flags?
-t specifies duration, -to specifies the end point (time from start of input).
17:02
What does '-c copy' do?
It copies the video and audio streams without re-encoding, making the process fast but slightly inaccurate for trimming.
14:56
How do you specify time in HH:MM:SS format in FFmpeg?
Use the format HH:MM:SS, e.g., '-ss 00:00:20' for 20 seconds.
22:06
What command converts an MP4 file to MKV without quality loss?
ffmpeg -i input.mp4 -c copy output.mkv
27:55
How do you batch convert all MP4 files in a directory to MKV?
Use a bash loop: for f in *.mp4; do ffmpeg -i "$f" -c copy "${f%.*}-converted.mkv"; done
30:03
Fast vs Slow Trimming
Explains the trade-off between speed and accuracy: '-c copy' is fast but can be off by a few seconds.
05:01Understanding -c copy
Clarifies that '-c copy' copies streams without re-encoding, preserving quality but reducing precision in cuts.
14:56HH:MM:SS Time Format
Shows how to specify timestamps for longer videos, a crucial skill for real-world use.
22:06Batch Conversion with Bash Loop
Demonstrates a practical script to convert entire directories, saving time for bulk operations.
30:03[00:01] foreign so in this video we'll just do a
[00:04] quick uh we'll just do a quick overview
[00:06] of how to install ffmpeg now first of
[00:09] all you must always check if you have
[00:10] ffmpeg installed uh just open up any
[00:13] terminal and type out FFM Peg uh if you
[00:17] see all of this here it means that
[00:19] ffmpeg is already installed you don't
[00:21] have to install it in case you do have
[00:24] to install it uh the and if you have
[00:27] Homebrew installed okay if you have
[00:29] Homebrew installed you can simply write
[00:31] group install ffmpeg that is you could
[00:34] simply do Groove install if you can Peg
[00:37] and that would work if you do not have
[00:40] Homebrew installed I highly recommend
[00:42] that you should have it how do you
[00:44] install Homebrew just Google home brew
[00:47] and you will land on this page brew.sh
[00:50] and all you have to do is copy and paste
[00:53] this line just copy it right from here
[00:55] paste enter it may ask you for your
[00:58] password that would be it it will
[01:00] install Homebrew you may may have to
[01:03] restart your terminal so once you have
[01:06] home brew installed once you have
[01:09] Homebrew installed you can go back to
[01:10] this and do Brew install ffap that is
[01:13] right through install effect right here
[01:15] it should work out in case you don't
[01:18] know what a terminal is uh
[01:20] FFM bank is then not for you you have to
[01:23] be comfortable with the terminal before
[01:25] you can understand how to use ffmpeg
[01:28] okay apart from that that's it this is
[01:30] it was a quick video thank you
[01:37] so in this video we are going to learn
[01:38] how to trim how to trim video parts or
[01:42] how to extract a particular segment of a
[01:46] video
[01:47] so I have a couple of sample videos here
[01:49] so I have a one minute timer video here
[01:51] I hope you can see this so this one
[01:54] minute timer video is nothing it's just
[01:56] a video of a minute it's a one minute
[01:58] long video but I also have a timer added
[02:01] to it you can see there's a timer right
[02:03] up of here
[02:05] so there's a timer added on the upper
[02:07] right hand corner it matches with how
[02:09] long the video has been going on it's
[02:11] just a time lapse simple video of
[02:14] so as you can see this it's showing 20
[02:16] seconds and we are 20 seconds into the
[02:18] video as well so this is just a sample
[02:20] video just to understand uh at what time
[02:22] frame are we working at
[02:25] so now how do you trim a section out of
[02:28] a video very quickly
[02:30] for example if we take for example if
[02:33] you want to remove the first 10 seconds
[02:36] but keep the rest now keep in mind this
[02:37] is a one minute video it's a one minute
[02:39] video so if you want to remove the first
[02:42] 10 seconds we want to remove the first
[02:45] 10 seconds
[02:48] that is we want to keep the video from
[02:51] 10 seconds up to one minute now in that
[02:53] case how do we in that case how do we do
[02:56] that so first of all I am in my ffmpeg
[02:59] directory this is the directory which
[03:00] contains all of these files you can
[03:02] check this out by using LS I hope you
[03:05] can see this very clearly
[03:07] uh in any case I'll just make this a
[03:10] little bit bigger unless yes I hope this
[03:12] should be very this should be visible
[03:13] anyways so now how do I remove the first
[03:16] 10 seconds but keep the rest
[03:19] now for that we must begin the video at
[03:21] 10 seconds and how do we achieve that
[03:23] very simply ffmpeg the command is ffmpeg
[03:26] now we give the input file that is given
[03:30] by minus I now here I am using one
[03:33] minute timer as my input file so ffmpeg
[03:36] I one minute uh underscore timer as my
[03:39] input file so minus I here is the input
[03:41] file now when do we want to start our
[03:45] output file we want to start from the
[03:48] 10th second because we want to remove
[03:49] from 0 to 10 so we want to start the
[03:51] file at the 10th second so we start it
[03:54] by using minus SS now SS tells you the
[03:57] start timer of our output video now
[04:01] there are two ways in which we can do
[04:02] this we could have done this either as
[04:03] 10 okay now 10 here stands for 10
[04:06] seconds I'll just give an example and
[04:09] then we'll give the output file name
[04:10] let's say let's say the output file name
[04:13] is 10 to
[04:15] 10 to end I'll just tell you why did I
[04:18] do an end dot MP4
[04:21] okay I did an mp4 here so
[04:25] let me just add one more thing here slow
[04:27] okay now you'll just see in a second why
[04:29] did I append this slow word here so if
[04:31] we do this if we do this right here if I
[04:33] run this command you will see
[04:37] so we see a lot of output and then there
[04:40] is something that is going on here
[04:43] so as you can see that the speed is 0.8
[04:46] X which means that a one minute video
[04:48] would take somewhat longer than a minute
[04:50] or almost a minute
[04:54] so you can see that we have completed 20
[04:56] seconds of this now of course this is a
[04:59] this is a slightly slower method there
[05:01] is also a faster method both of them
[05:04] have their advantages and disadvantages
[05:06] we'll come to that in just a second
[05:09] so let's just complete this one
[05:16] all right so this is done so when it is
[05:18] when it is over my command front returns
[05:20] my command prompt returns so now if you
[05:23] look right here so there is a 10 to end
[05:25] slope the output file that I had written
[05:28] here was 10
[05:30] to end was 10 to end slow and if I were
[05:33] to open up this file remember we removed
[05:36] the first 10 seconds we removed the
[05:38] first 10 seconds so if I all right why
[05:41] don't we do that why don't we first take
[05:43] the fast one as well so if now there is
[05:45] one more way that we could have done
[05:46] this done this faster as well
[05:49] same command okay but instead of going
[05:52] to add one more thing here minus C copy
[05:54] okay minus C copy and I'm going to
[05:58] change this to fast
[06:00] okay now you will see what did I do here
[06:02] so this one took us almost a minute uh
[06:06] this one minute video almost took us a
[06:08] minute and what about this one pay
[06:10] attention
[06:12] and it's done already okay it's done
[06:14] already so you could see that this fast
[06:18] one is already done whereas that took us
[06:19] about a minute this one is done only so
[06:22] now what is the difference between this
[06:24] slow process and this fast process now
[06:27] remember we remove the first 10 seconds
[06:29] so if I were to open up this slow one
[06:32] it started exactly I think you'll see
[06:34] this right here okay so if I were to
[06:36] restart this video
[06:41] okay so it is going to start exactly at
[06:45] 10 seconds we remove the first 10
[06:47] seconds so it's going to start exactly
[06:48] at 10 seconds that if I play it it's a
[06:51] 50 second video
[06:53] so it go it's it is going to go up to a
[06:55] minute
[06:58] okay but if I were to play this fast
[07:01] video now the issue here is it's going
[07:06] to start at three okay it started at 13.
[07:08] so basically so basically
[07:12] it started at 12 actually it started at
[07:14] 12 I cannot go any further back okay I
[07:17] cannot go any further back it is the
[07:19] video has started at 12 only
[07:22] okay now so why did this happen or or
[07:26] what is the advantage or disadvantage of
[07:29] this slow method versus this fast method
[07:31] the slow method is accurate it will it
[07:34] will give you the exact duration it will
[07:36] start at the exact time that you have
[07:38] mentioned it will stop at the exact time
[07:40] that you have mentioned but the first
[07:41] one has an error of a couple of seconds
[07:44] so if but it but it takes place very
[07:48] fast it happened very very quickly so if
[07:50] you are fine with a couple of seconds
[07:52] being up or down then I recommend you go
[07:54] by the fast method but if you have to
[07:57] maintain accuracy uh if you have to
[08:01] maintain complete accuracy of the time
[08:03] mentioned then I recommend that you go
[08:04] by the slow method okay so let me just
[08:07] copy it on both of these commands
[08:09] uh now one more thing so I as you can
[08:11] see that there is a lot of output here
[08:13] so how do we reduce all of this output
[08:16] as well because there's a lot of useless
[08:17] data here as well I'll just quickly copy
[08:19] this so this was the first one
[08:24] so this was the first one okay and then
[08:29] the slow one
[08:35] uh there was no C copy here
[08:39] okay I named it slow
[08:43] you can see the full Command right here
[08:46] okay so this was a this was the slow one
[08:50] this was the first one it took almost a
[08:52] minute this took place almost instantly
[08:54] now so this is how do you remove the
[08:56] first 10 seconds how about if you want
[08:58] to remove the last 10 seconds okay now
[09:01] uh if you if you already know the time
[09:03] frame that makes it much much easier
[09:05] okay so let's say that since we all know
[09:08] that this is a one one minute video and
[09:10] I want to and I want to remove the last
[09:13] 10 seconds okay that is in this case my
[09:16] video would actually be from zero
[09:19] seconds to 50 seconds okay obviously
[09:23] sometimes you may not know the duration
[09:24] will we will check on that example as
[09:26] well but let's say key you do not know
[09:28] how let's say that in this case we do
[09:30] know
[09:31] uh what is the duration of the video
[09:32] file
[09:33] now the format for now the format for
[09:36] that is
[09:37] the format for that is ffmpeg same thing
[09:40] minus I one minute underscore timer this
[09:43] is our input file okay now here what we
[09:46] want to do is want to keep it from the
[09:48] beginning up to 50 seconds okay so from
[09:51] the beginning up to 50 seconds if you
[09:52] are starting the file right from the
[09:54] beginning we do not have to mention the
[09:55] SS part this is not required if you are
[09:58] starting the file from the beginning but
[10:00] since we want to end at this particular
[10:02] time interval we can either use minus t
[10:05] 50 okay this tells me that I have to go
[10:08] up to 50 seconds or I could also use t o
[10:11] up to 50. both of these mean the same
[10:14] thing in this context here but I usually
[10:16] go with Dash T it's easier and and uh
[10:19] less lot less confusing
[10:21] so t50 and then let's give it as
[10:25] [Music]
[10:27] 0 to 50 let's keep this as slow dot MP4
[10:33] okay now this is again a 50 second video
[10:35] Let's see now so one more thing that I
[10:37] was about to tell you is how do you
[10:39] prevent all of that output for from
[10:41] coming so there is a very simple way to
[10:43] do that that is hide underscore Banner
[10:46] okay this is part one of it how do you
[10:49] reduce the output and the other part is
[10:52] log level
[10:55] Panic okay now if you use these two
[10:59] flags your output would be very limited
[11:01] and you won't see a lot of useless
[11:03] output so if you run that
[11:07] okay so as you could see there is that
[11:09] there is almost no output I think we
[11:11] should have put log level info here so
[11:13] that at least you could have known
[11:15] if this command is working or not
[11:21] I think we're going to stop this one
[11:23] right here and let's put this as log
[11:26] level info
[11:30] okay this is slightly better it will
[11:32] give you some information
[11:34] so I am going to do the exact same thing
[11:36] here so the command is exactly the same
[11:38] ffmpeg this is just to reduce the amount
[11:40] of output one minute timer this is our
[11:43] input file
[11:44] up to 50 seconds starting from the
[11:46] beginning up to 50 seconds 0 to 50 slow
[11:49] dot MP4 our output we want as MP4
[11:52] now if I were to run this
[11:55] so we are getting some output but it is
[11:57] asking me if I want to override this
[11:59] file I can do a y here
[12:03] okay so as you can see that this is
[12:05] approximately going at 1X the speed so
[12:07] it will still take me around 50 seconds
[12:09] 50 to 40 seconds
[12:13] you can see how much time has been
[12:14] completed right here
[12:22] so just a few more seconds to go
[12:26] so as you can see that there is much
[12:28] less output this time
[12:32] and if you were to set this log level to
[12:34] panic then there will be almost be no
[12:37] output however I still recommend you put
[12:39] it as log level info uh so this is done
[12:42] as you could see this still took some
[12:44] time and if we do the fast version how
[12:47] do we do the fast version by simply
[12:49] appending a minus C copy okay if we do
[12:52] that we can change this to fast okay but
[12:56] again the issue is of accuracy so and we
[13:00] are done okay we are done already so
[13:02] again if we check those out
[13:05] so so this time it was so this time the
[13:09] command that we ran was uh 0 to 50 fast
[13:13] and 0 to 50 slow so if I were to run if
[13:16] I were to run 0 to 50 slow
[13:19] so as you can see that began exactly at
[13:22] zero let me just pause it
[13:24] okay so it began exactly at zero and it
[13:28] will end
[13:30] it will end exactly at 50 or rather 49.
[13:34] it will end at 49 but if we were to run
[13:37] the 0 to 50 fast now it will begin at
[13:41] the right time because that is not where
[13:43] we have cut okay so it will begin at
[13:45] zero but it would end at a probably a
[13:49] different time so 49 50 okay so this one
[13:53] it did go up to 50 but the previous one
[13:55] went up to 49 and that was a bit more
[13:59] accurate you will see
[14:00] so it stopped at 49.
[14:03] so if accuracy is not a concern if a
[14:06] couple of seconds accuracy is not a
[14:08] console then you can go by the first one
[14:09] but if accuracy is important then you
[14:12] should go by the slow method now so this
[14:15] is when we have to remove some parts uh
[14:18] this is when we have to remove some
[14:19] parts of it let me just quickly copy it
[14:21] so 0 to 50 fast copy
[14:27] okay I'll just show this command to you
[14:29] this is the fast method okay and then of
[14:33] course we have the slow method as well
[14:34] slow but accurate
[14:39] so the slow method was something like
[14:41] this
[14:43] so the only difference between these two
[14:45] commands
[14:47] the only difference between these two
[14:49] commands is the dash C copy here okay
[14:52] now dash C copy uh what the what Dash C
[14:56] copy does it is it copies the entire
[14:58] video as it is okay without
[15:01] demoxing it without muxing demoxing or
[15:04] rather without encoding it encoding
[15:06] right now is not that important you
[15:08] could simply understand it is that it
[15:09] copies it as it is without any quality
[15:11] change this this method prevents any
[15:14] quality degradation
[15:16] so hide Banner login info this is just
[15:19] helpful in preventing too much output
[15:22] now so so in the first case we remove
[15:26] the first 10 seconds in the second case
[15:28] we removed the last 10 seconds now what
[15:30] if we want to keep only a portion in
[15:34] between okay that is let's say what if
[15:35] you want to keep or let's say you want
[15:38] to remove the first
[15:40] let's say five seconds
[15:43] and also remove
[15:45] and also remove last let's say 15
[15:49] seconds let's say 15 seconds okay now
[15:53] again since here we already know the
[15:54] video duration so if you are removing
[15:56] the first five seconds uh if you're
[15:59] removing the first five seconds then my
[16:01] actual video is starting at five seconds
[16:03] and it is going up to if you are
[16:04] removing the last 15 seconds as well it
[16:06] is going up to 45 seconds okay
[16:09] now so there are two things there are
[16:12] two ways in which we could have achieved
[16:14] there are two ways in which we can
[16:15] achieve this basically everybody is
[16:17] going to start with from Five Seconds up
[16:18] to 45 seconds now there are two ways in
[16:21] which we can do this the first way is
[16:23] ffmpeg
[16:25] minus uh height Banner
[16:27] okay
[16:30] log level
[16:31] info this is just again to suppress the
[16:34] output uh log level info minus I is one
[16:38] minute timer okay this is this is the
[16:40] same input file
[16:42] now so there are two ways to do this
[16:45] I'll show you both of the ways now the
[16:47] first way uh now the first way is
[16:49] obviously when are we starting from and
[16:52] to put a filter on timer on the starting
[16:55] point we use minus SS okay now since you
[16:57] want to start from five seconds so we'll
[16:59] put the SS as five
[17:02] okay now uh since we want to end the
[17:05] video at 45 seconds okay we want to end
[17:08] the video at 45 seconds there are two
[17:10] ways in which you can do this the first
[17:11] way is by specifying the end point the
[17:15] other way is by specifying the duration
[17:17] okay now what does the end point and
[17:20] duration mean very simply
[17:24] so if my video is running from 5 Seconds
[17:27] to 45 seconds the duration
[17:30] is going to be 40 seconds okay the end
[17:33] point is 45 seconds but the duration is
[17:35] 40 seconds so when we use minus t here
[17:38] it implies the duration okay from 5
[17:42] Seconds to how much longer do we want
[17:44] the video to go on so we want an extra
[17:46] 40 seconds because from 5 Seconds up to
[17:49] 45 seconds deduction has to be 40
[17:50] seconds so we want the video to go an
[17:52] extra 40 seconds this is Method number
[17:54] one okay it will give you the same
[17:55] result and let's say let's let's just go
[17:58] by the slow method in this case it's not
[17:59] in and it's not a very large video
[18:01] anyways uh we'll do uh five to forty
[18:06] rather 5 to 45
[18:08] to 45 T dot MP4 obviously this is a
[18:13] slower method
[18:15] okay it's going to take some time
[18:21] so the important thing here is we took
[18:23] the duration here okay we took the
[18:25] duration here so it started from Five
[18:28] Seconds went up to 40 seconds more so a
[18:32] total of 45 seconds we will also check
[18:34] out the output as well
[18:39] foreign
[18:43] so we have completed 37 seconds
[18:46] all right so done so if we were to play
[18:49] that file uh let's say uh so this was 5
[18:52] to 45 right so 5 to 45 now see it begins
[18:57] at five seconds
[18:59] it begins at five seconds it's a 40
[19:03] second video and the end point would be
[19:05] at 45 this is at 43 it there's still
[19:07] some time so if I play it so if I were
[19:10] to play it it would end at 44 okay
[19:13] because again it it does not go up to 45
[19:15] so this is when we use the duration okay
[19:19] that is here the duration was 40 seconds
[19:20] but what if we want to specify the end
[19:22] point if you want to specify the end
[19:24] point so in that case we simply use t o
[19:28] in that case we use t o and now our
[19:31] endpoint is up to 45th second okay so
[19:33] this goes on from the five second of the
[19:35] original video to the 45th second of the
[19:39] uh to the 45th second of the original
[19:41] video now here I'm going to use t o okay
[19:45] and if we go do that again now this is
[19:48] obviously again I'm using the slow
[19:49] method the fast method would be slightly
[19:51] inaccurate
[19:53] if you want to use a fast method just
[19:55] put a dash C copy right before the
[19:57] output file I'll show an example as well
[20:07] so this is done up so 29 seconds have
[20:11] been done we are only going up to 45
[20:17] Okay so
[20:19] this is the one that we did right now
[20:23] so as you can see this also began at
[20:25] five seconds this also began at five
[20:27] seconds and it would end at 44 seconds
[20:30] okay this is almost at the end point it
[20:32] would end at 44 seconds essentially 45
[20:34] seconds
[20:36] now so both of these do exactly the same
[20:40] thing but the difference between t and t
[20:42] o okay let me just copy the commands
[20:47] so
[20:52] so the first let's look at the T command
[20:56] so in case of T command we specified the
[21:00] duration
[21:03] okay and in case of the
[21:06] T O command we specified the end point
[21:15] okay so I think we should I should
[21:18] so the difference here was that we gave
[21:20] the duration from five seconds and the
[21:22] next 40 seconds after the fifth second
[21:24] and from here we mentioned the starting
[21:26] point and the end point
[21:29] okay now uh
[21:32] I guess this is it for this video so you
[21:34] could have you could have removed from
[21:36] the beginning you could have removed
[21:37] from the end or you could have removed
[21:39] from the beginning and the end as well
[21:42] okay so you can use any of these
[21:43] commands obviously yes to make it faster
[21:45] all you had to do was add a minus C
[21:49] copy right here okay doing this would
[21:51] have made the video go fast it would
[21:53] have been slightly inaccurate but
[21:54] Twitter Made It Go much faster okay so
[21:56] that's it for this video we will
[21:58] continue we will discuss more details or
[22:00] we'll discuss more uh commands right in
[22:03] the next video that's it
[22:06] all right so in this video we'll just
[22:08] check out one more uh one more way to to
[22:11] put the timers uh to put the timers when
[22:14] you want to trim parts of a video
[22:16] so in our last case when we wanted so in
[22:18] our last video when we wanted to trim
[22:20] out let's say the first 10 seconds you
[22:22] wanted to remove the first 10 seconds
[22:23] the command that we used was ss10 okay
[22:27] now 10 by itself means seconds here but
[22:31] uh our video obviously was a one minute
[22:32] video but what if it was not a one
[22:34] minute video what if it was it was let's
[22:36] say a 15 Minutes video or let's say it
[22:37] was a two hour video in that case how do
[22:40] we specify the time interval very simply
[22:43] um in that case what you would have done
[22:45] is ffmpeg minus uh minus minus
[22:50] ffmpeg minus I uh you have to specify
[22:53] the input file here let's say the input
[22:54] file is same one minute timer okay uh
[22:57] let's say starting at now how do we
[23:00] specify hours minutes and seconds so
[23:02] let's say 0 0 uh zero zero and let's say
[23:05] 20 okay so what this means here is hours
[23:09] minutes and seconds okay so if you have
[23:13] a long enough video you can use this
[23:14] method as well so basically this
[23:16] represents HH mm and SS obviously the
[23:20] accuracy is also up to milliseconds but
[23:23] I have never had to use that actually so
[23:25] uh so you can use this convention as
[23:27] well now of course you could have used
[23:29] the same thing for time duration or end
[23:32] point as well now if we were to use
[23:35] let's say minus 2 here okay if we were
[23:38] to use a two flag here that would imply
[23:40] the end point okay that would imply the
[23:43] end point what does that mean
[23:45] so let's say if if I want to keep let's
[23:48] say if I want to keep from let's say if
[23:50] I want to keep the let's say if I want
[23:52] to start the video from the 20th second
[23:55] up to let's say for let's say 55 seconds
[23:59] okay from the 20th second up to 55th
[24:02] second
[24:04] okay so in that case how would I have
[24:06] specified it 20 seconds up to zero zero
[24:09] zero zero so hours minutes and seconds
[24:12] that is 55 seconds let me do the let me
[24:15] just let's go by the first method here
[24:17] uh let's say 20 to 55
[24:21] 2 dot MP4 of course there's going to be
[24:25] a lot of output in this particular case
[24:27] because I have not used hide Banner or
[24:29] log level let's just still then check it
[24:31] out anyways so if I do this here let me
[24:34] just check if the yeah start timer 20
[24:36] and timer is 55 all right so this is
[24:38] from 20 seconds up to 55 seconds if I do
[24:42] an okay so as you could see that we saw
[24:44] all of this output then there is
[24:45] something going on here
[24:47] so the speed is still 0.7 but this is
[24:51] not a very long video
[24:53] foreign
[24:57] that we started the video from 20
[25:00] seconds here okay but it is showing 20
[25:03] but a few seconds back it showed 15
[25:06] seconds or 10 seconds uh now in this
[25:08] case we have to understand that when you
[25:09] do SS the timing of the video resets
[25:12] okay the timing of the video resets that
[25:14] is now 20 seconds will be counted as the
[25:17] beginning of the video okay or 20
[25:19] seconds will be counted as zero okay so
[25:23] so if I were to check this one out so I
[25:25] named this 20 to 55 20 to 55 here we are
[25:31] okay this is 2 using the duration
[25:35] so as you can see that this began at 20
[25:39] seconds okay as you can see that this
[25:40] began at 20 seconds and it's a 35 second
[25:43] video so if you go up to the end it will
[25:45] end at 54. okay and at 54. okay now uh
[25:49] because I've also done the duration one
[25:51] as well now if you wanted to go by the
[25:53] duration so for the duration part now if
[25:58] you are going from 20 to 55 the duration
[26:02] the duration of the video or how long
[26:04] the video would have been is 35 seconds
[26:07] okay so at that case when we are using
[26:10] the T flag or the duration flag it we
[26:13] would have used
[26:15] 30 seconds sorry not 30 seconds 35
[26:17] seconds okay from 20 seconds and the
[26:20] next 35 seconds so 22 so 22 55 t
[26:25] uh of course we will surprise all the
[26:27] output Okay so
[26:31] hide Banner
[26:34] and hide underscore Banner
[26:37] okay and then we have log
[26:41] level info okay so info gives you some
[26:44] information at the very least
[26:47] okay so info gives you some information
[26:49] whereas if I had written Panic here
[26:53] Panic then it would have given us no
[26:54] information the file would have simply
[26:56] completed
[26:58] okay so as you can see it began
[26:59] somewhere 13 seconds that is because the
[27:01] start timer has now been reset
[27:06] so obviously it will be a 35 second
[27:07] video so it will go only up to 35 it
[27:10] will end much before that actually
[27:15] so as you can see it ended right before
[27:17] it hit 35 so if we open up the other
[27:20] file 25 to 55 t Okay so as you can see
[27:26] that
[27:29] it begins
[27:32] that it begins
[27:35] it begins at 20 okay because we wanted
[27:37] to start the video at 20 and it will end
[27:39] again at 54 it's a 35 second video it
[27:41] will end at 54. okay it's at the end
[27:48] so I guess that's it for this video
[27:55] all right so in this video we are going
[27:56] to learn how to convert from one format
[27:58] to another for example some of you may
[28:01] have some videos which are in the MP4
[28:03] format or maybe uh for example you may
[28:06] have some videos which are in the MP4
[28:07] format or you may have some videos which
[28:09] are in the Avi format or they could be
[28:11] in MKV format now how do you inter
[28:13] convert those into each other very very
[28:16] fast okay without any quality loss or or
[28:20] without taking this or without it taking
[28:22] up too much of your time it's very
[28:23] simple
[28:25] so again we will take the example of the
[28:26] one minute timer MP4 and we'll try to
[28:28] convert this to MKV this is very very
[28:31] simple so ffmpeg as usual minus I minus
[28:35] I tells you uh the input file so we'll
[28:37] take one minute one minute timer so this
[28:40] is our input file now we want to let's
[28:41] say convert this into an MKV file as it
[28:44] is without any changes we want to
[28:46] convert this the entire file into an MKV
[28:48] file very fast so minus C copy okay then
[28:52] whatever name you want to put it let's
[28:54] say
[28:55] MP4 to MKV dot MKV okay that is all that
[29:00] you have to do you have to Simply put a
[29:02] minus C copy here and then whatever
[29:04] format you want it right here of course
[29:06] this will give a lot of output so I just
[29:08] will decrease that so hide Banner
[29:12] okay and log level
[29:16] log level info okay so that's it and as
[29:21] you'll see this will be done very very
[29:23] quickly so
[29:24] and it's done already okay it's done
[29:26] already so if I were to play this file
[29:28] there is the MKV format right here so if
[29:31] I were to play this as you can see this
[29:33] is now an MKV file okay there is zero
[29:35] quality loss and it begins and
[29:39] and it begins at
[29:43] it begins at zero okay as you can see
[29:46] here and it is a one minute file ending
[29:48] at 59 okay you can see it will end at
[29:50] 59.
[29:52] okay so so you can use you can use this
[29:56] script to convert an entire directory of
[29:58] files uh so I'll just copy down this one
[30:03] so you can use this script to convert an
[30:06] entire directory of files of course you
[30:08] could have used you could have used this
[30:10] to convert from mkb to MP4 in that case
[30:12] this footage just have been an MKV this
[30:14] would have been an mp4 now so what if
[30:17] you have an entire directory of files
[30:21] okay what if you have an entire
[30:22] directory or files now for that we can
[30:24] use a loop okay for that you can use a
[30:27] loop now so the format of a loop looks
[30:30] something like this for let's say let's
[30:33] say you have a directory full of MP4
[30:35] files uh let's say that you have a
[30:37] directory full of MP4 files and you want
[30:39] to convert them into MKV files let's say
[30:42] you have a movies folder all of MP4 and
[30:45] you want to convert that to MKV so how
[30:47] do you do that you simply run a loop now
[30:48] how do we write Loops in bash so I'm
[30:52] first of all going to write it right
[30:53] here then I'm going to copy that there
[30:55] so the way you write Loop looks
[30:57] something like this for f in whatever
[31:00] the format is let's say you have all of
[31:02] them in MP4 like I have it here okay for
[31:07] f in dollar MP4 do okay so do gives you
[31:11] uh do tells the command prompt on to
[31:15] what what does it have to do what does
[31:16] it have to do you have to run the ffmp
[31:17] command so ffmpeg minus side Banner you
[31:20] could use this you could emit this
[31:22] entirely up to you hide underscore
[31:24] Banner
[31:27] minus log
[31:30] level info okay minus I now my input
[31:34] file is going to be this F command here
[31:38] why because if I were to write an LS
[31:40] here okay I have this MP4 I have this
[31:45] MP4 okay so for one point F will be this
[31:50] the other point F would be this one okay
[31:52] so uh
[31:55] so F in Star MP4 yaniki means that this
[31:58] will convert these two files do FFM back
[32:01] hide by log level info one dollar F okay
[32:04] so dollar f means whatever file it is
[32:07] handling right now okay whatever file it
[32:09] is handling right now
[32:11] what do we want to do is we want to
[32:13] convert this into MKV so minus C copy uh
[32:18] into MKV now how do we do that we'll
[32:21] have to use some string manipulation if
[32:23] you're not familiar with string
[32:25] manipulation I suggest you read up on
[32:26] that so how do we manipulate the string
[32:29] here we use same thing double quotation
[32:31] here uh dollar bracket open F star
[32:36] percent okay so this means whatever is
[32:40] after the last uh whatever is after the
[32:43] last dot okay for example if I were to
[32:45] look here after the last dot we have MP4
[32:48] here okay so instead of the last dot we
[32:50] want it to be m k v here okay now this
[32:54] basically let's let's put a converted
[32:57] here
[32:58] let's put a converted word here okay to
[33:00] MKV so essentially what it does here is
[33:03] this is obviously our output file this
[33:05] is our output file
[33:08] what it is doing here is that it will
[33:10] keep the same name okay it will keep the
[33:14] same name but whatever is after this dot
[33:16] that is MP4 this part gets removed and
[33:19] it will add a dash converted MKV okay so
[33:22] let's run this command then you will get
[33:24] it so anyways we are inside a loop so do
[33:26] ffmpeg and then we will add a done okay
[33:28] so this means that now our Command is
[33:30] complete so if I were to copy this
[33:33] command
[33:34] and paste it right here I have not yet
[33:35] run it so I'll just show it to you once
[33:37] again so for f in dollar MP4 okay so
[33:41] sorry dollar so for f in Star MP4 star
[33:44] dot MP4 means all of the files that end
[33:45] in MP4 so MP4 here MP4 here these two
[33:48] obviously do not end in MP4 I mean this
[33:50] is an MKV so it is not going to get
[33:52] lifted it is not going to get listed do
[33:55] it tells it is asking for the command
[33:57] that you want to run so ffmpeg hide when
[33:59] our log level info whatever this is just
[34:00] to reduce the output minus I dollar F so
[34:03] input file is whatever the f is at that
[34:05] point of time minus C copy uh so that
[34:08] the the process goes very fast and there
[34:11] is absolutely no loss quality loss here
[34:14] so star F star percentage converted to
[34:18] MKV okay I want to convert this from MP4
[34:21] we started from MP4 we wanted to MKV
[34:23] with the same name and done so if I if I
[34:26] were to run this
[34:28] bad substitution what did I make where
[34:31] did I make a mistake here
[34:32] uh did I do a percentage and that error
[34:36] here probably that is what I did do done
[34:39] I probably messed this up right here
[34:46] yeah so I messed that up so as you can
[34:48] see we are already done okay we are
[34:50] already done so if I were to if I were
[34:54] to show you the so as you can see here
[34:57] so one minute timer has converted to one
[35:00] minute hyphen converted MKV this is just
[35:03] for understanding and your one minute
[35:05] video has converted to one minute
[35:07] converted MKV everything else remains
[35:09] exactly the same the size is exactly the
[35:10] same the duration would also be exactly
[35:12] for example if I were to run this
[35:15] so one minute timer
[35:19] so
[35:21] starts at zero
[35:23] ends at 59 and one minute timer MKV
[35:26] converted okay exact same thing it would
[35:32] start at zero
[35:34] end at 59 okay the format has been
[35:36] changed okay so you can use this to
[35:38] convert entire directories of movies or
[35:40] or videos from One format to the other
[35:42] very quickly without any change in
[35:45] quality I guess that's it for this video
[35:46] I'll see you
⚡ Saved you time reading this? Transcribe any YouTube video for free — no signup needed.