[0:00] hello this is Steph and welcome to my [0:02] channel again and today I'm going to [0:04] show you how to use the complex filters [0:07] uh better the filter complex using FM [0:12] pack first of all what are the filter [0:14] complex [0:15] um the filter is complex are the complex [0:18] filters filters complex is the options [0:20] that you have in a pack is uh that [0:23] category of filters that require uh [0:26] multiple inputs or multiple outputs [0:30] and we saw something in the past for [0:32] example the concatenation for example [0:35] with the GIF we saw the split so we have [0:39] a rough idea about what a complex filter [0:42] is and now we're going to see something [0:45] a bit better in detail [0:48] uh here we have Windows ready behind me [0:52] at the moment it's time to get started [1:03] okay here we are we have the terminal at [1:06] the top uh this is the windows terminal [1:09] so I changed from the CMD uh to this [1:13] Windows terminal it's super cool because [1:15] uh what you can do is also to [1:18] select the one that you want so not only [1:21] the command prompt that I'll be using [1:23] most of the times but the windows [1:25] Powershell develop compound prompt for [1:27] visual studio [1:30] um the [1:32] um [1:33] WSL windows subsystem for Linux I [1:36] install Ubuntu I have something with a [1:39] anaconda mini counter actually [1:42] um like to switch from one in the other [1:46] or having multiple tabs here it is a [1:49] super super cool and uh [1:53] I suggested if you would like to go on [1:57] um coding and using the command line so [1:59] here we have two videos [2:02] here on the left [2:05] where [2:07] so videos about Singapore every people [2:09] who follow me on Instagram uh I take [2:12] advantage to [2:14] give the my references about the social [2:17] media here [2:19] um [2:20] so um I've been to Singapore recently [2:23] and I would like to make a video about [2:25] Singapore I have a couple of videos here [2:28] play [2:31] Singapore one and this is uh the first [2:35] video [2:38] Singapore Marina Bay and the marina here [2:44] nice place to be and on the other we [2:49] have [2:50] Singapore [2:55] night [2:57] It's a Wonderful view accelerated view [3:00] of Singapore where the [3:06] cool so we would like to make a [3:08] Crossfade so it's it is a transition [3:10] from a video to another but in a linear [3:16] way so we don't want an Abrupt change [3:18] from one to the other it's not a [3:19] concatenation even if we did a [3:21] concatenation [3:22] advantage to show you [3:25] part about the concatenation here we use [3:28] the a filter complex actually but what [3:30] we would like to use is a so-called [3:32] Crossfade so here we have a [3:36] the [3:37] um the Crossfade filter there is a [3:40] called The X fade so the base code [3:43] stayed like this [3:45] and [3:48] what you would like to use is a F10 pack [3:51] minus I and the filter the freight and [3:55] the Fellas we want this input so here if [3:59] from Peg minus I single [4:03] one and then minus I single port two [4:07] these are the input files and then we [4:09] are immediately using the filter complex [4:12] so the filter complex is uh something [4:15] that accepts uh [4:17] multiple inputs multiple outputs and you [4:20] can also apply multiple filters here so [4:24] here we have for example the first input [4:28] and the second input so here we can put [4:31] zero and one like this so the input is [4:35] uh put it this way before the name of [4:38] the field name of the and [4:44] after [4:46] the equal sign we got to put the filter [4:49] configuration so here we've got to put [4:51] the parameter transition [4:55] here my transition I want to be a Fades [4:58] it's fading from a video to another [5:01] I got to set the duration of the fade in [5:04] this case it is one second [5:07] and also [5:10] um we got to put the offset what is the [5:13] offset the offset is the [5:16] um the time I want the first video to [5:19] start fading out so here in this case I [5:22] have a video that is more or less 10 [5:24] seconds long so I can put it in the [5:26] middle five seconds [5:28] and in the end I can put the name of the [5:31] parameters so the name of the parameters [5:33] uh the code sorry the collect parameters [5:37] leave x264 [5:41] preset [5:43] slow minus CR f [5:47] at 15 so not so so a fairly high quality [5:52] but not the super high quality in order [5:54] to keep this phase [5:56] the space contained and [6:01] then [6:03] we can put the name of the files in this [6:05] case we can say Singapore [6:09] xfader.np4 and let's see what happens [6:14] in this case we have an error what is [6:16] the the error here it says the first [6:19] input linked main time base do not match [6:22] the corresponding second input link X3 [6:25] so we have the time base so the let's [6:28] say the internal clock with which we are [6:30] ticking the advancement from one frame [6:33] and the other that is uh not set [6:36] correctly here this is faster than this [6:40] this has nothing to do with the frame [6:43] rate is only the advancement in terms of [6:46] time stamp that is present within the [6:48] file so what it would like to do is uh [6:50] to set the time base to the [6:54] um [6:54] photo audio video time based it usually [6:57] is calculated with the frame rate if I'm [7:00] not wrong so this is the what I found [7:02] out so if you um [7:04] correct me but this is a calculated [7:07] based [7:09] audio and the video time based [7:13] and so what we can do is to apply this [7:17] before the Crossfade so what can we do [7:20] we are still or we can use the previous [7:23] command so we have the [7:26] Singapore one Singapore two files this [7:30] uh still accepts the two inputs so here [7:34] let's put a bit of space then later we [7:36] are packing everything back [7:39] so what shall we do with the first input [7:41] with the first input we said that we [7:43] want to set the time base in order to [7:46] put it to the audio video time based so [7:49] set TB [7:51] equals to a b t b [7:54] so capital letters and then we're going [7:57] to put the set PTS [8:01] to the B the beginning of the uh [8:06] as you can do so start PTS [8:09] in this case we need to give an output [8:13] name so in this case it can be out [8:18] zero [8:19] the output file zero and then we got to [8:23] put the uh [8:26] semicolon the semicolon separates the [8:29] different filters so we have a first [8:33] um [8:34] set TB [8:36] and the set BTS then we got this output [8:41] there is a [8:43] by semicolon to the second output and in [8:46] the set sorry the second input file [8:47] second input file needs the same thing [8:50] so in this case we have the set TV [8:58] set PTS [9:00] equal to the pts and start BTS [9:06] and in this case we're going to call [9:08] this out one so we have the output uh so [9:13] we got just to sum up [9:16] first input that we call the zero file [9:19] zero that passes through the set time [9:23] base set BTS and it exit as out zero [9:29] then we got the second that is called [9:32] one it's a right here second one then [9:36] it's going it's going through the same [9:38] thing so we've got the the set TB set [9:41] time base and the set pts and it's [9:45] called the out one so we got out zero [9:48] and out one after we have the out zero [9:50] and the out one we're going to merge [9:52] them together in order to obtain a [9:53] single output in this case there's a no [9:57] need to call the output [9:59] um [10:01] because [10:02] it's like a sink we put the output [10:06] unnamed it and here [10:09] we got to put the first input and the [10:14] first a second in sorry the first output [10:17] of the previous [10:20] pipe and the output of the second pipe [10:24] coming from the second file so here we [10:26] got to put out zero [10:28] and uh out [10:33] Crossfade transition and blah blah with [10:36] everything that we said before and let's [10:38] see if now it's working [10:40] it asks if you want to overwrite the [10:42] file and we click yes [10:44] and it seems the thing is working cool [10:48] so we wait a bit of time until this is [10:51] finished [10:54] and uh you will see the speed [10:57] yeah it is more or less recorded no [10:59] video and now it's time to play uh [11:03] Beautiful video so we've got the [11:05] Singapore X fade [11:08] and here we go with the first input [11:13] there is a transition from the first [11:16] video to the second [11:17] cool so I got to say that this thing [11:21] about the set time base is a bit uh [11:24] say not the forecast it's something that [11:28] I didn't know so [11:30] um [11:31] most normally this is a thing that you [11:34] shouldn't do but the [11:37] the Crossfade is the necessary one but [11:40] so we saw a slightly more complex filter [11:43] complex so-called filter graph [11:46] that [11:47] um [11:50] fine [11:51] that's fine feel the complex [11:55] okay we have our Crossfade video we just [11:58] created and now we are going to use it [12:01] to make a video with the rgmb together [12:06] all in a single video with a tiling so [12:09] original video red Channel green Channel [12:11] blue Channel [12:14] and we use a filtered complex so to [12:16] understand that how the filter complex [12:19] are working so we are using FM pack and [12:23] seeing Apple X fade.mp4 is our input [12:26] file here we can repeat the input [12:30] multiple times but we use the split [12:32] filter which is a bit more clever and so [12:36] it makes us understand better how the [12:38] filter graph is working so we have the [12:42] inputs and the outputs explained better [12:45] with a complex field you're going to use [12:46] so then we're going to use the filter [12:49] complex [12:52] we use the accent go to the new line the [12:55] triangle accent [12:58] and uh the next line would be the first [13:02] line of the filter so here we put the [13:05] quote and our input is the file so we [13:11] have the zero then we put a split the [13:15] split requires the outputs [13:18] parameter the outputs parameter we have [13:21] three channels so we have a one two and [13:24] three in this case uh how can we call [13:26] them we call them [13:28] um let's say uh V1 [13:32] V2 and V3 [13:35] so we have a [13:39] zero there is an input then B1 V2 V3 [13:42] where that will be the input for the [13:45] next filters and what are the next [13:47] filters the next filters will be [13:51] so the filter is a loot RGB [13:57] if this stands for lookup table RGB in [14:01] this case we can make correspondences [14:03] between inputs and outputs uh [14:06] different channels in the RGB color [14:08] space and uh [14:10] so root RGB [14:13] this is a red channel so we got to put [14:15] the green at zero [14:18] and the blue at zero [14:20] and this will be our red Channel [14:23] and [14:24] colon [14:26] Uline [14:29] we have a steal the loot RGB where we [14:33] put in this case the red is zero and the [14:36] blue at zero since we want the the green [14:39] Channel [14:43] RG [14:47] okay and the third line will be V3 [14:53] loot RGB equals to a red of zero and a [15:00] green of zero since we want the blue [15:03] Channel [15:05] and now we separate the three rgmp [15:10] then now we want to put on the top line [15:14] the input and the red channel so we put [15:17] a h stack horizontal stack of these two [15:19] inputs and the same thing will be done [15:22] at the bottom where the the green and [15:24] the blue channel so here the next will [15:28] be the input video Zero and a red [15:34] Channel [15:36] this case it is on each stack [15:39] equal to inputs [15:42] so this is the parameter that we need to [15:45] accept the H stack accepts the inputs [15:48] equals to two since we have the uh zero [15:53] and Dr and [15:55] we name it top [15:58] oh [16:01] okay and we do the same thing with the G [16:06] and the B [16:09] right here there is on each stack [16:12] with two inputs [16:17] and this will be our bottom [16:21] okay [16:23] and now the final filter uh the final [16:26] one will be a vertical stack so we put [16:28] the top and the bottom together [16:31] and so we have the top and we have the [16:37] bottom [16:38] with this stack equals to [16:43] inputs to the same as each stack to be [16:46] in the v stack go to two here we can [16:50] select if we wanted to give an output to [16:54] the output a name or not so here we can [16:56] for example put out [16:59] is a output but you got to keep in mind [17:02] that here we got to put a map [17:04] out [17:06] in this way if you want you can put it [17:09] in this case just to avoid since the [17:11] notation is quite long and putting [17:14] something like this is a bit more [17:16] um [17:17] shorter and won't stand back we [17:19] understand better what it's doing since [17:21] the output is one so it's okay [17:25] now it's time to put our options so [17:28] there is the lead backs 264 [17:31] preset [17:33] let's put the slow [17:37] and as a constant rate Factor we put 18 [17:42] so a fairly good quality but not the [17:44] maximum just to contain the size of the [17:46] file and finally we give a name [17:49] [Music] [17:50] to do it so we can it can be Singapore [17:53] it's fader RGB [17:57] as format we can put MKV let's see [18:01] how it can be [18:04] good uh I think everything is okay so to [18:07] sum up we have the splitting three [18:09] channels then we take the red green and [18:13] blue of the three Channel we just output [18:15] from the split then we have the [18:19] horizontal Stacks we put the two videos [18:22] together respectively the input and the [18:25] red channels [18:27] um then we have the green and the blue [18:29] together and then we [18:31] see if it is working and it's working [18:34] now we wait for the output to be [18:36] generated uh now maybe it is a [18:41] bit slow but the video is not that long [18:44] and we wait until the end of the [18:46] processing [18:51] [Music] [19:01] okay now the processing has finished and [19:04] now it's time to play the video so I [19:06] think that the video will be too big for [19:09] the screen so [19:11] um I'm trying to open it with the oclc [19:18] and here we go we have the input the red [19:22] channel the green Channel and the blue [19:25] as we wanted again if you would like to [19:28] take a look about how the complex [19:30] filters work and to build your [19:32] photograph so again we make a sum up [19:36] so to set your filter complex it should [19:40] be set with a filter from Flex [19:45] and then here we put the input [19:50] then the name of the filter [19:53] with its parameter iron one [19:57] uh equals to Value one then the second [20:01] value will be in the [20:04] uh [20:05] a colon then W2 [20:09] Etc and here we put our output [20:14] if we generate from a single input [20:17] multiple outputs like the split filter [20:19] we put the out one and out to [20:25] so here we have all then [20:29] with a semicolon we decided what to put [20:31] in the next filter and here we put [20:36] out one [20:39] and [20:41] I'll [20:42] then we put the name of the filter and [20:44] so on and so forth so the fundamental [20:46] thing is [20:48] input here then output output or outputs [20:54] after the filter itself and we go on to [20:58] have a better picture about the filters [21:02] that we have here in contact we can go [21:05] with FM pack minus h [21:09] feel this no I'm sorry [21:12] if I met if I'm packed minus filters [21:16] will show the list of all the filters [21:18] that we have available if you want to [21:21] look for the filter of choice in Windows [21:24] you can use with a pipe fine Str [21:28] ucture let's find Str [21:32] Ike this [21:33] um let's say split [21:37] it will find the [21:40] dirt is up to you so here we have a [21:42] single video with a multiple video [21:45] outputs and here we have also [21:49] things regarding the audio so same thing [21:52] that we did with the video we can do it [21:54] with the audio so there's a cross fader [21:57] for the audio as well [21:59] it's called I think a cross fade check [22:05] across fader [22:08] um we have a Crossfade of two you've got [22:10] the audio streams and here we got the [22:12] the X faded ah we also have a x-fit [22:15] opens [22:19] parameters if I want to check we have [22:22] the final meters here we have X fader so [22:26] the thing is a FM pack minus h [22:31] ilton equals to Theta [22:36] and we can take a look at the [22:44] type okay it's a transition [22:51] who [22:53] okay so we saw something about the [22:55] filter complex [22:57] um I hope you enjoyed this one of the [22:59] most complicated things you can do with [23:02] fmpeg actually but it will help you a [23:05] lot in case you want to automate your uh [23:09] video generation process so if you would [23:11] like to make crossfades you want to make [23:15] fancy facts to your video [23:17] substantially sometimes you want to make [23:20] a slideshow of your vacation video [23:23] essentially you're doing something like [23:24] this or either you concatenate or you [23:27] Crossfade from one video to the other [23:29] there might be something else to say [23:31] about the cross fading if you want to do [23:33] it in a [23:35] good way so maybe it's a bit [23:40] uncomfortable to have the offset from [23:44] the beginning of the first video [23:47] um but knowing if you want to make a [23:49] concatenation with a Crossfade or [23:51] something but anyway this is a powerful [23:54] tool you can look yourself on how to do [23:56] it so it's like an overlay [24:01] anyway thank you very much if you reach [24:02] up to this point I hope you liked it if [24:05] you liked it like share and subscribe [24:06] and hit the notification Bell to be [24:09] always notified with the new video I'll [24:12] be releasing and um [24:15] I remember you to subscribe and follow [24:17] me on the social media uh I maintaining [24:20] and trying to maintain at least so [24:22] Instagram and Tick Tock uh for new [24:25] content [24:27] here and uh I hope to see you next time [24:30] with new content relative to multimedia [24:33] and much much more thank you very much [24:36] and ciao ciao [24:43] [Music] [24:51] foreign