dshow or gdigrab input filters alongside wasapi for audio, you can record high-quality video without third-party software. This approach provides a lightweight, scriptable solution for creating tutorials, gameplay footage, or system demonstrations directly from the command line.
Prerequisites and Installation
Before recording, ensure you have FFmpeg installed on your Windows 10 machine. If you do not have it yet, download the static build from the official FFmpeg website and extract the bin folder to a location in your system PATH, such as C:\ffmpeg\bin. You should verify the installation by opening Command Prompt or PowerShell and running ffmpeg -version. This command confirms that the executable is accessible globally.
You also need to identify your audio and video devices. Windows 10 uses DirectShow for many legacy inputs and WASAPI for modern digital audio streams. Open a terminal and run ffmpeg -list_devices true -f dshow -i dummy to list available video capture devices like your webcam or screen capture tools. For audio, use ffmpeg -f dshow -list_devices true -i dummy to see microphone and speaker names. Note the exact display names as they appear, including spaces and special characters, because these strings are critical for the input arguments.
Basic Screen Recording Command
The most straightforward method for capturing the desktop involves using the gdigrab input format. This filter captures the graphical output of the Windows Desktop Window Manager. Combine this with an audio input source to create a complete recording. A basic command structure looks like this:
ffmpeg -f gdigrab -framerate 30 -i desktop -f dshow -i audio="Your Audio Device Name" -c:v libx264 -preset ultrafast -crf 0 -c:a aac output.mp4
In this command, -f gdigrab specifies the graphics grabber input. The -framerate 30 flag sets the frame rate to 30 frames per second, which is standard for smooth motion. The -i desktop argument tells FFmpeg to capture the entire screen area. Replace "Your Audio Device Name" with the exact name found in your device listing step. For example, if your speakers are listed as Speakers (Realtek Audio), enclose that string in quotes within the -i parameter.
The encoding parameters at the end define how the data is stored. -c:v libx264 selects the H.264 video codec, which offers excellent compatibility and compression. -preset ultrafast minimizes CPU usage during recording, preventing stuttering in real-time capture. -crf 0 ensures lossless video quality, though this results in larger file sizes. For audio, -c:a aac encodes the sound into AAC format, which is widely supported across media players and web platforms.
Advanced Configuration: Region and Quality
Often, you may only want to record a specific portion of the screen rather than the entire display. You can achieve this by adding offset and resolution parameters to the gdigrab input. Use -video_size to define the width and height of the capture area, and -offset_x and -offset_y to specify the top-left corner coordinates.
ffmpeg -f gdigrab -framerate 30 -video_size 1920x1080 -offset_x 0 -offset_y 0 -i desktop -f dshow -i audio="Microphone" -c:v libx264 -preset fast -crf 23 -c:a aac region_recording.mp4
This setup captures a 1920x1080 area starting from the origin (0,0). Adjust the offsets to target different monitors or windows. Reducing the -crf value to 23 introduces slight compression, balancing file size and quality for general use. If you are experiencing performance issues, consider switching to -preset fast instead of ultrafast if your CPU can handle the load, or lower the framerate to 24 fps.
For higher fidelity audio, you might prefer using the wasapi input format instead of dshow. This captures the direct stream from your audio interface, bypassing potential mixer artifacts. The syntax changes slightly to -f wasapi -i audio=loopback for capturing system sounds. If you need to combine internal audio with microphone input, you will need to use the amix filter or separate tracks. See our guide on How to Use ffmpeg (No Transcoding) for Audio on Windows 10 for more details on handling raw audio streams effectively.
Troubleshooting Common Issues
Users often encounter black screens or missing audio when first attempting FFmpeg recording. A black screen usually indicates that the gdigrab filter cannot access the desktop window manager due to permission issues or incompatible drivers. Ensure you are running the terminal as an administrator. Additionally, some laptops with hybrid graphics may struggle; try forcing the application to use the dedicated GPU via Windows Graphics Settings.
If the audio is out of sync with the video, check your timestamp settings. Adding -fflags +genpts to the input can sometimes help regenerate timestamps for poorly formatted sources. Another common issue is the file size growing indefinitely. Always include a stop condition, such as pressing Ctrl+C in the terminal, to properly close the file header. Without this, the resulting MP4 file may be unplayable in standard players.
For persistent issues with desktop output files, particularly in virtual machines or remote sessions, refer to Fixing FFmpeg Desktop Output File Issue: Remote Windows VM Screen Recording. This resource addresses specific edge cases where screen capture fails due to restricted graphical interfaces.
Frequently Asked Questions
Can I record just one specific window instead of the whole screen?
FFmpeg's gdigrab does not natively support selecting individual windows by title. You must capture the entire screen and then crop the video using the crop video filter after recording, or use a tool like OBS Studio for live window selection.
Why is my recorded video very large even with CRF 0?
A CRF of 0 means lossless encoding, which preserves every pixel detail but generates massive files. To reduce size while maintaining good quality, increase the CRF to 18-23 or change the preset to medium or slow, which allows the encoder to compress more efficiently at the cost of longer processing time.
How do I record audio from my browser separately from my microphone?
You can use the wasapi loopback mode to capture system audio and a separate dshow input for your microphone. Map them to different audio channels in the output file using the -map option, allowing you to mix them later in post-production.
Does FFmpeg work on older versions of Windows like Windows 7?
Yes, FFmpeg supports Windows 7, 8, and 10. However, some newer audio features like WASAPI loopback may require updated drivers or specific builds. The dshow and gdigrab methods remain stable across all supported Windows versions.
What is the best format for streaming directly to YouTube?
While MP4 is great for storage, FLV or RTMP streams are traditionally used for live broadcasting. You can pipe FFmpeg output directly to YouTube using their RTMP endpoint with the -f flv rtmp://a.rtmp.youtube.com/live2/YOUR_KEY command, ensuring low latency.