Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th March 2025, 11:16   #1  |  Link
efschu
Registered User
 
Join Date: Mar 2024
Posts: 7
RGB to YUV using GPU not CPU

Hi,

I'm using the following script:
Code:
core.num_threads = 32

clip = video_in

stream0 = core.std.SelectEvery(core.trt.Model(core.resize.Bicubic(clip, width=1280, height=720, format=vs.RGBS, matrix_in_s='709'), engine_path="/root/Downloads/realesr-general-wdn-x4v3_opset16_V100_574_720.engine", num_streams=3, device_id=0), cycle=2, offsets=0)
stream1 = core.std.SelectEvery(core.trt.Model(core.resize.Bicubic(clip, width=1280, height=720, format=vs.RGBS, matrix_in_s='709'), engine_path="/root/Downloads/realesr-general-wdn-x4v3_opset16_V100_574_720.engine", num_streams=3, device_id=1), cycle=2, offsets=1)

clip = core.std.Interleave([stream0, stream1])

clip.set_output()
which gives me 27 fps using vspipe.

now i want to use this in realtime with MPV, so I must convert the clip to YUV at the end. but this takes to much CPU power, and the fps are dropping to 23fps, which makes it not usable in realtime.

Code:
clip = core.resize.Bicubic(clip, format=vs.YUV420P8, matrix_s='709')
is it possible to convert format on the GPU rather the CPU - or is it possible to use RGB output with MPV?

thnx in advance
efschu is offline   Reply With Quote
Old 8th March 2025, 16:08   #2  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
mpv can take RGBS output just fine

edit: huh, so the problem is that the vapoursynth filtering in mpv doesn't support RGB output? I think you can use vs-placebo to do the conversion on GPU, but I don't think it can make such a difference... the data needs to be transfered between VRAM and RAM yet again, and in the meantime your GPU is busy doing upscale.

Last edited by Z2697; 8th March 2025 at 16:19.
Z2697 is offline   Reply With Quote
Old 11th March 2025, 09:47   #3  |  Link
efschu
Registered User
 
Join Date: Mar 2024
Posts: 7
I have a third GPU idling meanwhile, while CPU is nearly 100% load, so I would like to outsource the scaling and colorspace conversion. I have looked @vs-placebo, but havent found out til now how i can use it for yuv to rgbs, rgbs to yuv conversion. Have to have a deeper look.

Thnx for the suggestion.
efschu is offline   Reply With Quote
Old 11th March 2025, 13:35   #4  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
Quote:
Originally Posted by efschu View Post
I have a third GPU idling meanwhile, while CPU is nearly 100% load, so I would like to outsource the scaling and colorspace conversion. I have looked @vs-placebo, but havent found out til now how i can use it for yuv to rgbs, rgbs to yuv conversion. Have to have a deeper look.

Thnx for the suggestion.
I'd assume CPU is idling for the given script, what is eating your CPU resource?

Apparently vs-placebo didn't provide a easy way of doing matrix conversion, sorry.

Last edited by Z2697; 11th March 2025 at 13:45.
Z2697 is offline   Reply With Quote
Old 11th March 2025, 15:10   #5  |  Link
efschu
Registered User
 
Join Date: Mar 2024
Posts: 7
top command shows me vspipe is consuming 16 cores while running, and if I do not do a colorspace conversion from RGB to YUV at the end the speed of script is fine, but if i do the conversion (which is done on the CPU) the speed drops below realtime (which makes it useless for my usecase)
efschu is offline   Reply With Quote
Old 12th March 2025, 08:43   #6  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
That's sounds weird. I can't imagine a 5K color matrix conversion @23FPS hitting a 16-core CPU that hard. What is your CPU?
I mean, it does consumes quite a lot CPU resource, but 100% is just too unreal (it was 100% even without this final converion?)

Last edited by Z2697; 12th March 2025 at 08:58.
Z2697 is offline   Reply With Quote
Old 12th March 2025, 08:58   #7  |  Link
efschu
Registered User
 
Join Date: Mar 2024
Posts: 7
The load is nearly at 100% befor the rgb2yuv conversion. So there is no power left. Forsure if the CPU is idling, it's no problem to do the matrix conversion. Its an AMD Ryzen 5950X with 3800MHz RAM.
efschu is offline   Reply With Quote
Old 12th March 2025, 09:06   #8  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
I just have a hard time to understand why the CPU load was 100% already...
You can try to use FP16 (vs.RGBH), your CPU has F16C instruction, that can reduce some cost on memory bandwidth at least, but you need to re-build the TRT engine.
Z2697 is offline   Reply With Quote
Old 13th March 2025, 10:32   #9  |  Link
efschu
Registered User
 
Join Date: Mar 2024
Posts: 7
Wow. Creating the engine with

Code:
--inputIOFormats=fp16:chw --outputIOFormats=fp16:chw
and using RGBH, increased performance by 38%.

Thank you so much.
efschu is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:45.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.