使用AMD RX580通过FFmpeg硬件编码速度仅1.5x,如何提速?
Is 1.5x speed normal with AMD RX580 hardware encoding?
Yes, this is expected given your current command. The bottleneck isn't the AMF hardware encoder—it's your entire filter chain (scale, boxblur, overlay, crop), which runs exclusively on the CPU. The GPU encoder sits idle waiting for the CPU to finish processing each frame, so the speed gain over CPU-only encoding is minimal.
Should it be faster?
Absolutely. You can achieve much higher speeds (often 5x or more, depending on the workload) by offloading filtering tasks to the GPU and optimizing encoder settings.
Methods to improve encoding speed:
Offload filtering to the GPU
The biggest performance gain comes from moving CPU-heavy filters likeboxblurandscaleto the GPU. For AMD GPUs, use VA-API (Linux) or AMF-specific filters (Windows) to do this.
Example Linux command with VA-API acceleration:ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i 5.mp4 \ -lavfi "[0:v]scale_vaapi=w=1920:h=1080,boxblur_vaapi=luma_radius=min(h\,w)/8:luma_power=1:chroma_radius=min(cw\,ch)/8:chroma_power=1[bg];[0:v]scale_vaapi=h=1080:w=-1[ov];[bg][ov]overlay_vaapi=(W-w)/2:(H-h)/2" \ -c:v h264_amf output.mp4This runs all scaling, blurring, and overlay operations on the GPU, freeing the CPU to handle other tasks and feeding pre-processed frames directly to the AMF encoder.
Use AMF's built-in scaling
If you can't fully offload filtering, at least let the AMF encoder handle scaling instead of using the CPU-basedscalefilter. Remove thescalesteps from your lavfi chain and specify the output resolution with-s 1920x1080(for the background) or adjust the overlay's scale to use GPU acceleration where possible.Optimize AMF encoder presets
Adjust the encoder preset to prioritize speed over quality. Add-preset ultrafastor-preset fastto your command:ffmpeg -i 5.mp4 -c:v h264_amf -preset ultrafast -lavfi "[0:v]scale=1920:1080,boxblur=luma_radius=min(h\,w)/8:luma_power=1:chroma_radius=min(cw\,ch)/8:chroma_power=1[bg];[0:v]scale=-1:1080[ov];[bg][ov]overlay=(W-w)/2:(H-h)/2" output.mp4Faster presets reduce encoding latency, with only minor quality tradeoffs for most use cases.
Remove unnecessary filters
Your finalcrop=w=1920:h=1080is redundant—your background is already 1920x1080, and the overlay is centered within it. Removing this filter saves a small amount of CPU overhead.Validate FFmpeg build features
Ensure your FFmpeg build supports AMF and VA-API:- Run
ffmpeg -encoders | grep amfto confirmh264_amfis available. - Run
ffmpeg -filters | grep vaapito check for GPU-accelerated filters.
If these are missing, use an official AMD-provided FFmpeg build or compile from source with AMF/VA-API enabled.
- Run
内容的提问来源于stack exchange,提问作者Peter Czask

