server icon indicating copy to clipboard operation
server copied to clipboard

feat: custom channel resolutions & subregion copy

Open Julusian opened this issue 1 year ago • 15 comments

Support for defining channel resolutions in the config file.

And running a decklink on a channel at a different resolution to the channel, outputting a subregion. The only requirement is that the framerate of the decklink and channel must match. No scaling/rotation support, for that use a dedicated channel and route.

Use cases include:

  • LED video wall which runs at some odd resolution (eg 1000x100).
  • TV video wall (eg 3x1080p panels in a row)
  • Projector blend

In all of these cases, it allows you to run the channel at the resolution of the final product, and avoids needing to transform every layer to match the usable region, and still send it to decklink outputs without the overhead of extra channels.

Testing build: https://builds.julusian.dev/casparcg/casparcg-server-v2.3.x-4123675b-20220913-subregion.zip

Julusian avatar Jul 12 '22 17:07 Julusian

Interesting what is your plan in controlling this. Will this be configured in de config / how ? is it already testable with say a 2160P channel ?

MauriceVeraart avatar Jul 13 '22 07:07 MauriceVeraart

Will this be configured in de config / how ?

Config file changes are in the PR: https://github.com/CasparCG/server/blob/235eecf15ca8554710fe018d3a2f4d7d39460db4/src/shell/casparcg.config#L75

mint-dewit avatar Jul 13 '22 08:07 mint-dewit

Interesting what is your plan in controlling this. Will this be configured in de config / how ?

As Balte has linked to, this is configurable in the config file. There is no reason it couldn't be done in ADD 1 DECKLINK ...., but I dont expect to implement that for now.

is it already testable with say a 2160P channel ?

So far I have only tested it with 1080p5000 and 720p5000 channels and consumers, but as long as the framerate matches, it should work with any formats as long as the framerate matches (50i and 50p are be the same in this context). We intend to use this with channels running at custom resolutions

Julusian avatar Jul 13 '22 09:07 Julusian

This looks great.

So if I understand correctly, Decklink outputs are still bound to broadcast supported formats but when making a custom video mode (let's say 2500×1500px) now you can split this channel into several 1920×1080 SDI outputs? (let's assume we don't have a 4k card I guess).

Or is it now possible to output custom resolutions pixel by pixel (500×500px) through decklink?

Thanks!

Sidonai-1 avatar Jul 13 '22 10:07 Sidonai-1

i tried it with the build #16ee0e3d available on builds.casparcg.com and it does not work on my side just 1080P out with the normal channel content

or i am doing it wrong <= most likely ;) or it's the buildserver. the changes in casparcg.config Balte referenced are not there either

see log

caspar_2022-07-13.log

MauriceVeraart avatar Jul 13 '22 11:07 MauriceVeraart

