Allow different interpolation to VideoFrame.reformat
Created by: legraphista
Overview
There is no way to scale a video frame with other interpolation methods.
SWS_BILINEAR
is the best fit as a default, but for speed you would want SWS_FAST_BILINEAR
, and SWS_POINT
(neighbor) for up-scaling small frames (64x64) to better visualize them and keeping the information clean.
Using OpenCV would be an option but there are too many hoops to jump through. It's way faster to do in the native libav API.
Desired Behavior
Ability to use different interpolation for resizing a video frame. Right now it's hardcoded to use SWS_BILINEAR
Example API
frame.reformat(width=width,
height=height,
interpolation='neighbor')
# or maybe even better
frame.reformat(width=width,
height=height,
interpolation=av.video.interpolation.NEIGHBOR)
Additional context
Location of hardcoded flags: https://github.com/mikeboers/PyAV/blob/ae64e1ba52bea3cb72cfec473233f5137d0c1bda/av/video/frame.pyx#L200-L212