multimodalart HF Staff commited on
Commit
c19fa93
·
verified ·
1 Parent(s): 48aee38

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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 av
163
 
164
- stream = av.open(path, metadata_errors="ignore").streams.video[0]
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 av
173
 
174
- container = av.open(path, metadata_errors="ignore")
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)