# Status and usage of cudacodec::VideoWriter

**URL:** <https://forum.opencv.org/t/status-and-usage-of-cudacodec-videowriter/17396>\
**Category:** Python\
**Tags:** ffmpeg, cuda, videoio, cudacodec\
**Created:** [April 24, 2024, 9:54am UTC](https://forum.opencv.org/t/status-and-usage-of-cudacodec-videowriter/17396 "2024-04-24T09:54:15Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![tvercaut](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/tvercaut/32/10255_2.png) [@tvercaut](https://forum.opencv.org/u/tvercaut)\
**Post date:** [April 28, 2024, 9:34pm UTC](https://forum.opencv.org/t/status-and-usage-of-cudacodec-videowriter/17396/21 "2024-04-28T21:34:36Z")

</div>

> [@cudawarped](#):
>
> I am still not sure if outputing that format from the video reader is realvent to OpenCV as no routines (that I know of) can process it. What is your use case in OpenCV? I assumed you were processing footage from a sensor and wanted to archive the footage in a higher precision not that you needed to read it back into OpenCV?

Indeed, I want to store and work with data from a 10bit machine vision camera (monochrome). The 10 bit data will most likely be represented as 16 bit for all processing purposes (although some downgrading to 8 bit may happen at some point, say for display. The processing pipeline can be developped in OpenCV but could also be in PyTorch or else (as this is for academic research purposes).

Enabling both recording and reading of 10 bit data in OpenCV would allow us to pre-record some videos and work on them offline with the same characteristics as if coming from the camera. It also helps with testing that writting works.

For the specific case of `NV_ENC_BUFFER_FORMAT_YUV420_10BIT` for monochrome data, this would work rather seamlesslessy with opencv since we would get the Y plane already in 16 bit (most significant 10 bits being written to) and can simply discard the U and V planes (unused for monochrome) by cropping the images. Thus all OpenCV routines already supporting 16 bit grayscale data would be usable.

If YUV is actually used for colour as well, converting the YUV420 frame (single “packed” 16 bit channel) to a “full” 3 channel 16bit YUV or RGB matrix can be done easily with a few opencv routines (e.g. `cv2.resize`, `cv2.cuda.merge`, etc.).

It may look more inuitive to work with a grayscale colour format rather than yuv420 for grayscale image capture. However, 10 bit grayscale hevc is not widely supported (I don’t think nvenc does it for example) and there are little downsides in just having zero filled U and V (semi) planes.

---

_[View the full topic](https://forum.opencv.org/t/status-and-usage-of-cudacodec-videowriter/17396)._
