work with numpy #37
-
objective steps
code
result
best regards |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Short answer: You're responsible to put the input Numpy array in the correct image pixel format. 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, colorchennelmixer does the job with ffmpegio.transpose('mountains.mp4', 'temp.mp4', overwrite = True, vf='colorchannelmixer=0.299:0.587:0.144:00.299:0.587:0.144:00.299:0.587:0.144:0') I have not tested this command, but you get the idea. If you want to apply multiple effects (to grayscale + flip) then you can chain multiple filters as needed. |
Beta Was this translation helpful? Give feedback.
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"
ornp.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…