You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
url='https://github.com/hhoppe/data/raw/main/video.mp4'video=media.read_video(url)
print(video.shape, video.dtype) # It is a numpy array.print(video.metadata.fps) # The 'metadata' attribute includes framerate.media.show_video(video) # Play the video using the retrieved framerate.media.show_images(video, height=80, columns=4) # Show frames side-by-side.video=media.moving_circle((128, 128), num_images=10)
media.show_video(video, fps=10)
media.write_video('/tmp/video.mp4', video, fps=60)
# Darken a video frame-by-frame:filename_in='/tmp/video.mp4'filename_out='/tmp/out.mp4'withmedia.VideoReader(filename_in) asr:
print(f'shape={r.shape} fps={r.fps} bps={r.bps}')
darken_image=lambdaimage: media.to_float01(image) *0.5withmedia.VideoWriter(
filename_out, shape=r.shape, fps=r.fps, bps=r.bps) asw:
forimageinr:
w.add_image(darken_image(image))
media.show_video(media.read_video(filename_out), fps=60)
Setup:
Video I/O relies on the external program ffmpeg, which must be present in
the system PATH. On Unix, it can be installed using: