Hi everyone,
I'm trying to convert with ffmpeg-python every frame of a video in a numpy array that could work with opencv
What I have tried:
Here my code:
<pre><pre lang="Python">for i in (frames):
out, _ = (
ffmpeg
.input(filename)
.output('pipe:',vframes=frames, format='rawvideo', pix_fmt='rgb24')
.run(capture_stdout=True)
)
video = (
np
.frombuffer(out, np.uint8)
.reshape([-1, 1920, 1080, 3])
)
print(f'Array from ffmpeg: {video}')
The code works and it creates a numpy array, but it does not work with opencv.
When I pass inside the for loop the array to opencv I get this error
imgS = cv2.resize(video, (0, 0), None, 0.5, 0.5)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
error: (-215:Assertion failed) !dsize.empty() in function 'cv::resize'