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.32k stars 233 forks source link

How to encode h264 bytes stream with sei? #472

Closed Ar4enal closed 1 year ago

Ar4enal commented 1 year ago

I want to save an encoded .h264 file. I use this to save a file. success = nvEnc.EncodeSingleFrame(rawFrame, encFrame, sync=False) encByteArray = bytearray(encFrame) encFile.write(encByteArray)

https://github.com/NVIDIA/VideoProcessingFramework/blob/7ab13cb035fb3aa33eca0b76d2815336211945f3/samples/SampleEncode.py#L96-L119

Then I analyze the file, there is no sei inside. How to encode with sei? I find that there is a function to encode with sei, but I do not know how to get sei numpy.ndarray firstly. https://github.com/NVIDIA/VideoProcessingFramework/blob/7ab13cb035fb3aa33eca0b76d2815336211945f3/src/PyNvCodec/__init__.pyi#L451

gedoensmax commented 1 year ago

I would recommend looking into PyAV to decode additional information from the container. I found some PR around it, might be a good starting point. https://github.com/PyAV-Org/PyAV/pull/924