Hi, I'm trying to write a video from image buffer, and I have troubles with that. When I save the buffer to an image, and then read it with opencv and write to video, it works, but if I try to skip the saving process ( which makes more sense in this case), the video output is empty, even though when I compare the image I processed from buffer with the image read from disk with opencv, they are the same. What am I missing here?
writer = cv2.VideoWriter("output2.avi", cv2.VideoWriter_fourcc(*'MJPG'), 24, (WINDOW_WIDTH, WINDOW_HEIGHT))
for data in imgs:
data_array = np.frombuffer(data, np.uint8)
data_array.shape = WINDOW_WIDTH, WINDOW_HEIGHT, 4
new_data_array = cv2.cvtColor(data_array, cv2.COLOR_RGBA2BGR)
# for testing
img = Image.frombuffer("RGBA", (WINDOW_WIDTH, WINDOW_HEIGHT), data)
img.save("img.png", "png")
im = cv2.imread("img.png", 1)
print(im.all() == new_data_array.all()) # prints all true
# writer.write(new_data_array) # doesn't work
writer.write(im) # works
writer.release()