Record Screen and System Audio with FFmpeg on Windows
Capturing both your screen and system audio simultaneously on Windows using FFmpeg requires configuring the correct input devices. This guide provides a straightforward, step-by-step walkthrough on how to identify your internal audio device and run the exact FFmpeg command needed to record high-quality screen video alongside desktop audio.
Step 1: Identify Your Audio Device Name
To record system audio, you must target the loopback device of your speakers or headphones. FFmpeg can discover these devices using the DirectShow framework.
Open Command Prompt or PowerShell and run the following command:
ffmpeg -list_devices true -f dshow -i dummyLook at the output under the DirectShow audio devices section. You need to find the loopback version of your active playback device. It will look something like this:
"Speakers (Realtek High Definition Audio) (loopback)""Stereo Mix (Realtek High Definition Audio)"
Copy the exact name inside the quotation marks.
Step 2: Run the FFmpeg Capture Command
Once you have your audio device name, use gdigrab to
capture the desktop screen and dshow to capture the system
audio.
Replace YOUR_LOOPBACK_DEVICE in the command below with
the exact name you copied in Step 1:
ffmpeg -f gdigrab -framerate 30 -i desktop -f dshow -i audio="YOUR_LOOPBACK_DEVICE" -c:v libx264 -pix_fmt yuv420p -c:a aac output.mp4Command Breakdown:
-f gdigrab: Specifies the GDI-based screen grabber for Windows.-framerate 30: Sets the video capture rate to 30 frames per second.-i desktop: Tells FFmpeg to capture the entire desktop.-f dshow -i audio="...": Specifies DirectShow as the audio grabber and inputs your specific system audio loopback device.-c:v libx264: Encodes the video using the H.264 codec.-pix_fmt yuv420p: Sets the pixel format to YUV 4:2:0, ensuring maximum compatibility with default media players.-c:a aac: Encodes the captured audio to the AAC format.output.mp4: The output file name.
Step 3: Stop the Recording
To stop recording, click on the Command Prompt window and press
Q or Ctrl + C. FFmpeg will safely
finish writing the file and save the output.mp4 file in
your current working directory.