RomanArzumanyan / VALI

Video processing in Python
Apache License 2.0
44 stars 4 forks source link

Opportunity convert one frame from bytes #105

Open kadimon opened 2 months ago

kadimon commented 2 months ago

Is it possible to use this library to convert a single keyframe from bytes?

RomanArzumanyan commented 2 months ago

Hi @kadimon

Yes, it does. Did you try the samples ?

kadimon commented 2 months ago

I have not found an example of creating a packet of bytes in samples. I am currently experiencing some hardware compatibility issues when trying to run code from a decoder sample. It is great that the ability to decode bytes of keyframes is available. @RomanArzumanyan if you have a sample code that would be cool.

RomanArzumanyan commented 2 months ago

@kadimon

You can e. g. run samples in Google Colab notebook with T4 runtime type.

I have not found an example of creating a packet of bytes in samples

That contradicts the issue description. I was under impression that you need to decode a single key frame. If you don't have compressed packet with the key frame, you have to create it first. Any suitable framework will do. VALI, OpenCV, PyAV, you name it. Encoding sample isn't written yet, but you can reference PyNvEncoder class unit test, it's quite small and simple: https://github.com/RomanArzumanyan/VALI/blob/1862c35b83779e51e602c0c7090f47b89ca541f3/tests/test_PyNvEncoder.py#L55

Please note that VALI can only take files as input. You can mmap encoded packet, but it has to have the URL. That is done to keep PyDecoder class API manageable. Otherwise it will have to return variety of status codes for all sorts of corner cases (like when a single packet isn't enough to decode something meaningful).