The Student Room Group

Python Programming - Reading & Resizing Videos in Google Colab Using OpenCV

I used the below code to read and display a video file in Google Colab. However, I do not understand how to resize it to a specific size. Coding is very different when it comes to this and any help would be highly appreciated!


from IPython.display import HTML
from base64 import b64encode

video_path = '/Videos/dog.mp4'

mp4 = open(video_path, "rb").read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML(f"""
<video width=400 controls><source src="{data_url}" type="video/mp4">
</video>""")

Quick Reply

Latest

Trending

Trending