NVIDIA / VideoProcessingFramework

Set of Python bindings to C++ libraries which provides full HW acceleration for video decoding, encoding and GPU-accelerated color space and pixel format conversions
Apache License 2.0
1.31k stars 234 forks source link

How to save 1 channel (black and white) videos? #335

Closed sotelo closed 2 years ago

sotelo commented 2 years ago

Hi @rarzumanyan!

First of all, let me thank you for the work that you've put into this library! It's very useful and we've been able to speed up our code significantly thanks to it.

On our current use case, we are processing videos and using a PyTorch model to extract a mask for them. The mask is a 1 float between 0 and 1 and has the same size as the resolution of the original video in terms of height and width. Then, the question is: What would be the recommended way to save the mask as a video file? (Ideally, we'd like to be able to visualize the mask as a black and white video in VLC)

A dummy solution to this problem would be to repeat the 3 channels and then save it as a usual BGR video. Is there a more efficient way to do this?

Thank you for your help and happy to provide more details. José

rarzumanyan commented 2 years ago

Hi @sotelo

A dummy solution to this problem would be to repeat the 3 channels and then save it as a usual BGR video.

So far that's the only way ;) If that's possible I'd recommend you to work this around in pytorch. Since I'm not a pytorch guru I can only suggest smth like this:

Looks like a long way, but at least everything will be done on GPU and it does these memcopy operations really fast.

P. S. Proper solution would be:

It's feasible to implement, but not done yet in VPF.

rarzumanyan commented 2 years ago

@sotelo

I've added rgb>y and y>yuv444 cconv support in y_yuv444_cconv feature branch, please check it out.

sotelo commented 2 years ago

Thanks for the quick answer! I will check the new branch out!

rarzumanyan commented 2 years ago

Feature branch was merged to master, closing this issue as resolved.