Compressing 4 Videos Concurrently in Real-time using FFmpeg

Hello,

I’m currently trying to compress 4 video files concurrently using FFmpeg, but my issue is that I’m not able to compress them fast enough to be done in real-time, i.e. 4 30-second videos compressed in 30 seconds.

I’m using an NVIDIA RTX A2000 Embedded GPU, and the input files are 4k 30fps YUV422 12-bit and 30 seconds each, so each file is about 29GB, and the codec I’m using is HEVC NVENC.

Here is the command I’m using:

ffmpeg -y `
-hwaccel cuda -hwaccel_output_format cuda -f rawvideo -s:v 3840x2160 -pix_fmt yuv422p12be -framerate 30 -i "I:\ffmpeg\12-bit\yuvs\input0.yuv" `
-hwaccel cuda -hwaccel_output_format cuda -f rawvideo -s:v 3840x2160 -pix_fmt yuv422p12be -framerate 30 -i "I:\ffmpeg\12-bit\yuvs\input1.yuv" `
-hwaccel cuda -hwaccel_output_format cuda -f rawvideo -s:v 3840x2160 -pix_fmt yuv422p12be -framerate 30 -i "I:\ffmpeg\12-bit\yuvs\input2.yuv" `
-hwaccel cuda -hwaccel_output_format cuda -f rawvideo -s:v 3840x2160 -pix_fmt yuv422p12be -framerate 30 -i "I:\ffmpeg\12-bit\yuvs\input3.yuv" `
-map 0:0 -c:v hevc_nvenc -b:v 25M -r 30 "D:\ffmpeg\videos\output0.mp4" `
-map 1:0 -c:v hevc_nvenc -b:v 25M -r 30 "D:\ffmpeg\videos\output1.mp4" `
-map 2:0 -c:v hevc_nvenc -b:v 25M -r 30 "D:\ffmpeg\videos\output2.mp4" `
-map 3:0 -c:v hevc_nvenc -b:v 25M -r 30 "D:\ffmpeg\videos\output3.mp4"

This command took more than 60 seconds to finish, so I need to somehow cut the processing time by more than half if I want it to be done in real-time.

I’ve seen from NVIDIA’s website (Video Codec SDK | NVIDIA Developer) that HEVC NVENC supports YUV420 and YUV444, so does that mean FFmpeg is converting the pixel format from YUV422 to one of those before the GPU is then processing the video? If so, is there a way to accelerate this with the GPU?

The YUV files are stored on a RAID array that has a read speed of more than 6GB/s, so I don’t think the disk is the bottleneck.

Here are also screenshots of the Task Manager after FFmpeg finishes:


The end goal is to encode 8 streams concurrently in real-time, but seeing as I’m not even able to do 4 videos, does anyone have any suggestions? Thanks in advance!