diff --git a/docs/src/getting-started.md b/docs/src/getting-started.md index 68c90f3..a6ccb41 100644 --- a/docs/src/getting-started.md +++ b/docs/src/getting-started.md @@ -79,6 +79,8 @@ This plays this result: +> Some Jupyter environments are weird (i.e., VS Code), so `.play()` might not work. Using `.play(..., method="iframe")` may help. + It's worth noting that we are playing frames in order here and outputing video at the same framerate we recieved, but that doesn't need to be the case. Here are some things other things you can now try: diff --git a/vidformer-cli/Cargo.toml b/vidformer-cli/Cargo.toml index b1dbd36..c7649d0 100644 --- a/vidformer-cli/Cargo.toml +++ b/vidformer-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vidformer-cli" -version = "0.4.0" +version = "0.4.1" edition = "2021" [dependencies] diff --git a/vidformer-py/src/vidformer.py b/vidformer-py/src/vidformer.py index 8188cd3..b433362 100644 --- a/vidformer-py/src/vidformer.py +++ b/vidformer-py/src/vidformer.py @@ -1,6 +1,6 @@ """A Python library for creating and viewing videos with vidformer.""" -__version__ = "0.4.0" +__version__ = "0.4.1" import subprocess from fractions import Fraction @@ -80,8 +80,6 @@ def _to_json_spec(self): def play(self, server, method="html"): """Play the video live in the notebook.""" - from IPython.display import IFrame, HTML - spec, sources, filters = self._to_json_spec() spec_json_bytes = json.dumps(spec).encode("utf-8") spec_obj_json_gzip = gzip.compress(spec_json_bytes, compresslevel=1) @@ -112,9 +110,17 @@ def play(self, server, method="html"): namespace = resp["namespace"] hls_js_url = server.hls_js_url() + if method == "link": + return hls_video_url + if method == "player": + return hls_player_url if method == "iframe": + from IPython.display import IFrame + return IFrame(hls_player_url, width=1280, height=720) if method == "html": + from IPython.display import HTML + # We add a namespace to the video element to avoid conflicts with other videos html_code = f""" @@ -439,6 +445,14 @@ def __getitem__(self, idx): raise Exception("Source index must be a Fraction") return SourceExpr(self, idx, False) + def play(self, *args, **kwargs): + """Play the video live in the notebook.""" + + domain = self.ts() + render = lambda t, i: self[t] + spec = Spec(domain, render, self.fmt()) + return spec.play(*args, **kwargs) + class StorageService: def __init__(self, service: str, **kwargs): diff --git a/vidformer/Cargo.toml b/vidformer/Cargo.toml index 1e963e5..0b29a68 100644 --- a/vidformer/Cargo.toml +++ b/vidformer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vidformer" -version = "0.4.0" +version = "0.4.1" description = "A data-systems focused library for declarative video synthesis." authors = ["Dominik Winecki "] edition = "2021"