So if I understand correctly, Decklink outputs are still bound to broadcast supported formats but when making a custom video mode (let's say 2500×1500px) now you can split this channel into several 1920×1080 SDI outputs? (let's assume we don't have a 4k card I guess).

Yes exactly this. We are still limited by the formats that the decklinks/sdi support. That split is exactly what we are looking at doing. It was completely possible before by using a channel to composite, and a channel to scale/crop for each decklink, but this is very wasteful.

It handles the decklink being smaller or bigger than the channel, so you could even do things like using a 1080p sdi to a video wall processor, but as you only need 100 pixels of height, you could run the channel in 1920x100 to save the gpu work, and the need to transform everything

Julusian avatar Jul 13 '22 12:07 Julusian

i tried it with the build #16ee0e3d available on builds.casparcg.com

That commit is from master, not this pr. No idea what the buildserver is doing, but it does not appear to be building prs

Julusian avatar Jul 13 '22 12:07 Julusian

You can try this build: https://builds.julusian.dev/casparcg/casparcg-server-v2.3.x-custom-resolutions.zip

This PR includes custom channel resolutions now too. I was intending to keep them separate, but they ended up being more interlinked than I was hoping

Julusian avatar Jul 14 '22 15:07 Julusian

Ow that's just really nice to have the custom-res like this too. Will test this out in more depth later. Thanks for this

MauriceVeraart avatar Jul 15 '22 08:07 MauriceVeraart

I guess this is a limitation not a bug but resolutions wider then 8192 will give a memory leak on the GPU on my side.

It's a distinct point where it fails. 8192*2160 runs fine go 2 pixels higher and the gpu memory will climb to 100% in say 4seconds . i bed this has something to do with max shader resulution i see this behaviour in other programs too.

something to keep in mind when using this.

MauriceVeraart avatar Jul 18 '22 07:07 MauriceVeraart

What gpu do you have? I am hoping that threshold is the max texture size it supports, which should make it easy to detect and refuse to run instead

Julusian avatar Jul 18 '22 08:07 Julusian

quadro RTX 6000

MauriceVeraart avatar Jul 18 '22 08:07 MauriceVeraart

Hmm.. That card has a GL_MAX_TEXTURE_SIZE of 32768, so those dimensions should fit fine. And GL_MAX_TEXTURE_BUFFER_SIZE is 134217728 which does have some headroom, but not masses. I dont see any other reported number that looks to be in the region of being a limit here https://opengl.gpuinfo.org/displayreport.php?id=3826

Perhaps its a power of 2 thing? 8192x4096x4 is 134217728, so even though textures dont have to be a power of 2, perhaps it is doing so inside the driver. Does it work with increasing the height up to 4096? or if you drop the height to 2048 can it be made twice as wide?

I am wondering if the leaking is some bad handling in caspar, of us making some assumptions of operations that can never fail, resulting in leaking of buffers or something. Not sure if its worth looking into properly.

Julusian avatar Jul 18 '22 10:07 Julusian

i can go to 8192x8192 (with bad performance in the end but not the same fault.) strange thing is that 12288 (multiple of 2048) does work again i guess it must be dividable by 2048 or maybe devidable by some other power of 2

MauriceVeraart avatar Jul 18 '22 11:07 MauriceVeraart

You can try this build: https://builds.julusian.dev/casparcg/casparcg-server-v2.3.x-custom-resolutions.zip

I'm going to test this build a bit, is it a 2.3.3 stable with just this new feature or does it include some of the latest fixes that have been happening? (up-down transitions comes to mind, for example)

Thanks

Sidonai-1 avatar Jul 19 '22 15:07 Sidonai-1

currently i am able to set video mode for Decklink consumer in the config file. how do i set video mode on the command line ADD 1-100 DECKLINK 1 embedded_audio low_latency 720p5000_video_mode ADD 1-100 DECKLINK 1 embedded_audio low_latency video_mode 720p5000 none of the above commands sets the video mode.

PeterAkakpo avatar Dec 22 '22 13:12 PeterAkakpo

Nothing has been added to AMCP for this, as that was not necessary for the use case I had.

Julusian avatar Dec 22 '22 14:12 Julusian

thanks for the response. but i think once it is configurable in the config file, it should be available for ACMP too. this will enable setting different video mode on the fly. my usse case is to add and remove decklink outputs on the fly with a click of a button

PeterAkakpo avatar Dec 22 '22 14:12 PeterAkakpo

I was trying to use this feature with a 4k video and divided by 4 decklink's (Decklink duo 2, 4 outputs) to perform the 4k. All with low latency, but one or 2 decklink's get out of sync for small frames. This will be nice to do this 4k 3G. If I check task manager node of CPU and GPU are in 100%. Is there a way that we can try to sync them manualy?

Spo-oky avatar Feb 19 '23 19:02 Spo-oky

I was trying to use this feature with a 4k video and divided by 4 decklink's (Decklink duo 2, 4 outputs) to perform the 4k. All with low latency, but one or 2 decklink's get out of sync for small frames. This will be nice to do this 4k 3G. If I check task manager node of CPU and GPU are in 100%. Is there a way that we can try to sync them manualy?

I'm in a similar situation.

In my case I'm using a 8KPro to output four 4K signals. I set the buffer to 1, as I've been told that higher buffers mean opening the door to higher delays. CPU and GPU usage is around 50%, so no dropped or late frames. The diag window looks smooth. I tried "low latency" on the decklinks but couldn't see much of a difference so I stopped using it.

However, there is between 1 and 3 frames of delay between certain signals. It changes which one is it every time you restart Caspar. Sometimes I'm lucky and there is only 1 frame of delay in 1 signal. I couldn't pinpoint the cause of this, it seems a bit random.

I guess setting the buffer to 0 is not an option, right? 🤣

Thanks!!

Sidonai-1 avatar Feb 19 '23 20:02 Sidonai-1

This is interesting to hear. In my testing I never managed to get it to go out of sync, but you are not the first case where it has had issues. It sounds like this is a bit broken currently then.

@Sidonai-1 The buffer depth is how many frames we aim to have buffered in the decklink driver. The lower it is the lower the output latency, but also the more likely that the decklink will have to repeat a frame as we didnt provide more in time.

Julusian avatar Feb 20 '23 10:02 Julusian

In my testing I never managed to get it to go out of sync

I tested a panoramic video mode at 30fps, and most of the time it looked just fine. It was only when the content was moving faster that it showed tearing effects. If you sew up two signals side by side it is specially noticeable with clear solids on darker background moving quickly upwards or downwards.

Sidonai-1 avatar Feb 24 '23 13:02 Sidonai-1