macOS下FFmpeg录屏出现色彩褪色问题求助
Hey there, let's get to the bottom of that faded color issue you're seeing with your screen recordings. I've run into similar quirks with AvFoundation on macOS before, so here are targeted fixes to try out:
First, Fix Conflicting Encoding Parameters
I noticed you're using both -qp 0 and -crf 22 in your command—these two parameters can't work together with libx264. When you set a CRF value, FFmpeg ignores the QP setting entirely, so your earlier adjustments to QP weren't actually affecting the output. Stick with either CRF (for variable bitrate, better for screen recording) or QP (constant bitrate), but not both. Let's focus on CRF since it's more efficient for this use case.
Try These Actionable Fixes
1. Force the Input Pixel Format
AvFoundation sometimes captures screen data in a pixel format that doesn't match your display's color space, leading to washed-out results. Explicitly set the input pixel format to bgr0 (a common format for macOS displays) before encoding:
ffmpeg -f avfoundation -video_size 1980x1140 -framerate 30 -capture_cursor 1 -capture_mouse_clicks 1 -pix_fmt bgr0 -i '1' -preset ultrafast -an -crf 22 -pix_fmt yuv420p -y -c:v libx264 video_test.mkv
2. Add Explicit Color Space Metadata
Often the problem isn't the encoding itself, but media players misinterpreting the video's color space. macOS screens typically use sRGB, which aligns with the BT.709 standard. Add these flags to tell players exactly how to render the colors:
ffmpeg -f avfoundation -video_size 1980x1140 -framerate 30 -capture_cursor 1 -capture_mouse_clicks 1 -i '1' -preset ultrafast -an -crf 22 -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -y -c:v libx264 video_test.mkv
3. Verify Your Capture Device Index
Double-check that you're recording the correct display. Run this command to list all available AvFoundation devices:
ffmpeg -f avfoundation -list_devices true -i ""
Look for your main display (e.g., "Built-in Display") and make sure its index matches the -i '1' in your command. If you have multiple displays, picking the wrong one could cause color inconsistencies.
4. Fine-Tune Color Balance with Filters (Last Resort)
If the above fixes don't resolve the issue, you can adjust saturation and gamma directly with a filter. Start with small tweaks to avoid over-saturating:
ffmpeg -f avfoundation -video_size 1980x1140 -framerate 30 -capture_cursor 1 -capture_mouse_clicks 1 -i '1' -preset ultrafast -an -crf 22 -pix_fmt yuv420p -vf eq=saturation=1.2:gamma=1.1 -y -c:v libx264 video_test.mkv
Adjust the saturation (1.1–1.3) and gamma (1.0–1.2) values until the colors match your screen.
内容的提问来源于stack exchange,提问作者Gabrielle

