Lossless H264 encoding with the cuda encoder

I started using the CUDA encoder library and had some success with it. However the documentation is quite sketchy. So I’m wondering how I would facilitate lossless encoding with it. Usually in H264 this is done by qp=0 but apparently the cuda encoder works differently. Any ideas on how to set the parameters to get lossless quality?

As a sidenote, from the SDK example it seems like decoding is somewhat more difficult than encoding. Does anyone have experience with writing a decoder?

The decoder isn’t too bad; it’s just that the SDK example has a lot of wrapper classes. In the most basic sense, cuda decoding consists of:

  • cuvidCreateVideoSource(…)

  • cuvidCreateParser(…)

  • cuvidCreateDecoder(…)

  • (get the video frames w/ the cuvid source+parser, or your own)

  • cuvidDecodePicture

  • cuvidMapVideoFrame

  • do some processing in cuda

  • cuvidUnmapVideoFrame

  • cuvidDestroyDecoder(…)

(This was adapted from the cuvid api’s cuviddec.h file)

If you’re on windows, it’ll be a bit easier on you, as you can use the built in cuvid parser, whereas if on linux/mac you’ll have to write your own.

Thanks, I’ll give the decoder a try soon. I really hope NVIDIA extends their documentation there a bit in the future.

Now hopefully someone can also help with the encoding parameters. The idea is that I don’t want to build comprehensive encoding and decoding solutions but use H264 as a data storage format within an application. And for that it’s important to start evaluating lossless compression first. If only I knew how to set it…