ffmpeg fixed for windows
This commit is contained in:
parent
6221eed40d
commit
82ce526da6
2 changed files with 12 additions and 10 deletions
|
|
@ -68,7 +68,7 @@ class FFMPEG:
|
||||||
"""
|
"""
|
||||||
cls._ensure_installed()
|
cls._ensure_installed()
|
||||||
|
|
||||||
cmd = ["ffmpeg"]
|
cmd = [".\\ffmpeg.exe" if IS_WINDOWS else "ffmpeg"]
|
||||||
cmd.extend(ffmpeg_args)
|
cmd.extend(ffmpeg_args)
|
||||||
logger.debug("Running %s", " ".join(cmd))
|
logger.debug("Running %s", " ".join(cmd))
|
||||||
with Logger.handle_external_logs(name="ffmpeg"):
|
with Logger.handle_external_logs(name="ffmpeg"):
|
||||||
|
|
|
||||||
|
|
@ -64,18 +64,20 @@ def convert_url_thumbnail(thumbnail_url: str, output_thumbnail_path: str) -> Opt
|
||||||
"""
|
"""
|
||||||
# timeout after 8 seconds
|
# timeout after 8 seconds
|
||||||
with urlopen(thumbnail_url, timeout=1.0) as file:
|
with urlopen(thumbnail_url, timeout=1.0) as file:
|
||||||
with tempfile.NamedTemporaryFile() as thumbnail:
|
with tempfile.NamedTemporaryFile(delete=False) as thumbnail:
|
||||||
thumbnail.write(file.read())
|
thumbnail.write(file.read())
|
||||||
|
|
||||||
os.makedirs(os.path.dirname(output_thumbnail_path), exist_ok=True)
|
os.makedirs(os.path.dirname(output_thumbnail_path), exist_ok=True)
|
||||||
|
|
||||||
tmp_output_path = FFMPEG.tmp_file_path(
|
tmp_output_path = FFMPEG.tmp_file_path(
|
||||||
relative_file_path=thumbnail.name, extension="jpg"
|
relative_file_path=thumbnail.name, extension="jpg"
|
||||||
)
|
)
|
||||||
FFMPEG.run(["-bitexact", "-i", thumbnail.name, tmp_output_path])
|
FFMPEG.run(["-bitexact", "-i", thumbnail.name, tmp_output_path])
|
||||||
|
|
||||||
# Have FileHandler handle the move to a potential cross-device
|
# Have FileHandler handle the move to a potential cross-device
|
||||||
FileHandler.move(tmp_output_path, output_thumbnail_path)
|
FileHandler.move(tmp_output_path, output_thumbnail_path)
|
||||||
FileHandler.delete(tmp_output_path)
|
FileHandler.delete(tmp_output_path)
|
||||||
|
|
||||||
|
os.remove(thumbnail.name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue