[0:01] foreign so in this video we'll just do a [0:04] quick uh we'll just do a quick overview [0:06] of how to install ffmpeg now first of [0:09] all you must always check if you have [0:10] ffmpeg installed uh just open up any [0:13] terminal and type out FFM Peg uh if you [0:17] see all of this here it means that [0:19] ffmpeg is already installed you don't [0:21] have to install it in case you do have [0:24] to install it uh the and if you have [0:27] Homebrew installed okay if you have [0:29] Homebrew installed you can simply write [0:31] group install ffmpeg that is you could [0:34] simply do Groove install if you can Peg [0:37] and that would work if you do not have [0:40] Homebrew installed I highly recommend [0:42] that you should have it how do you [0:44] install Homebrew just Google home brew [0:47] and you will land on this page brew.sh [0:50] and all you have to do is copy and paste [0:53] this line just copy it right from here [0:55] paste enter it may ask you for your [0:58] password that would be it it will [1:00] install Homebrew you may may have to [1:03] restart your terminal so once you have [1:06] home brew installed once you have [1:09] Homebrew installed you can go back to [1:10] this and do Brew install ffap that is [1:13] right through install effect right here [1:15] it should work out in case you don't [1:18] know what a terminal is uh [1:20] FFM bank is then not for you you have to [1:23] be comfortable with the terminal before [1:25] you can understand how to use ffmpeg [1:28] okay apart from that that's it this is [1:30] it was a quick video thank you [1:37] so in this video we are going to learn [1:38] how to trim how to trim video parts or [1:42] how to extract a particular segment of a [1:46] video [1:47] so I have a couple of sample videos here [1:49] so I have a one minute timer video here [1:51] I hope you can see this so this one [1:54] minute timer video is nothing it's just [1:56] a video of a minute it's a one minute [1:58] long video but I also have a timer added [2:01] to it you can see there's a timer right [2:03] up of here [2:05] so there's a timer added on the upper [2:07] right hand corner it matches with how [2:09] long the video has been going on it's [2:11] just a time lapse simple video of [2:14] so as you can see this it's showing 20 [2:16] seconds and we are 20 seconds into the [2:18] video as well so this is just a sample [2:20] video just to understand uh at what time [2:22] frame are we working at [2:25] so now how do you trim a section out of [2:28] a video very quickly [2:30] for example if we take for example if [2:33] you want to remove the first 10 seconds [2:36] but keep the rest now keep in mind this [2:37] is a one minute video it's a one minute [2:39] video so if you want to remove the first [2:42] 10 seconds we want to remove the first [2:45] 10 seconds [2:48] that is we want to keep the video from [2:51] 10 seconds up to one minute now in that [2:53] case how do we in that case how do we do [2:56] that so first of all I am in my ffmpeg [2:59] directory this is the directory which [3:00] contains all of these files you can [3:02] check this out by using LS I hope you [3:05] can see this very clearly [3:07] uh in any case I'll just make this a [3:10] little bit bigger unless yes I hope this [3:12] should be very this should be visible [3:13] anyways so now how do I remove the first [3:16] 10 seconds but keep the rest [3:19] now for that we must begin the video at [3:21] 10 seconds and how do we achieve that [3:23] very simply ffmpeg the command is ffmpeg [3:26] now we give the input file that is given [3:30] by minus I now here I am using one [3:33] minute timer as my input file so ffmpeg [3:36] I one minute uh underscore timer as my [3:39] input file so minus I here is the input [3:41] file now when do we want to start our [3:45] output file we want to start from the [3:48] 10th second because we want to remove [3:49] from 0 to 10 so we want to start the [3:51] file at the 10th second so we start it [3:54] by using minus SS now SS tells you the [3:57] start timer of our output video now [4:01] there are two ways in which we can do [4:02] this we could have done this either as [4:03] 10 okay now 10 here stands for 10 [4:06] seconds I'll just give an example and [4:09] then we'll give the output file name [4:10] let's say let's say the output file name [4:13] is 10 to [4:15] 10 to end I'll just tell you why did I [4:18] do an end dot MP4 [4:21] okay I did an mp4 here so [4:25] let me just add one more thing here slow [4:27] okay now you'll just see in a second why [4:29] did I append this slow word here so if [4:31] we do this if we do this right here if I [4:33] run this command you will see [4:37] so we see a lot of output and then there [4:40] is something that is going on here [4:43] so as you can see that the speed is 0.8 [4:46] X which means that a one minute video [4:48] would take somewhat longer than a minute [4:50] or almost a minute [4:54] so you can see that we have completed 20 [4:56] seconds of this now of course this is a [4:59] this is a slightly slower method there [5:01] is also a faster method both of them [5:04] have their advantages and disadvantages [5:06] we'll come to that in just a second [5:09] so let's just complete this one [5:16] all right so this is done so when it is [5:18] when it is over my command front returns [5:20] my command prompt returns so now if you [5:23] look right here so there is a 10 to end [5:25] slope the output file that I had written [5:28] here was 10 [5:30] to end was 10 to end slow and if I were [5:33] to open up this file remember we removed [5:36] the first 10 seconds we removed the [5:38] first 10 seconds so if I all right why [5:41] don't we do that why don't we first take [5:43] the fast one as well so if now there is [5:45] one more way that we could have done [5:46] this done this faster as well [5:49] same command okay but instead of going [5:52] to add one more thing here minus C copy [5:54] okay minus C copy and I'm going to [5:58] change this to fast [6:00] okay now you will see what did I do here [6:02] so this one took us almost a minute uh [6:06] this one minute video almost took us a [6:08] minute and what about this one pay [6:10] attention [6:12] and it's done already okay it's done [6:14] already so you could see that this fast [6:18] one is already done whereas that took us [6:19] about a minute this one is done only so [6:22] now what is the difference between this [6:24] slow process and this fast process now [6:27] remember we remove the first 10 seconds [6:29] so if I were to open up this slow one [6:32] it started exactly I think you'll see [6:34] this right here okay so if I were to [6:36] restart this video [6:41] okay so it is going to start exactly at [6:45] 10 seconds we remove the first 10 [6:47] seconds so it's going to start exactly [6:48] at 10 seconds that if I play it it's a [6:51] 50 second video [6:53] so it go it's it is going to go up to a [6:55] minute [6:58] okay but if I were to play this fast [7:01] video now the issue here is it's going [7:06] to start at three okay it started at 13. [7:08] so basically so basically [7:12] it started at 12 actually it started at [7:14] 12 I cannot go any further back okay I [7:17] cannot go any further back it is the [7:19] video has started at 12 only [7:22] okay now so why did this happen or or [7:26] what is the advantage or disadvantage of [7:29] this slow method versus this fast method [7:31] the slow method is accurate it will it [7:34] will give you the exact duration it will [7:36] start at the exact time that you have [7:38] mentioned it will stop at the exact time [7:40] that you have mentioned but the first [7:41] one has an error of a couple of seconds [7:44] so if but it but it takes place very [7:48] fast it happened very very quickly so if [7:50] you are fine with a couple of seconds [7:52] being up or down then I recommend you go [7:54] by the fast method but if you have to [7:57] maintain accuracy uh if you have to [8:01] maintain complete accuracy of the time [8:03] mentioned then I recommend that you go [8:04] by the slow method okay so let me just [8:07] copy it on both of these commands [8:09] uh now one more thing so I as you can [8:11] see that there is a lot of output here [8:13] so how do we reduce all of this output [8:16] as well because there's a lot of useless [8:17] data here as well I'll just quickly copy [8:19] this so this was the first one [8:24] so this was the first one okay and then [8:29] the slow one [8:35] uh there was no C copy here [8:39] okay I named it slow [8:43] you can see the full Command right here [8:46] okay so this was a this was the slow one [8:50] this was the first one it took almost a [8:52] minute this took place almost instantly [8:54] now so this is how do you remove the [8:56] first 10 seconds how about if you want [8:58] to remove the last 10 seconds okay now [9:01] uh if you if you already know the time [9:03] frame that makes it much much easier [9:05] okay so let's say that since we all know [9:08] that this is a one one minute video and [9:10] I want to and I want to remove the last [9:13] 10 seconds okay that is in this case my [9:16] video would actually be from zero [9:19] seconds to 50 seconds okay obviously [9:23] sometimes you may not know the duration [9:24] will we will check on that example as [9:26] well but let's say key you do not know [9:28] how let's say that in this case we do [9:30] know [9:31] uh what is the duration of the video [9:32] file [9:33] now the format for now the format for [9:36] that is [9:37] the format for that is ffmpeg same thing [9:40] minus I one minute underscore timer this [9:43] is our input file okay now here what we [9:46] want to do is want to keep it from the [9:48] beginning up to 50 seconds okay so from [9:51] the beginning up to 50 seconds if you [9:52] are starting the file right from the [9:54] beginning we do not have to mention the [9:55] SS part this is not required if you are [9: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