Spawning multiple ffmpeg processes with xargs:
On standard NVIDIA GPUs (Not the Quadros and Tesla lines), NVENC encodes are limited to two simultaneous sessions. The sample below illustrates how to pass a list of AVI files to ffmpeg and encode them to HEVC on two encode sessions:
$ find Videos/ -type f -name \*.avi -print | sed 's/.avi$//' |\
xargs -n 1 -I@ -P 2 ffmpeg -i "@.avi" -c:a aac -c:v hevc_nvenc "@.mp4"
This will find all files with the ending .avi
in the directory Videos/
and transcode them into HEVC/H265+AAC files with the ending .mp4. The noteworthy part here is the -P 2
to xargs, which starts up to two processes in parallel.