[0:00] so FFM Peg is very simple and very [0:03] powerful and it's actually a lot more [0:04] straightforward than you might realize I [0:07] use it exclusively for my screen [0:09] recording and mic recording and then I [0:10] also use it for the postprocessing of [0:12] taking this phone video here and [0:14] slapping it into the corner of the [0:16] screen and drawing a little gray box [0:17] around that that's done entirely with [0:19] FFM Peg bass scripts and I've got my [0:22] recording script here and then I have an [0:23] additional script that's just going to [0:25] take everything and slap it all together [0:26] and give me that final video that's [0:28] going to get uploaded so I I'm going to [0:30] go over today how these scripts work how [0:32] I use ffmpeg and also the basics of [0:34] recording and some of the filter options [0:36] with it as well um I want to start by [0:38] going over why I'm not using OBS because [0:41] OBS is kind of the standard for [0:42] recording and I've gotten you know [0:44] questions asking if I'm using OBS I'm [0:46] not using OBS it's a huge program and [0:48] I'm not saying it's bad but it is just [0:51] too much for what I need all I need to [0:52] do is record my screen and record my mic [0:54] and that's it and OBS is this big tool [0:57] meant for recording and live streaming [0:58] and all of this other stuff and I just [1:00] don't need something that resource [1:02] intensive and not to mention if I try to [1:04] run it on my ThinkPad it just lags out [1:05] it is that resource intensive whereas [1:07] FFM Peg can instead just run exactly [1:10] what I need which is just the singular [1:12] recording command that I need it to be [1:13] running so um if you don't already know [1:16] FFM Peg is essentially just a bunch of [1:18] tools for audio and video manipulation [1:21] um everything from recording and [1:22] streaming to converting between formats [1:25] to applying filters onto audio and video [1:28] so for example I have a D noise filter [1:30] on my mic that is getting applied live [1:32] as I'm recording and writing to that [1:34] file so that's pretty cool and there's a [1:36] whole bunch of stuff you can do with FFM [1:38] Peg and it it really shines when you [1:40] want to be running a bunch of things [1:42] many times over and you don't want to be [1:44] you know having to open up like editing [1:46] software or you know Ken live or [1:48] whatever to actually apply those edits [1:51] since I'm running the same things every [1:53] single video I make you know I always [1:54] have to take this phone and put it in [1:56] the corner of the screen and draw a [1:57] little box around it so why would I do [2:00] that manually in an editing program when [2:02] I can just have a shell script to do it [2:03] right anyways so to record with FFM Peg [2:07] I know the commands with FFM Peg can [2:09] kind of appear intimidating at first if [2:11] you've never done anything with them but [2:13] you can break them down always into [2:15] input and output it's always going to be [2:17] an input file and an output file so if I [2:20] want to record my screen here this [2:22] screen is going to be the input and the [2:24] video file that I'm writing to is going [2:25] to be the output so I would start by [2:28] adding this- f for format X11 grab since [2:31] I'm on X and I will put the Wayland [2:33] equivalent in the description um so- [2:36] fx11 grab and then I want my input to [2:38] actually just be the second monitor here [2:40] so I'm going to start with 0 0 since [2:42] that's the top coordinate of the first [2:45] Monitor and then I'm going to add on [2:46] 1920 since my first monitor is 1920 x [2:49] 1080 I'm just going to add on 1920 and [2:51] then uh comma zero and then I'm just [2:53] going to give it an output file which is [2:55] uh I don't know test. MKV um and the [2:58] only other thing I want to do is just [2:59] give give a video resolution um just as [3:02] a good practice it's um better to just [3:04] give it a resolution so that way you can [3:06] just ensure you're getting the right [3:07] resolution if I go ahead and press enter [3:09] we are now recording my screen and uh it [3:12] is actually that simple the only other [3:13] thing worth mentioning if you don't know [3:15] your screen dimensions just check with X [3:17] randar and um it actually goes ahead and [3:18] tells me uh plus 1920 that is um where [3:22] I'm going to shift over that's where the [3:23] display port display actually starts [3:26] anyway so I could just cue to quit out [3:28] of this recording and then I could check [3:30] on it with you know MPV or whatever you [3:31] normally use and um yeah we've got a [3:34] screen recording perfect so if I wanted [3:37] to have audio on that recording as well [3:40] um I could go ahead and instead run this [3:42] with an extra input as um a Alon device [3:45] so I could do F uh oops falsa and- I [3:49] default and that's just going to run [3:51] with the default input device which is [3:52] my mic if you have multiple inputs then [3:55] just check and make sure you're [3:56] selecting the right one but I only have [3:57] one so I can just go with default there [3:59] and that is now recording my screen with [4:01] my mic and that is the most simple way [4:04] to record with FFM Peg um that is as [4:08] simple as just recording with one [4:09] command but of course it would be a lot [4:10] simpler to have it just run with a [4:12] hotkey which is what I normally do hence [4:14] why this recording script here so this [4:16] recording script allows me to just call [4:18] it with the hotkey and then run it to [4:20] record it toggles on and off recording [4:22] and then it also adds this little thing [4:24] in dwm Block so I can actually see if [4:26] I'm recording or not um and I just have [4:28] this bound as a hotkey so I I literally [4:31] I'm just calling this shell script with [4:32] the hotkey so um the main thing going on [4:35] here is this record function the first [4:37] thing I want to do is toggle on my [4:39] microphone since I normally leave it off [4:41] so I first toggle it on um and then I [4:43] have my two different FFM Peg commands [4:45] and I have it in two commands just [4:47] because I do want a separate audio file [4:49] for backup purposes essentially just in [4:52] case I ever did need an exclusive audio [4:54] file um so my screen recording command [4:57] is what I pretty much just explained [4:59] with the only additions of I'm setting [5:01] the frame rate to be 30 frames per [5:02] second and I'm setting the codec to be [5:05] h264 so CV is just for video Codec um [5:08] and- qp0 is for lossless quality um the [5:12] codec is actually going to it's going to [5:14] be in this MPV uh MPV MKV container [5:18] format here um MKV and MP4 and a couple [5:21] other formats are all Container formats [5:23] so if you set the codec they all support [5:25] different codecs so if you want to [5:26] actually set the codec you can do that [5:28] it's not like the codec is be determined [5:30] by the file extension so anyways I'm [5:32] setting the codec and then I just have [5:34] the file that it's going to get written [5:35] to here um and the date command is just [5:37] ensuring that every file name is going [5:39] to be unique so I'm not you know [5:40] overwriting old recordings or anything [5:43] um and then with the audio recording [5:45] part it's just getting written to a wave [5:47] file but the only thing of Interest here [5:48] is the uh audio filter which is this is [5:51] what the noise filtering um as I'm [5:53] recording is so it's just using FFM [5:56] Peg's audio filter of AFF TDN which I [5:59] have noidea idea what that stands for [6:00] but it allows for a bunch of different [6:02] noise filtering options and I'm using [6:04] noise floor of -75 but obviously that's [6:07] the kind of thing where you would want [6:08] to adjust it to your particular [6:09] microphone um mine has like kind of a [6:12] lot of white noise in it so this just [6:13] gets rid of that and it's a lot clearer [6:16] with that so um anyways that gets [6:17] written to a wave file and what I'm [6:19] doing with both of these recordings is [6:21] it's actually getting uh the P IDs sent [6:23] to temporary files so that way I [6:25] actually can check whether I am [6:27] recording or not at the end here um by [6:30] seeing if the file exists so if that [6:32] recording file exists then when the [6:34] script is called it's going to end the [6:36] recording and exit the script or if that [6:38] file doesn't exist it's going to start [6:40] recording which allows me to have just [6:42] one hotkey and always toggle on and off [6:45] the recording state with that hotkey and [6:47] obviously every time it records it's [6:49] just going to start you know a new file [6:51] uh for that particular recording and the [6:53] last thing happening in this script is [6:55] just the dwm blocks icon up here and um [6:58] credit to Luke Smith as usual for the [7:00] idea of the kill signals with dwm blocks [7:03] I don't know if it was his idea in the [7:04] first place or if he got it from [7:05] somebody else but that is where I got [7:07] the idea from so credit where it's due [7:10] um anyways I'm using just custom kill [7:12] signals to kill the recording icon block [7:14] up here um and replace it as needed and [7:17] I've gone over that a million times so [7:18] I'll just link to another video in the [7:20] description where I go over the dwm [7:21] block stuff but um I don't know the last [7:24] thing I'm doing is just sending [7:25] notifications um when I start or end [7:27] recording and this is my recording [7:29] script so it leaves me with a-wave file [7:31] and a MKV file and from there what I [7:34] have to do is take this phone video pull [7:36] it off of the phone and then combine [7:38] everything together so I have a script [7:40] to do that um and essentially I just go [7:43] to the directory that has my video files [7:45] in it I I make a new directory for the [7:47] singular video that I'm working on SLAP [7:49] everything in the directory and then [7:50] just run this script and um actually [7:52] before I go over the script I wanted to [7:54] mention this page here uh FF improviser [7:57] I guess would be how you would say it um [7:59] and this is a really really good [8:00] resource I will put it in the [8:02] description um it's got a bunch of just [8:04] like cheat sheet stuff for how to do [8:06] stuff with FFM Peg I've relied on this [8:08] site a ton for figuring out how to do [8:10] stuff because if you don't want to read [8:12] through the super thick FFM Peg man page [8:15] um this is way easier you can just skip [8:17] to what you need and it explains [8:18] commands um really really helpful site [8:21] so I will put this in the description [8:23] but anyways on to my script here and [8:25] this is where I'm going to start talking [8:26] about filters in FFM Peg a little bit [8:28] since um that is what I'm doing the [8:30] entire process is just applying [8:31] different filters so that it can then [8:34] you know take this uh screen recording [8:36] uh crop it uh flip it out remove audio [8:39] apply it onto the screencast so anyways [8:42] the first thing I'm doing is taking this [8:44] screen recording this uh sorry not [8:46] screen recording this phone recording as [8:47] an input file um and applying a video [8:49] filter I'm applying first a crop and [8:52] then a horizontal flip and you can apply [8:54] multiple videos uh video filters at once [8:57] with FFM Peg so crop comma horizontal [9:00] flip the crop dimensions are just crop [9:03] Dimensions um and the last thing I'm [9:04] doing is just removing audio since I [9:06] don't need audio from the phone video [9:08] and that outputs to this cam. mov the [9:10] next thing I need to do is map my audio [9:13] from my wave file onto my screen [9:15] recording my MKV so I'm just taking [9:17] those both as input files I'm mapping [9:19] them together and oh this is this is [9:21] pretty important this codec here is just [9:23] set to copy uh so that way I don't [9:25] re-encode the video because it is best [9:27] to avoid re-encoding a video if you [9:29] don't have to um a to save time and B [9:31] the more you re-encode the more chance [9:33] for errors Etc you're getting so um [9:36] avoid re-encoding when possible um and [9:38] then I just end up with this applied. [9:40] MKV I'm then going to draw the gray box [9:43] in the corner and that's just a video [9:44] filter for draw box um I'm just giving [9:47] it coordinates and a color and it's [9:49] going to fill up the box and then I get [9:51] this box. [9:52] MKV um then I'm going to Overlay this uh [9:55] cam. mov that got you know cropped and [9:58] flipped Etc um that's going to get [10:00] overlaid onto the screen video and I'm [10:02] using complex filtering here so that [10:04] first of all I need to actually make [10:06] sure they are in the same color space um [10:08] which is pretty important because by [10:10] default my phone video here is in a [10:12] different color space than my screen [10:13] recording so I need to make sure they're [10:15] actually converted to the same color [10:17] space um so I'm doing that here and then [10:20] after that I overlay the uh phone [10:22] recording onto the screen recording and [10:24] then that just gets exported to this [10:26] final. MKV which is what gets uploaded [10:28] to YouTube and then I just remove the [10:31] extra stuff um from the process and I [10:33] send myself a notification and this is [10:36] how I edit my videos with FFM Peg um [10:39] it's a lot easier to be able to just go [10:41] into a directory and run a script as [10:43] opposed to having to you know open up a [10:44] program like Kaden live and then import [10:46] all the files and you know rearrange [10:48] everything and then render it out it's a [10:50] lot easier just to run a script so this [10:52] is where FFM Peg really shines if you [10:55] have any sort of repetitive acction [10:57] actions that you're doing over and over [10:58] in editing you may well be able to just [11:01] replace it with FFM Peg scripts but [11:03] anyways I hope you enjoyed this video [11:04] and I'll see you next time peace