---
title: 'FFmpeg Tutorial for Beginners'
source: 'https://youtube.com/watch?v=2hP6ZSVibHg'
video_id: '2hP6ZSVibHg'
date: 2026-06-15
duration_sec: 0
---

# FFmpeg Tutorial for Beginners

> Source: [FFmpeg Tutorial for Beginners](https://youtube.com/watch?v=2hP6ZSVibHg)

## Summary

This 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.

### Key Points

- **Checking FFmpeg Installation** [00:01] — Open a terminal and type 'ffmpeg'. If you see output, it's installed. If not, install via Homebrew.
- **Installing FFmpeg via Homebrew** [00:27] — If Homebrew is installed, run 'brew install ffmpeg'. To install Homebrew, visit brew.sh and paste the installation command.
- **Trimming Video – Removing First 10 Seconds** [02:25] — Use 'ffmpeg -i input.mp4 -ss 10 -c copy output.mp4' for fast copy (slightly inaccurate) or omit '-c copy' for accurate re-encoding.
- **Trimming Video – Removing Last 10 Seconds** [08:56] — 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.
- **Trimming a Middle Segment** [15:30] — 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.
- **Specifying Time in HH:MM:SS Format** [22:06] — 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.
- **Converting Video Formats** [27:55] — 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.
- **Batch Converting Files with a Loop** [30:03] — 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.

### Conclusion

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.

## Transcript

foreign so in this video we'll just do a
quick uh we'll just do a quick overview
of how to install ffmpeg now first of
all you must always check if you have
ffmpeg installed uh just open up any
terminal and type out FFM Peg uh if you
see all of this here it means that
ffmpeg is already installed you don't
have to install it in case you do have
to install it uh the and if you have
Homebrew installed okay if you have
Homebrew installed you can simply write
group install ffmpeg that is you could
simply do Groove install if you can Peg
and that would work if you do not have
Homebrew installed I highly recommend
that you should have it how do you
install Homebrew just Google home brew
and you will land on this page brew.sh
and all you have to do is copy and paste
this line just copy it right from here
paste enter it may ask you for your
password that would be it it will
install Homebrew you may may have to
restart your terminal so once you have
home brew installed once you have
Homebrew installed you can go back to
this and do Brew install ffap that is
right through install effect right here
it should work out in case you don't
know what a terminal is uh
FFM bank is then not for you you have to
be comfortable with the terminal before
you can understand how to use ffmpeg
okay apart from that that's it this is
it was a quick video thank you
so in this video we are going to learn
how to trim how to trim video parts or
how to extract a particular segment of a
video
so I have a couple of sample videos here
so I have a one minute timer video here
I hope you can see this so this one
minute timer video is nothing it's just
a video of a minute it's a one minute
long video but I also have a timer added
to it you can see there's a timer right
up of here
so there's a timer added on the upper
right hand corner it matches with how
long the video has been going on it's
just a time lapse simple video of
so as you can see this it's showing 20
seconds and we are 20 seconds into the
video as well so this is just a sample
video just to understand uh at what time
frame are we working at
so now how do you trim a section out of
a video very quickly
for example if we take for example if
you want to remove the first 10 seconds
but keep the rest now keep in mind this
is a one minute video it's a one minute
video so if you want to remove the first
10 seconds we want to remove the first
10 seconds
that is we want to keep the video from
10 seconds up to one minute now in that
case how do we in that case how do we do
that so first of all I am in my ffmpeg
directory this is the directory which
contains all of these files you can
check this out by using LS I hope you
can see this very clearly
uh in any case I'll just make this a
little bit bigger unless yes I hope this
should be very this should be visible
anyways so now how do I remove the first
10 seconds but keep the rest
now for that we must begin the video at
10 seconds and how do we achieve that
very simply ffmpeg the command is ffmpeg
now we give the input file that is given
by minus I now here I am using one
minute timer as my input file so ffmpeg
I one minute uh underscore timer as my
input file so minus I here is the input
file now when do we want to start our
output file we want to start from the
10th second because we want to remove
from 0 to 10 so we want to start the
file at the 10th second so we start it
by using minus SS now SS tells you the
start timer of our output video now
there are two ways in which we can do
this we could have done this either as
10 okay now 10 here stands for 10
seconds I'll just give an example and
then we'll give the output file name
let's say let's say the output file name
is 10 to
10 to end I'll just tell you why did I
do an end dot MP4
okay I did an mp4 here so
let me just add one more thing here slow
okay now you'll just see in a second why
did I append this slow word here so if
we do this if we do this right here if I
run this command you will see
so we see a lot of output and then there
is something that is going on here
so as you can see that the speed is 0.8
X which means that a one minute video
would take somewhat longer than a minute
or almost a minute
so you can see that we have completed 20
seconds of this now of course this is a
this is a slightly slower method there
is also a faster method both of them
have their advantages and disadvantages
we'll come to that in just a second
so let's just complete this one
all right so this is done so when it is
when it is over my command front returns
my command prompt returns so now if you
look right here so there is a 10 to end
slope the output file that I had written
here was 10
to end was 10 to end slow and if I were
to open up this file remember we removed
the first 10 seconds we removed the
first 10 seconds so if I all right why
don't we do that why don't we first take
the fast one as well so if now there is
one more way that we could have done
this done this faster as well
same command okay but instead of going
to add one more thing here minus C copy
okay minus C copy and I'm going to
change this to fast
okay now you will see what did I do here
so this one took us almost a minute uh
this one minute video almost took us a
minute and what about this one pay
attention
and it's done already okay it's done
already so you could see that this fast
one is already done whereas that took us
about a minute this one is done only so
now what is the difference between this
slow process and this fast process now
remember we remove the first 10 seconds
so if I were to open up this slow one
it started exactly I think you'll see
this right here okay so if I were to
restart this video
okay so it is going to start exactly at
10 seconds we remove the first 10
seconds so it's going to start exactly
at 10 seconds that if I play it it's a
50 second video
so it go it's it is going to go up to a
minute
okay but if I were to play this fast
video now the issue here is it's going
to start at three okay it started at 13.
so basically so basically
it started at 12 actually it started at
12 I cannot go any further back okay I
cannot go any further back it is the
video has started at 12 only
okay now so why did this happen or or
what is the advantage or disadvantage of
this slow method versus this fast method
the slow method is accurate it will it
will give you the exact duration it will
start at the exact time that you have
mentioned it will stop at the exact time
that you have mentioned but the first
one has an error of a couple of seconds
so if but it but it takes place very
fast it happened very very quickly so if
you are fine with a couple of seconds
being up or down then I recommend you go
by the fast method but if you have to
maintain accuracy uh if you have to
maintain complete accuracy of the time
mentioned then I recommend that you go
by the slow method okay so let me just
copy it on both of these commands
uh now one more thing so I as you can
see that there is a lot of output here
so how do we reduce all of this output
as well because there's a lot of useless
data here as well I'll just quickly copy
this so this was the first one
so this was the first one okay and then
the slow one
uh there was no C copy here
okay I named it slow
you can see the full Command right here
okay so this was a this was the slow one
this was the first one it took almost a
minute this took place almost instantly
now so this is how do you remove the
first 10 seconds how about if you want
to remove the last 10 seconds okay now
uh if you if you already know the time
frame that makes it much much easier
okay so let's say that since we all know
that this is a one one minute video and
I want to and I want to remove the last
10 seconds okay that is in this case my
video would actually be from zero
seconds to 50 seconds okay obviously
sometimes you may not know the duration
will we will check on that example as
well but let's say key you do not know
how let's say that in this case we do
know
uh what is the duration of the video
file
now the format for now the format for
that is
the format for that is ffmpeg same thing
minus I one minute underscore timer this
is our input file okay now here what we
want to do is want to keep it from the
beginning up to 50 seconds okay so from
the beginning up to 50 seconds if you
are starting the file right from the
beginning we do not have to mention the
SS part this is not required if you are
starting the file from the beginning but
since we want to end at this particular
time interval we can either use minus t
50 okay this tells me that I have to go
up to 50 seconds or I could also use t o
up to 50. both of these mean the same
thing in this context here but I usually
go with Dash T it's easier and and uh
less lot less confusing
so t50 and then let's give it as
[Music]
0 to 50 let's keep this as slow dot MP4
okay now this is again a 50 second video
Let's see now so one more thing that I
was about to tell you is how do you
prevent all of that output for from
coming so there is a very simple way to
do that that is hide underscore Banner
okay this is part one of it how do you
reduce the output and the other part is
log level
Panic okay now if you use these two
flags your output would be very limited
and you won't see a lot of useless
output so if you run that
okay so as you could see there is that
there is almost no output I think we
should have put log level info here so
that at least you could have known
if this command is working or not
I think we're going to stop this one
right here and let's put this as log
level info
okay this is slightly better it will
give you some information
so I am going to do the exact same thing
here so the command is exactly the same
ffmpeg this is just to reduce the amount
of output one minute timer this is our
input file
up to 50 seconds starting from the
beginning up to 50 seconds 0 to 50 slow
dot MP4 our output we want as MP4
now if I were to run this
so we are getting some output but it is
asking me if I want to override this
file I can do a y here
okay so as you can see that this is
approximately going at 1X the speed so
it will still take me around 50 seconds
50 to 40 seconds
you can see how much time has been
completed right here
so just a few more seconds to go
so as you can see that there is much
less output this time
and if you were to set this log level to
panic then there will be almost be no
output however I still recommend you put
it as log level info uh so this is done
as you could see this still took some
time and if we do the fast version how
do we do the fast version by simply
appending a minus C copy okay if we do
that we can change this to fast okay but
again the issue is of accuracy so and we
are done okay we are done already so
again if we check those out
so so this time it was so this time the
command that we ran was uh 0 to 50 fast
and 0 to 50 slow so if I were to run if
I were to run 0 to 50 slow
so as you can see that began exactly at
zero let me just pause it
okay so it began exactly at zero and it
will end
it will end exactly at 50 or rather 49.
it will end at 49 but if we were to run
the 0 to 50 fast now it will begin at
the right time because that is not where
we have cut okay so it will begin at
zero but it would end at a probably a
different time so 49 50 okay so this one
it did go up to 50 but the previous one
went up to 49 and that was a bit more
accurate you will see
so it stopped at 49.
so if accuracy is not a concern if a
couple of seconds accuracy is not a
console then you can go by the first one
but if accuracy is important then you
should go by the slow method now so this
is when we have to remove some parts uh
this is when we have to remove some
parts of it let me just quickly copy it
so 0 to 50 fast copy
okay I'll just show this command to you
this is the fast method okay and then of
course we have the slow method as well
slow but accurate
so the slow method was something like
this
so the only difference between these two
commands
the only difference between these two
commands is the dash C copy here okay
now dash C copy uh what the what Dash C
copy does it is it copies the entire
video as it is okay without
demoxing it without muxing demoxing or
rather without encoding it encoding
right now is not that important you
could simply understand it is that it
copies it as it is without any quality
change this this method prevents any
quality degradation
so hide Banner login info this is just
helpful in preventing too much output
now so so in the first case we remove
the first 10 seconds in the second case
we removed the last 10 seconds now what
if we want to keep only a portion in
between okay that is let's say what if
you want to keep or let's say you want
to remove the first
let's say five seconds
and also remove
and also remove last let's say 15
seconds let's say 15 seconds okay now
again since here we already know the
video duration so if you are removing
the first five seconds uh if you're
removing the first five seconds then my
actual video is starting at five seconds
and it is going up to if you are
removing the last 15 seconds as well it
is going up to 45 seconds okay
now so there are two things there are
two ways in which we could have achieved
there are two ways in which we can
achieve this basically everybody is
going to start with from Five Seconds up
to 45 seconds now there are two ways in
which we can do this the first way is
ffmpeg
minus uh height Banner
okay
log level
info this is just again to suppress the
output uh log level info minus I is one
minute timer okay this is this is the
same input file
now so there are two ways to do this
I'll show you both of the ways now the
first way uh now the first way is
obviously when are we starting from and
to put a filter on timer on the starting
point we use minus SS okay now since you
want to start from five seconds so we'll
put the SS as five
okay now uh since we want to end the
video at 45 seconds okay we want to end
the video at 45 seconds there are two
ways in which you can do this the first
way is by specifying the end point the
other way is by specifying the duration
okay now what does the end point and
duration mean very simply
so if my video is running from 5 Seconds
to 45 seconds the duration
is going to be 40 seconds okay the end
point is 45 seconds but the duration is
40 seconds so when we use minus t here
it implies the duration okay from 5
Seconds to how much longer do we want
the video to go on so we want an extra
40 seconds because from 5 Seconds up to
45 seconds deduction has to be 40
seconds so we want the video to go an
extra 40 seconds this is Method number
one okay it will give you the same
result and let's say let's let's just go
by the slow method in this case it's not
in and it's not a very large video
anyways uh we'll do uh five to forty
rather 5 to 45
to 45 T dot MP4 obviously this is a
slower method
okay it's going to take some time
so the important thing here is we took
the duration here okay we took the
duration here so it started from Five
Seconds went up to 40 seconds more so a
total of 45 seconds we will also check
out the output as well
foreign
so we have completed 37 seconds
all right so done so if we were to play
that file uh let's say uh so this was 5
to 45 right so 5 to 45 now see it begins
at five seconds
it begins at five seconds it's a 40
second video and the end point would be
at 45 this is at 43 it there's still
some time so if I play it so if I were
to play it it would end at 44 okay
because again it it does not go up to 45
so this is when we use the duration okay
that is here the duration was 40 seconds
but what if we want to specify the end
point if you want to specify the end
point so in that case we simply use t o
in that case we use t o and now our
endpoint is up to 45th second okay so
this goes on from the five second of the
original video to the 45th second of the
uh to the 45th second of the original
video now here I'm going to use t o okay
and if we go do that again now this is
obviously again I'm using the slow
method the fast method would be slightly
inaccurate
if you want to use a fast method just
put a dash C copy right before the
output file I'll show an example as well
so this is done up so 29 seconds have
been done we are only going up to 45
Okay so
this is the one that we did right now
so as you can see this also began at
five seconds this also began at five
seconds and it would end at 44 seconds
okay this is almost at the end point it
would end at 44 seconds essentially 45
seconds
now so both of these do exactly the same
thing but the difference between t and t
o okay let me just copy the commands
so
so the first let's look at the T command
so in case of T command we specified the
duration
okay and in case of the
T O command we specified the end point
okay so I think we should I should
so the difference here was that we gave
the duration from five seconds and the
next 40 seconds after the fifth second
and from here we mentioned the starting
point and the end point
okay now uh
I guess this is it for this video so you
could have you could have removed from
the beginning you could have removed
from the end or you could have removed
from the beginning and the end as well
okay so you can use any of these
commands obviously yes to make it faster
all you had to do was add a minus C
copy right here okay doing this would
have made the video go fast it would
have been slightly inaccurate but
Twitter Made It Go much faster okay so
that's it for this video we will
continue we will discuss more details or
we'll discuss more uh commands right in
the next video that's it
all right so in this video we'll just
check out one more uh one more way to to
put the timers uh to put the timers when
you want to trim parts of a video
so in our last case when we wanted so in
our last video when we wanted to trim
out let's say the first 10 seconds you
wanted to remove the first 10 seconds
the command that we used was ss10 okay
now 10 by itself means seconds here but
uh our video obviously was a one minute
video but what if it was not a one
minute video what if it was it was let's
say a 15 Minutes video or let's say it
was a two hour video in that case how do
we specify the time interval very simply
um in that case what you would have done
is ffmpeg minus uh minus minus
ffmpeg minus I uh you have to specify
the input file here let's say the input
file is same one minute timer okay uh
let's say starting at now how do we
specify hours minutes and seconds so
let's say 0 0 uh zero zero and let's say
20 okay so what this means here is hours
minutes and seconds okay so if you have
a long enough video you can use this
method as well so basically this
represents HH mm and SS obviously the
accuracy is also up to milliseconds but
I have never had to use that actually so
uh so you can use this convention as
well now of course you could have used
the same thing for time duration or end
point as well now if we were to use
let's say minus 2 here okay if we were
to use a two flag here that would imply
the end point okay that would imply the
end point what does that mean
so let's say if if I want to keep let's
say if I want to keep from let's say if
I want to keep the let's say if I want
to start the video from the 20th second
up to let's say for let's say 55 seconds
okay from the 20th second up to 55th
second
okay so in that case how would I have
specified it 20 seconds up to zero zero
zero zero so hours minutes and seconds
that is 55 seconds let me do the let me
just let's go by the first method here
uh let's say 20 to 55
2 dot MP4 of course there's going to be
a lot of output in this particular case
because I have not used hide Banner or
log level let's just still then check it
out anyways so if I do this here let me
just check if the yeah start timer 20
and timer is 55 all right so this is
from 20 seconds up to 55 seconds if I do
an okay so as you could see that we saw
all of this output then there is
something going on here
so the speed is still 0.7 but this is
not a very long video
foreign
that we started the video from 20
seconds here okay but it is showing 20
but a few seconds back it showed 15
seconds or 10 seconds uh now in this
case we have to understand that when you
do SS the timing of the video resets
okay the timing of the video resets that
is now 20 seconds will be counted as the
beginning of the video okay or 20
seconds will be counted as zero okay so
so if I were to check this one out so I
named this 20 to 55 20 to 55 here we are
okay this is 2 using the duration
so as you can see that this began at 20
seconds okay as you can see that this
began at 20 seconds and it's a 35 second
video so if you go up to the end it will
end at 54. okay and at 54. okay now uh
because I've also done the duration one
as well now if you wanted to go by the
duration so for the duration part now if
you are going from 20 to 55 the duration
the duration of the video or how long
the video would have been is 35 seconds
okay so at that case when we are using
the T flag or the duration flag it we
would have used
30 seconds sorry not 30 seconds 35
seconds okay from 20 seconds and the
next 35 seconds so 22 so 22 55 t
uh of course we will surprise all the
output Okay so
hide Banner
and hide underscore Banner
okay and then we have log
level info okay so info gives you some
information at the very least
okay so info gives you some information
whereas if I had written Panic here
Panic then it would have given us no
information the file would have simply
completed
okay so as you can see it began
somewhere 13 seconds that is because the
start timer has now been reset
so obviously it will be a 35 second
video so it will go only up to 35 it
will end much before that actually
so as you can see it ended right before
it hit 35 so if we open up the other
file 25 to 55 t Okay so as you can see
that
it begins
that it begins
it begins at 20 okay because we wanted
to start the video at 20 and it will end
again at 54 it's a 35 second video it
will end at 54. okay it's at the end
so I guess that's it for this video
all right so in this video we are going
to learn how to convert from one format
to another for example some of you may
have some videos which are in the MP4
format or maybe uh for example you may
have some videos which are in the MP4
format or you may have some videos which
are in the Avi format or they could be
in MKV format now how do you inter
convert those into each other very very
fast okay without any quality loss or or
without taking this or without it taking
up too much of your time it's very
simple
so again we will take the example of the
one minute timer MP4 and we'll try to
convert this to MKV this is very very
simple so ffmpeg as usual minus I minus
I tells you uh the input file so we'll
take one minute one minute timer so this
is our input file now we want to let's
say convert this into an MKV file as it
is without any changes we want to
convert this the entire file into an MKV
file very fast so minus C copy okay then
whatever name you want to put it let's
say
MP4 to MKV dot MKV okay that is all that
you have to do you have to Simply put a
minus C copy here and then whatever
format you want it right here of course
this will give a lot of output so I just
will decrease that so hide Banner
okay and log level
log level info okay so that's it and as
you'll see this will be done very very
quickly so
and it's done already okay it's done
already so if I were to play this file
there is the MKV format right here so if
I were to play this as you can see this
is now an MKV file okay there is zero
quality loss and it begins and
and it begins at
it begins at zero okay as you can see
here and it is a one minute file ending
at 59 okay you can see it will end at
59.
okay so so you can use you can use this
script to convert an entire directory of
files uh so I'll just copy down this one
so you can use this script to convert an
entire directory of files of course you
could have used you could have used this
to convert from mkb to MP4 in that case
this footage just have been an MKV this
would have been an mp4 now so what if
you have an entire directory of files
okay what if you have an entire
directory or files now for that we can
use a loop okay for that you can use a
loop now so the format of a loop looks
something like this for let's say let's
say you have a directory full of MP4
files uh let's say that you have a
directory full of MP4 files and you want
to convert them into MKV files let's say
you have a movies folder all of MP4 and
you want to convert that to MKV so how
do you do that you simply run a loop now
how do we write Loops in bash so I'm
first of all going to write it right
here then I'm going to copy that there
so the way you write Loop looks
something like this for f in whatever
the format is let's say you have all of
them in MP4 like I have it here okay for
f in dollar MP4 do okay so do gives you
uh do tells the command prompt on to
what what does it have to do what does
it have to do you have to run the ffmp
command so ffmpeg minus side Banner you
could use this you could emit this
entirely up to you hide underscore
Banner
minus log
level info okay minus I now my input
file is going to be this F command here
why because if I were to write an LS
here okay I have this MP4 I have this
MP4 okay so for one point F will be this
the other point F would be this one okay
so uh
so F in Star MP4 yaniki means that this
will convert these two files do FFM back
hide by log level info one dollar F okay
so dollar f means whatever file it is
handling right now okay whatever file it
is handling right now
what do we want to do is we want to
convert this into MKV so minus C copy uh
into MKV now how do we do that we'll
have to use some string manipulation if
you're not familiar with string
manipulation I suggest you read up on
that so how do we manipulate the string
here we use same thing double quotation
here uh dollar bracket open F star
percent okay so this means whatever is
after the last uh whatever is after the
last dot okay for example if I were to
look here after the last dot we have MP4
here okay so instead of the last dot we
want it to be m k v here okay now this
basically let's let's put a converted
here
let's put a converted word here okay to
MKV so essentially what it does here is
this is obviously our output file this
is our output file
what it is doing here is that it will
keep the same name okay it will keep the
same name but whatever is after this dot
that is MP4 this part gets removed and
it will add a dash converted MKV okay so
let's run this command then you will get
it so anyways we are inside a loop so do
ffmpeg and then we will add a done okay
so this means that now our Command is
complete so if I were to copy this
command
and paste it right here I have not yet
run it so I'll just show it to you once
again so for f in dollar MP4 okay so
sorry dollar so for f in Star MP4 star
dot MP4 means all of the files that end
in MP4 so MP4 here MP4 here these two
obviously do not end in MP4 I mean this
is an MKV so it is not going to get
lifted it is not going to get listed do
it tells it is asking for the command
that you want to run so ffmpeg hide when
our log level info whatever this is just
to reduce the output minus I dollar F so
input file is whatever the f is at that
point of time minus C copy uh so that
the the process goes very fast and there
is absolutely no loss quality loss here
so star F star percentage converted to
MKV okay I want to convert this from MP4
we started from MP4 we wanted to MKV
with the same name and done so if I if I
were to run this
bad substitution what did I make where
did I make a mistake here
uh did I do a percentage and that error
here probably that is what I did do done
I probably messed this up right here
yeah so I messed that up so as you can
see we are already done okay we are
already done so if I were to if I were
to show you the so as you can see here
so one minute timer has converted to one
minute hyphen converted MKV this is just
for understanding and your one minute
video has converted to one minute
converted MKV everything else remains
exactly the same the size is exactly the
same the duration would also be exactly
for example if I were to run this
so one minute timer
so
starts at zero
ends at 59 and one minute timer MKV
converted okay exact same thing it would
start at zero
end at 59 okay the format has been
changed okay so you can use this to
convert entire directories of movies or
or videos from One format to the other
very quickly without any change in
quality I guess that's it for this video
I'll see you
