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