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

Can I specify the resolution I want when decoding? #562

Closed gzchenjiajun closed 8 months ago

gzchenjiajun commented 8 months ago

Thank you vpf for this project! Much more convenient than compiling from opencv to get python support for hard decoding!

import cv2
width = 640
height = 480
cap = cv2.VideoCapture('your_video_stream')
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
while True:
    ret, frame = cap.read()
    if not ret:
        break
    cv2.imshow('Frame', frame)
    if cv2.waitKey(1) & 0xFF == 27:
        break
cap.release()
cv2.destroyAllWindows()

I have two questions: 1, Can I achieve similar functions above, that is, when decoding with vpf, specify the size of the picture I need in advance, such as: cap.set(cv2.CAP_PROP_FRAME_WIDTH, width) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height) What is a similar implementation in vpf?

2, Which hard encoder and hard decoder is used to execute vpf? Is it nvdec? Because I didn't see which specific decoder was used.

RomanArzumanyan commented 8 months ago

Hi @gzchenjiajun

Please check out https://github.com/RomanArzumanyan/VALI which is VPF successor. It’s actively supported and maintained, has compatible API and module naming. Just duplicate your issue there.

WRT to your very question:

Can I achieve similar functions above

You can use PyNvDecoder +PySurfaceResizer for on-GPU decoding and scaling. I assume the similar processing is done under the hood in OpenCV.

Which hard encoder and hard decoder is used to execute vpf?

VPF uses Nvdec and Nvenc via NV Video Codec SDK API.

gzchenjiajun commented 8 months ago

thks! @RomanArzumanyan