A workaround to improve CasparCG performance / and using GPU decoding

Hi, guys, sorry for my poor English.

I’ve been digging CCG performance for a very lone time because my needs are kind of special (very very intensive, just not able to do it with CCG on a 128 core computer :frowning: )

CCG is a very useful software, so I don’t wanna give up it.
I’ve read all forum topics that related to performance,
From what I learned, CCG has two factors that cause performance issue
1 some limitation of CPU usage (like threads)
2 no GPU decoding

for factor 1, you may find that you are not able to play a video smoothly by CCG (4K samples from internet)
there is an solution for it
4K video replay should be fine
but still, if I push more, like “VF” filter, it will by laggy while CPU usage still very low
I tried to play it with FFMPEG, it will cost much more CPU but played well
which means there is still some kind of limitation inside CCG that prevent me to use enough CPU, I can’t find what that is, tried a lot edition in the code, not working

and later today, I figured a workaroud which can also fix factor 2
simplely process:
convert video source to ndi source–>add ndi souce in CCG

since I don’t have ffmepg with ndi build, I tried using ndi tools
play video source as full screen oin screen 2–>use ndi tools to convert screen 2 into ndi source–>add ndi source in CCG

this is playing a 4K video directly inside CCG, 31% CPU usage

this is playing a 4K video on screen, convert into ndi, play ndi source in CCG, 19+1+0.5 CPU usage

so, saved 10%

and if you play video on two layers, you will be saving 30%…even wihtout GPU decoding, you still save 20% usage

besides save CPU usage, the key point is that you now can actully use any FFMPEG capable source/parameters with CCG. some are not supported in CCG currently(like GPU decoding), and more producer

and a little note: you don’t actully need a real screen for that, just have GPU output ports(like hdmi), you can buy a little cheater hdmi thing that cheat your GPU you’ve connected it to a monitor, its about $2 each.

hopefully, this could help ppl with simlar problem using CCG :smile:

I think I’ve said this before in another thread, but Screen Consumer performance is quite poor compared to using an NDI Consumer and using NDI Studio Monitor in a second monitor, which can be of more use in plenty of scenarios compared to Screen Consumer.

Now, the only concern regarding NDI integration in CasparCG might have something to do with licenses and whatnot, which I have no idea how can that turn out. As far as I know, FFMPEG withdrew NDI native support because of licensing issues with NewTek.

Anyway, I am no core developer, but I think performance gains are always welcome.

FFmpeg had an issue with the library NewTek provided to make use of NDI inside FFmpeg as it was propietary and they refused to open it.
I think CasparCG is not using any non-free library to make it work. It relies on the NDI runtime which is not distributed within Caspar, you need to install it separately.

From my reading and research into gpl compliance, I am confident that there are no issues with casparcg there. The key thing is that there are no closed source binaries that are required for any core functionality. There are closed source binaries needed to enable various i/o features, but they are all optional and require the user to separately install them. This is true not just for ndi, but decklink, bluefish and flash too.

The story with ffmpeg is that newtek were distributing copies of ffmpeg with ndi supported compiled in. These builds were done in a way that meant that the ndi library was a core component (it could not run without it), and so was in violation of the gpl license.
ffmpeg responded by requiring newtek to stop distributing this (which they did) and by dropping ndi support from ffmpeg.

1 Like

NDI Consumer + NDI Studio, sounds like a interesting trick for monitor.
But my problem is actually that I need to do some heavy work using ffmpeg, for example replay 4K video, apply filters etc. If I do this inside CCG, it might just not able to work (because CPU usage limiation inside CCG somehow, cpu is low, but frames are skipping), even I turn off all screen comsumer, the problem is still there. and these work are done without problem if I use FFmpeg instead of CCG, that why I comfirmed that its somehow a limitation inside CCG. Then I figured that I can do these work outside CCG, and then transform it into CCG by NDI, which works pretty good

I actully wanna bypass NDI, the reason is what you just mentioned
my method tried is that use pipe/udp/tcp/rtsp to transform uncompressed video(no encode CPU usage) from outside-CCG FFMpeg into inside-CCG FFMpeg, but this failed, because CCG has no support for pipe/udp/tcp links, and rtsp do not support uncompresed video type in FFMpeg… so sad

then I have to stick around NDI for now,
I’ve found an 3.5 ver FFmpeg with NDI build, now what I do is like this

ffmpeg -rtsp_transport tcp -i rtsp:// -vf scale=1920:1080:flags=fast_bilinear,lut3d=tttt.cube -f libndi_newtek -pix_fmt uyvy422 NdiTest
this is really a heavy work, cost more than 50% cpu usage of one i7 7820x, and cost 30% if use CCG instead but skipping frames

and then go CCG to add an NDI input

I guess this will be my final solution, if some ppl wants this version of FFMpeg, just google FFMPEGUI, that’s it

ye, I’ve searched and watched almost every link related to ndi and ffmpeg to fix my problem
and it is really sad that FFmpeg stopped supporting NDI,
since it’s a really good solution for me, I even can handle my videos in a distributed way (ffmpeg to filter videos on different computer, and then output ndi into main stream CCG computer)
at least I think FFMpeg 3.5 will be good enough for years, I wish CCG one day could support RTP/TCP/UDP streams as comsumers so that I will be able to use FFMpeg alone to do so

I just found that CCG support HTTP by FFMpeg
and I tested HTTP outside CCG, comformed that http support rawvideo (without encode compression)

but I failed to use HTTP inside CCG, got an error, could someone help me for this?

this is from client FFMpeg

ffmpeg -re -i 4k10m.mp4 -vcodec rawvideo -an -f avi

this is from server CCG

play 1-1

after client pushing data, I then get this error

I found that this error occur no matter the client is pushing or not…
just run the command in CCG, and wait for a while, it will happen
so what is the right way to use HTTP inside CCG, anyone knows? Thanks

I feel like these two http are different
seems CCG’s http works as client, but ffmpeg http works as that the source is a client to push data…I am a little bit comfused now
does that means I need a http server for CCG and FFmpeg outside to work together?

OK, I figured, FFMpeg http could run as client as well as server
just put -listen 1 parameter, it will be a server
to do this, just set it in the CCG source code…

I am wondering if CCG could ever possible to use FFMpeg.exe instead of the its lib, so CCG don’t have to implement all protocs, just let users to use FFMpeg command?
I know its maybe sounds like a stupid question, just a noob wondering…