Recording casparcg output via ffmpeg and NVIDIA GPU

Hi to all,

I currently record all my output directly to harddisk with a command like:
ADD 1-1 FILE “FILENAME” -vcodec libx264 -preset ultrafast -tune fastdecode

Works totally fine but I have a high CPU usage when video has a lot movement. Nearly 100% CPU usage (99-100%)

My System is a HP Z420 with NVIDIA Quadro K2000 and CasparCG 2.2.

When I use sth like:
ADD 1-1 FILE “FILENAME” -vcodec libx264 -preset ultrafast -tune fastdecode -format mpegts then the same recording will end only in a total cpu usage of only 35-40%

When I check for GPU monitor (NVIDIA monitor), in both cases the GPU is about 50% used and it doesn’t matter if I record or not. Could it be that the GPU is not used at all for ffmpeg?

Does anyone have an idea which command to use to record with GPU usage instead CPU usage in ffmepg?

FFmpeg in CCG doesn’t use cuvid, nvenc or nvdec (and probably isn’t built with support for it anyways).

Ah ok… any chance that this will be changed in the future so that also gpu is used ?

I just checked and the ffmpeg that Caspar 2.2 uses does have nvenc support enabled. I was not expecting that to be the case

But in your command you are using the libx264 codec which is a cpu h264 encoder. Try using h264_nvenc instead (you might also need -profile high444p -pixel_format yuv444p -preset default) for it to work
https://trac.ffmpeg.org/wiki/HWAccelIntro

3 Likes

Does this still hold true?
Is there no way to use a GPU accelerated recorder in caspar?

As @Julusian already stated above, the following code in server 2.3 working ok.

ADD 1-1 FILE test115.mp4 -codec:v h264_nvenc -profile:v high444p -pixel_format:v yuv444p -preset:v default

We can see in task manager that gpu is being used for video encoding.

1 Like

Thanks!

Found this FFmpeg Consumer · CasparCG/help Wiki · GitHub has the following note:

Note: Caspar will only take arguments in the -[parameter]:[stream] syntax. Use -codec:v, not -vcodec. Arguments not passed on by caspar to FFmpeg will yield an “Unused option” log message.

argument format is a thing with caspar’s ffmpeg consumer. can’t use the alias.

@vimlesh1975 I’m having troubles with GPU encode on the latest nightly of 2.3. P2000 GPU on Driver R440 U6 (442.50).

ADD 1-1 FILE test115.mp4 -codec:v h264_nvenc -profile:v high444p -pixel_format:v yuv444p -preset:v default

CPU is consuming an additional 20% when recording and GPU doesn’t change. Am I missing a setup step somewhere?

Thanks

When I tested it I relied on “Video Encode” caption on GPU in task manager. But actually GPU uses doesn’t increase significantly.
I today tested 03-03-2020 build which uses ff-mpeg version 4.2.2. But it also doesn’t show GPU use.
While same command when used in ffmpeg command line GPU use goes up significantly.

That’s the same behaviour I’m seeing. It would appear the GPU flag is being ignored or is completely ineffective in these versions.