Video encoding with ffmpeg on an Nvidia GPU using can be extremely fast compared to software based encoding on the CPU.

Example command: ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -extra_hw_frames 4 -i input.mp4 -c:a copy -c:v h264_nvenc -b:v 5M output3.mp4

This results in a transcoding speed of 14.7x!

On AWS instance type g4dn.xlarge ffmpeg fails unless the option -extra_hw_frames 4 is added.