[0:00] Do you ever battle with finding the right tool  to create a GIF, compress a huge video file,   [0:04] or resize an image? How about capturing  your screen, running a live stream session,   [0:08] or audio ripping from a video you found? You  probably had a name attached to each need I   [0:12] just mentioned. What if I told you the ultimate  tool for all of these is likely already on your   [0:17] machine working silently under the hood in the  apps you use every day. It's called FFmpeg,   [0:21] and it's the engine that powers everything from  YouTube to Netflix. It recently rose to fame again   [0:26] with an unintended Twitter storm that ended in  Theo contributing $5,000 to the project, which got   [0:32] me thinking. People think of FFmpeg as a silent  library rather than something they can pretty much   [0:37] do anything with. I mean, FFmpeg is just this  incredible like what would you call a library   [0:42] system? Not only is open source and completely  free, it's probably the safest and highest quality   [0:46] option out there. Everything else is mostly an  FFmpeg wrapper. Every single application OBS   [0:51] probably fmp underneath the hood. all the prof  everything ffmpeg underneath the hood. But it   [0:56] has one huge problem. It's overwhelming and like  other familiar open source projects, it gives the   [1:01] user so much power eventually facing them with the  paradox of choice and endless amount of switches   [1:06] to config. I I think ffmpeg like they have all  these sort of parameters that you can add on   [1:11] the command line. It's like one of those cryptic  languages that only very few wizards understand.   [1:17] I'm here to say that FFmpeg isn't this impossible  tool for genius dark basement low-level engineers.   [1:23] And the truth is, you don't need to be an expert  to bend video, images, or audio to your will. You   [1:28] just need to know the right secrets and how to  put them to use. And yes, every once in a while,   [1:32] use a rubber. In this video, I'm going to  show you how to do everything with FFmpeg,   [1:36] but also how to add a touch that makes using  it smooth. Well, like coconut oil. We'll go   [1:42] from FFmpeg's surprising history to the simple  copypaste commands that will completely change how   [1:46] you work with media forever. FFmpeg is probably  one of the most consequential libraries of our   [1:51] day and does not get the love it deserves. I just  love it. I just think they're the best. Let's get   [1:56] started. FFmpeg's name is basically fastforward  Meg. Remember Meg? I mean the first version way   [2:02] back then. Who here remembers the early 2000s  internet? that wild west of websites where dancing   [2:08] babies and rotating word art gifts were at the  height of cool and every video you wanted to watch   [2:13] required a specific often terrible player to be  downloaded. It was a mess. But out of that chaos,   [2:18] a legendary programmer, the same genius who later  gave us Chem, the virtualization tool many of you   [2:24] container users run daily, started a secret  side project. He was building a key that could   [2:28] unlock every media format. Little did anyone know  this tool FFmpeg was quietly becoming the hidden   [2:34] backbone of the entire internet's video. The logo  represents a zigzag scan pattern that shows how   [2:39] meg codecs handle entropy encoding a lossless data  compression. And if me saying that brings up this   [2:44] memory, then we're in good company. Doubled it.  I'm Piper, ladies and gentlemen. Let's hear it   [2:50] for them. Okay, a nice trip down memory lane, but  how do you use it? FFmpeg is a group of libraries   [2:55] for developers, but we're here for the CLI. So,  let's start simple but essential. I have this cut   [3:01] from a previous video. I still remember the day,  the moment. Yeah, fancy. Most commands require an   [3:06] input introduced by hyphen i and then a file. When  a video involved, you'll often have vf for video   [3:13] filter followed by what you're looking for. We're  shortening this video to 10 frames per second. 320   [3:19] pixels is our width and minus1 tells ffmpeg to  calculate the height keeping the ratio intact.   [3:25] Lancos is a highquality algo for resizing  especially when downscaling. C colon V stands   [3:30] for codec for video which in our case is GIF.  Now you'll see the use of many algorithm names in   [3:35] different processes. Don't worry about remembering  all of them. We'll talk about that. Okay, it runs   [3:40] lots of output in the logs including useful  data. Let's just jump straight to what we made   [3:45] a beautiful GIF that's way way too small. Let's  fix that. Now while FFmpeg is hard to remember   [3:50] configuration of once you have that oneliner  changing is easy. Oh, and if you're not using vi   [3:56] mode in the terminal, that's exactly why you want  to start. 320, changes to 920, let it run again,   [4:03] uh, 1.8 megabytes of a nicely sized GIF, and job  done. Do you have any idea just how many times I   [4:10] looked for online gift creators where I can upload  a small video, wait, watch ads, run shady client   [4:16] code injected into my browser just to get this.  I'm too embarrassed to say. Since we now have a   [4:21] form of an image, let's talk about images. For  this trick, I'm going to use this thumbnail for   [4:25] a neim debugging video. A fairly large image of 3  megabytes. To shrink it, you can open a number of   [4:32] tools or online utilities, but ffmpeg can easily  handle images. I for input takes the file name.   [4:38] Then the video filter, which will hold one pair  of scale, and we'll fix that to 800 600. Lastly,   [4:44] the output file and wham, 54 kilobytes, which are  actually kabytes to be correct, but that's not the   [4:50] time for that. Let's see what we got. A lovely  distorted image. Mission accomplished. Well, you   [4:55] could use the trick from earlier. Just add minus  one to the tool to do the calculation. And there   [5:00] we have a nicely shrunk image. Perfect aspect  ratio of 51 kilobytes. Job's done. Perfectly   [5:05] compressed media is only half the battle for a  fast website. The other half is lightning fast   [5:10] delivery. That's where having a premium manage  host like today's sponsor, Kinsta, makes all the   [5:14] difference. As a business owner, your focus should  be on growth, not on whether your website is about   [5:19] to crash. If you're constantly worried about slow  speeds, security threats, or getting stuck with a   [5:24] support chatbot, it's time for a change. This  is Kinsta. They provide premium manage hosting   [5:29] for WordPress and are trusted by over 120,000  businesses. From small shops that need to handle   [5:34] sudden traffic spikes to giants like Screaming  Frog, G2 even ranked them number one out of the   [5:39] 350 providers. Here's why. First, speed. Just by  switching, your site could load up to 200% faster.   [5:46] One agency saw a mind-blowing 1,600% speed boost.  Then security. Kinsta offers an enterprise level   [5:52] firewall, DOS protection, and is so certified,  giving you total peace of mind. And my favorite   [5:57] part, when you need help, you talk to a real  WordPress expert in minutes, 24/7. No chat bots,   [6:03] just actual solutions. Tired of being your own IT  department? Switch to Kinsta. They'll migrate your   [6:08] entire site for free. Plus, you get your first  month on them in a 30-day money back guarantee,   [6:13] so there's literally zero risk. Visit the link in  the description or scan the QR code on the screen   [6:18] to claim your offer and let your hosting just  work. And now back to the video. There comes a   [6:23] time that you want to separate audio from video.  We used to call it audio ripping back in the happy   [6:28] 2000s when we wanted the MTV tracks music only.  Well, let's take the glamorous clip from earlier.   [6:34] This time with a VN flag, which the doc suggests  stands for video no or no video, meaning audio.   [6:42] Then a codec of MP3. This is actually old syntax,  but you'll see it a lot, right? So, output.mpp3 is   [6:48] ready to play. How about VC for the job? And there  we have the beautifully ripped MP3 audio track.   [6:54] I still remember the day, the moment. Okay, GIFs  and imageing is easy, right? Let's compress video,   [7:00] shall we? That's one of the main selling points  of FFmpeg after all. And I understand compression,   [7:05] which is another super fascinating technical uh  set of problems that I don't know. I just FFmpeg   [7:12] just fills me with joy. Same input, this time a  video codec by the name of Libx264, a well-known,   [7:18] widely used compression standard that's both  efficient and high quality. CRF here is a rate   [7:23] factor. Not a straightforward term, but basically  balances quality and file size. It goes from 0 to   [7:28] 63, where zero is higher quality and larger files,  and a higher index means the opposite. However,   [7:34] 23 is a common default with good balance, so you'd  normally see people and other software just use   [7:39] that. It takes about three whole seconds and the  video is out. A quick look shows 3.3 megabytes out   [7:45] of the previous 15.2. Is it any good though? Well,  not too bad if you ask me. Not bad at all. So,   [7:51] you're probably thinking, am I going to  have to remember all of these numbers   [7:55] just mentioned? Well, you don't have to. And if  you're really against scripting and automation,   [8:00] here's an open source exactly for that. Handbreak  offers much friendlier experience with its easy to   [8:05] use interface. It comes with readymade presets for  devices and platforms. you can quickly get great   [8:10] results without diving deep into technical flax.  It's perfect for everyday users who want simple,   [8:15] highquality video compression. Although, I must  point out that while Handbreak uses codecs like   [8:20] we've seen earlier, it does not use FFmpeg or its  libraries under the hood. Here's another extremely   [8:25] useful feature you probably didn't know about  FFmpeg. It's a device capture. What does that   [8:30] mean? It can capture your video cams, microphones,  both together, but also, and far, far more   [8:35] importantly, your screens. Yes, ffmpeg is a screen  capture utility. This is how you list devices   [8:42] for AV foundation format which is Mac specific.  Windows users would have the show there for the   [8:47] direct show media format while Linux users can use  one of the few like like V412 for video or also.   [8:55] So there's my list of both video and audio devices  from screens through my iPhone that's waiting on   [9:00] my desk to my DSLR cam or meeting webcam on top.  I can grab any of them and what they see or hear   [9:06] right from FFmpeg. Remember Zuckerberg was taping  both his Max Face Cam and his microphone. Well,   [9:12] look how easy it is to script something that  captures everything at once. I think he was   [9:16] worried for a good reason. Let's start with  the screen capture. 7 is my main screen. So,   [9:20] let's get it into the list of flags here, which by  now you probably know most of. So, let's just let   [9:25] things run. Time to move things on the screen  to see how smooth it comes out. I'll drag the   [9:29] finder around, stop recording with Ctrl + C, and  let it gracefully shut down. This is what came   [9:34] out. Here's the window moving around. Not too bad  for a 22 megabytes file. One thing that is missing   [9:39] here is the cursor. Want it in. There's a flag for  that. Capture cursor. Run again. This time with a   [9:45] dragged window while it's playing a GIF. Let's  see how it went. And there it is, even playing   [9:48] the GIF from the start. Now, here's the fun part.  Capturing live devices. Let's go with five listed   [9:54] as my iPhone camera, which is immediately turned  on and telling me the Mac has control. Let's pick   [9:59] it up and see whether FFmpeg actually gets input  from it. Open the video and what do you know?   [10:05] Hello, that's my screen. There's the camera and a  bunch of cables. Mind you, I did use 60 frames per   [10:10] second here like a crazy person, which explains  the shakiness of what you're seeing. Nevertheless,   [10:15] it works. This brings up malicious ideas  to mind, but let's leave this aside.   [10:20] about that shakiness. FFmpeg has a solution for  that as well. It's literally called a shakiness   [10:25] index and accuracy added to it. I didn't have a  lot of success with this specifically, but I'd be   [10:30] very keen to hear from others who did. Just before  automating things, FFmpeg can even burn watermarks   [10:36] on media for you. Don't believe it? Look at that.  Video filter with draw text and the text itself to   [10:42] add. This can also take a font color and size and  even a canvas coordinates. Let it run. It's done.   [10:47] And there you have it. burnt on the top left hand  side corner should you ever need that kind of mark   [10:52] burnt on media you publish. Okay, how about we  start automating? Even after sharing all these   [10:58] flags and covering what each means, there's no way  I'll remember it all in the second I need a GIF   [11:03] for shrinking an image. So, while there are many  ways to script commands, here's my choice. A twin,   [11:08] while serving as my command history manager,  has also a scripting system that's especially   [11:13] relevant here because it's easily tweaked. A twins  scripts new make gif will be the example I pick   [11:18] here to create gifs on the fly. If we ever need  changes beyond what's configured at twins scripts   [11:23] edit make gif will load it into the configured  editor for changes. I made an entire video on   [11:28] a twin scripts. I'll link it up here. But for now  let's create a gif automation. The oneliner takes   [11:32] its place here. But configured parameters will  live between double curly bracket pairs making   [11:37] them configurable interactively. I'll do that with  my input full file and then the output file name.   [11:43] Obviously, I can change the scale, FPS, etc. But  for now, this will do. At scripts, run make GIF,   [11:49] which I, by the way, mapped to ASR locally,  asks for values backwards, starting with the   [11:54] output file name, then the input file, which  I can't remember. So, T-Max to the rescue. And   [11:59] there it is. And there's our new GIF created  from automation. Now that you've wrapped your   [12:04] head around FFmpeg, you're ready to put things in  use. But like we mentioned, it can be quite a lot   [12:10] taking it all in the flags, the switches, and  then configs. I mentioned a twin scripts while   [12:15] presenting my choice for automating FFmpeg. But  you won't only getting the scripts. A twin is   [12:19] an entire history manager with data persistency,  fuzzy finding, and a powerful sync system that I   [12:25] can't work without. Check it in the video up here  and let me know in the comments what you think.   [12:30] Don't forget to check out Kinsta for a faster,  more secure WordPress hosting. Check out the QR   [12:35] on screen or the link in the description. Thank  you for watching and I'll see you on the next