vidformer 0.2.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Metadata-Version: 2.1
         | 
| 2 2 | 
             
            Name: vidformer
         | 
| 3 | 
            -
            Version: 0. | 
| 3 | 
            +
            Version: 0.3.1
         | 
| 4 4 | 
             
            Summary: A Python library for creating and viewing videos with vidformer.
         | 
| 5 5 | 
             
            Author-email: Dominik Winecki <dominikwinecki@gmail.com>
         | 
| 6 6 | 
             
            Requires-Python: >=3.8
         | 
| @@ -10,6 +10,8 @@ Classifier: Operating System :: OS Independent | |
| 10 10 | 
             
            Requires-Dist: requests
         | 
| 11 11 | 
             
            Requires-Dist: msgpack
         | 
| 12 12 | 
             
            Requires-Dist: numpy
         | 
| 13 | 
            +
            Project-URL: Homepage, https://ixlab.github.io/vidformer/
         | 
| 14 | 
            +
            Project-URL: Issues, https://ixlab.github.io/vidformer/issues
         | 
| 13 15 |  | 
| 14 16 | 
             
            # vidformer-py
         | 
| 15 17 |  | 
| @@ -0,0 +1,4 @@ | |
| 1 | 
            +
            vidformer.py,sha256=2o3jxO5Ce4-aLHXQ0DNfjZsfwC77x4BvTWjObhvbB_4,24520
         | 
| 2 | 
            +
            vidformer-0.3.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
         | 
| 3 | 
            +
            vidformer-0.3.1.dist-info/METADATA,sha256=ttaoMZ8Xg4pTZp1siqPg_QcGwS4FlD45ilBIan2rsv4,643
         | 
| 4 | 
            +
            vidformer-0.3.1.dist-info/RECORD,,
         | 
    
        vidformer.py
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            """A Python library for creating and viewing videos with vidformer."""
         | 
| 2 2 |  | 
| 3 | 
            -
            __version__ = "0. | 
| 3 | 
            +
            __version__ = "0.3.1"
         | 
| 4 4 |  | 
| 5 5 | 
             
            import subprocess
         | 
| 6 6 | 
             
            from fractions import Fraction
         | 
| @@ -35,12 +35,12 @@ def _check_hls_link_exists(url, max_attempts=150, delay=0.1): | |
| 35 35 | 
             
                    try:
         | 
| 36 36 | 
             
                        response = requests.get(url)
         | 
| 37 37 | 
             
                        if response.status_code == 200:
         | 
| 38 | 
            -
                            return  | 
| 38 | 
            +
                            return response.text.strip()
         | 
| 39 39 | 
             
                        else:
         | 
| 40 40 | 
             
                            time.sleep(delay)
         | 
| 41 41 | 
             
                    except requests.exceptions.RequestException as e:
         | 
| 42 42 | 
             
                        time.sleep(delay)
         | 
| 43 | 
            -
                return  | 
| 43 | 
            +
                return None
         | 
| 44 44 |  | 
| 45 45 |  | 
| 46 46 | 
             
            class Spec:
         | 
| @@ -77,10 +77,10 @@ class Spec: | |
| 77 77 | 
             
                        frames.append(frame)
         | 
| 78 78 | 
             
                    return {"frames": frames}, s, f
         | 
