@@ -249,25 +249,17 @@ def animated_webp_support(func: Callable[[str], FFProbeInfo]) -> Callable[[str],
249
249
def wrapper (uri : str ) -> FFProbeInfo :
250
250
probe_info = func (uri )
251
251
if probe_info .streams [0 ].height == 0 and probe_info .streams [0 ].width == 0 and probe_info .format .format_name == "webp_pipe" :
252
- if not uri .startswith ("http" ):
253
- webpmux_command = ["webpmux" , "-get" , "frame" , "1" , uri , "-o" , uri ]
254
- call (webpmux_command )
255
- return func (uri )
256
-
257
- parsed_uri = urlparse (uri )
258
-
259
- path = parsed_uri .path
260
- file = os .path .basename (path )
261
- _ , file_ext = os .path .splitext (file )
262
-
263
- response = requests .get (uri )
264
- response .raise_for_status ()
265
-
266
- with tempfile .NamedTemporaryFile (mode = "wb" , suffix = file_ext , delete = True ) as f :
267
- f .write (response .content )
268
- webpmux_command = ["webpmux" , "-get" , "frame" , "1" , f .name , "-o" , f .name ]
269
- call (webpmux_command )
270
- return func (f .name )
252
+ if uri .startswith ("http" ):
253
+ response = requests .get (uri )
254
+ response .raise_for_status ()
255
+ with tempfile .NamedTemporaryFile (mode = "wb" , suffix = ".webp" , delete = False ) as f :
256
+ f .write (response .content )
257
+ uri = f .name
258
+
259
+ assert os .path .exists (uri )
260
+ webpmux_command = ["webpmux" , "-get" , "frame" , "1" , uri , "-o" , uri ]
261
+ call (webpmux_command )
262
+ return func (uri )
271
263
return probe_info
272
264
273
265
return wrapper
0 commit comments