Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -159,9 +159,9 @@ def canvas_of(path: str) -> tuple[int, int]:
|
|
| 159 |
The same rule as `omni_preencode.canvas` — the part of the frame that is kept decides.
|
| 160 |
"""
|
| 161 |
|
| 162 |
-
import
|
| 163 |
|
| 164 |
-
stream =
|
| 165 |
width, height = int(stream.width), int(stream.height)
|
| 166 |
return (768, 1344) if width >= height else (1344, 768)
|
| 167 |
|
|
@@ -169,9 +169,9 @@ def canvas_of(path: str) -> tuple[int, int]:
|
|
| 169 |
def read_video(path: str, seconds: float = 0.0) -> tuple[np.ndarray, float]:
|
| 170 |
"""Decode a clip — only its first `seconds` when given — exactly as `omni_preencode.read_video`."""
|
| 171 |
|
| 172 |
-
import
|
| 173 |
|
| 174 |
-
container =
|
| 175 |
stream = container.streams.video[0]
|
| 176 |
stream.thread_type = "AUTO"
|
| 177 |
fps = float(stream.average_rate)
|
|
|
|
| 159 |
The same rule as `omni_preencode.canvas` — the part of the frame that is kept decides.
|
| 160 |
"""
|
| 161 |
|
| 162 |
+
import omni_preencode as pre
|
| 163 |
|
| 164 |
+
stream = pre.open_media(path).streams.video[0]
|
| 165 |
width, height = int(stream.width), int(stream.height)
|
| 166 |
return (768, 1344) if width >= height else (1344, 768)
|
| 167 |
|
|
|
|
| 169 |
def read_video(path: str, seconds: float = 0.0) -> tuple[np.ndarray, float]:
|
| 170 |
"""Decode a clip — only its first `seconds` when given — exactly as `omni_preencode.read_video`."""
|
| 171 |
|
| 172 |
+
import omni_preencode as pre
|
| 173 |
|
| 174 |
+
container = pre.open_media(path)
|
| 175 |
stream = container.streams.video[0]
|
| 176 |
stream.thread_type = "AUTO"
|
| 177 |
fps = float(stream.average_rate)
|