| 79 79 |  | 
| 80 | 
            -
                def play(self, server,  | 
| 80 | 
            +
                def play(self, server, method="html"):
         | 
| 81 81 | 
             
                    """Play the video live in the notebook."""
         | 
| 82 82 |  | 
| 83 | 
            -
                    from IPython.display import HTML
         | 
| 83 | 
            +
                    from IPython.display import IFrame, HTML
         | 
| 84 84 |  | 
| 85 85 | 
             
                    spec, sources, filters = self._to_json_spec()
         | 
| 86 86 | 
             
                    spec_json_bytes = json.dumps(spec).encode("utf-8")
         | 
| @@ -108,12 +108,15 @@ class Spec: | |
| 108 108 | 
             
                    print(f"Sending to server. Spec is {len(spec_obj_json_gzip_b64)} bytes")
         | 
| 109 109 | 
             
                    resp = server._new(spec_obj_json_gzip_b64, sources, filters, arrays, self._fmt)
         | 
| 110 110 | 
             
                    hls_video_url = resp["stream_url"]
         | 
| 111 | 
            +
                    hls_player_url = resp["player_url"]
         | 
| 111 112 | 
             
                    namespace = resp["namespace"]
         | 
| 112 | 
            -
             | 
| 113 113 | 
             
                    hls_js_url = server.hls_js_url()
         | 
| 114 114 |  | 
| 115 | 
            -
                     | 
| 116 | 
            -
             | 
| 115 | 
            +
                    if method == "iframe":
         | 
| 116 | 
            +
                        return IFrame(hls_player_url, width=1280, height=720)
         | 
| 117 | 
            +
                    if method == "html":
         | 
| 118 | 
            +
                        # We add a namespace to the video element to avoid conflicts with other videos
         | 
| 119 | 
            +
                        html_code = f"""
         | 
| 117 120 | 
             
            <!DOCTYPE html>
         | 
| 118 121 | 
             
            <html>
         | 
| 119 122 | 
             
            <head>
         | 
| @@ -137,9 +140,11 @@ class Spec: | |
| 137 140 | 
             
            </body>
         | 
| 138 141 | 
             
            </html>
         | 
| 139 142 | 
             
            """
         | 
| 140 | 
            -
             | 
| 143 | 
            +
                        return HTML(data=html_code)
         | 
| 144 | 
            +
                    else:
         | 
| 145 | 
            +
                        return hls_player_url
         | 
| 141 146 |  | 
| 142 | 
            -
                def save(self, server, pth,  | 
| 147 | 
            +
                def save(self, server, pth, encoder=None, encoder_opts=None):
         | 
| 143 148 | 
             
                    """Save the video to a file."""
         | 
| 144 149 |  | 
| 145 150 | 
             
                    assert encoder is None or type(encoder) == str
         | 
| @@ -281,11 +286,19 @@ class YrdenServer: | |
| 281 286 | 
             
                        cmd = [bin, "yrden", "--port", str(self._port)]
         | 
| 282 287 | 
             
                        if _in_notebook:
         | 
| 283 288 | 
             
                            # We need to print the URL in the notebook
         | 
| 284 | 
            -
                            # This is  | 
| 289 | 
            +
                            # This is a trick to get VS Code to forward the port
         | 
| 285 290 | 
             
                            cmd += ["--print-url"]
         | 
| 286 291 | 
             
                        self._proc = subprocess.Popen(cmd)
         | 
| 287 292 |  | 
| 288 | 
            -
                     | 
| 293 | 
            +
                    version = _check_hls_link_exists(f"http://{self._domain}:{self._port}/")
         | 
| 294 | 
            +
                    if version is None:
         | 
| 295 | 
            +
                        raise Exception("Failed to connect to server")
         | 
| 296 | 
            +
             | 
| 297 | 
            +
                    expected_version = f"vidformer-yrden v{__version__}"
         | 
| 298 | 
            +
                    if version != expected_version:
         | 
| 299 | 
            +
                        print(
         | 
| 300 | 
            +
                            f"Warning: Expected version `{expected_version}`, got `{version}`. API may not be compatible!"
         | 
| 301 | 
            +
                        )
         | 
| 289 302 |  | 
| 290 303 | 
             
                def _source(self, name: str, path: str, stream: int, service):
         | 
| 291 304 | 
             
                    r = requests.post(
         | 
| @@ -358,9 +371,9 @@ class SourceExpr: | |
| 358 371 |  | 
| 359 372 | 
             
                def __repr__(self):
         | 
| 360 373 | 
             
                    if self._is_iloc:
         | 
| 361 | 
            -
                        return f"{self._source. | 
| 374 | 
            +
                        return f"{self._source._name}.iloc[{self._idx}]"
         | 
| 362 375 | 
             
                    else:
         | 
| 363 | 
            -
                        return f"{self._source. | 
| 376 | 
            +
                        return f"{self._source._name}[{self._idx}]"
         | 
| 364 377 |  | 
| 365 378 | 
             
                def _to_json_spec(self):
         | 
| 366 379 | 
             
                    if self._is_iloc:
         | 
| @@ -524,6 +537,8 @@ class FilterExpr: | |
| 524 537 |  | 
| 525 538 |  | 
| 526 539 | 
             
            class UDF:
         | 
| 540 | 
            +
                """User-defined filter superclass"""
         | 
| 541 | 
            +
             | 
| 527 542 | 
             
                def __init__(self, name: str):
         | 
| 528 543 | 
             
                    self._name = name
         | 
| 529 544 | 
             
                    self._socket_path = None
         | 
    
        vidformer-0.2.0.dist-info/RECORD
    DELETED
    
    | @@ -1,4 +0,0 @@ | |
| 1 | 
            -
            vidformer.py,sha256=KcSMT_q66O-r0xtGujhHl0e6YMAyAovhzpsnR_ftgwY,23911
         | 
| 2 | 
            -
            vidformer-0.2.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
         | 
| 3 | 
            -
            vidformer-0.2.0.dist-info/METADATA,sha256=QJ8XqcazkCcn_ufPkTQzX3rQ9yTzb4_SOf_npWpnjHQ,523
         | 
| 4 | 
            -
            vidformer-0.2.0.dist-info/RECORD,,
         | 
| 
            File without changes
         |