VideoPlayer widget in Supervisely is a media player that utilizes the HTML <video> tag and provides additional functionalities to control it through Python code such as seeking and controlling the current playback time in seconds. It uses the built-in browser player, which is supported by most devices.
In addition, Video Player has a feature for overlaying an image on top of the video without modifying the video itself.
import os
from pathlib import Path
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Button, Card, Container, Checkbox
from supervisely.app.widgets import Flexbox, InputNumber, VideoPlayer
from supervisely._utils import abs_url
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
Prepare videos url and type
video_id = int(os.environ["modal.state.slyVideoId"]) # get video ID from environment
video_info = api.video.get_info_by_id(id=video_id) # get VideoInfo from server
video_url = abs_url(video_info.path_original)
video_mime_type = video_info.file_meta["mime"]
local_video_url = "/static/video-cam2.mp4" # local video url
local_video_type = "video/mp4" # local video url