Skip to content

work with numpy #37

Answered by tikuma-lsuhsc
sugizo asked this question in Q&A
Discussion options

You must be logged in to vote

Short answer: grayscale= np.dot(frame[0,...], [0.299, 0.587, 0.144] ).astype(np.uint8)

You're responsible to put the input Numpy array in the correct image pixel format. ffmpegio simply passes the numpy data bytes straight to FFmpeg. Assuming that the video is RGB24 (8-bit per color channel) your input data dtype must be either "<u1" or np.uint8.

Now, if you're performing these fixed function (the same transform on every frame) read multiple frames at a time (as many as your system can handle). Looping one frame at a time significantly slows down the process.

Finally, as I alluded in the other post of yours, I'm a big proponent of using the FFmpeg filters whenever possible. In this case, c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sugizo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants