server/images: use ruffle exporter for swf thumbnails
Works with far more SWFs than ffmpeg. Using OpenGL backend.
This commit is contained in:
parent
782f069031
commit
b34d38bfac
1 changed files with 18 additions and 5 deletions
|
@ -28,6 +28,9 @@ class Image:
|
|||
def __init__(self, content: bytes) -> None:
|
||||
self.content = content
|
||||
self._reload_info()
|
||||
if self.info["format"]["format_name"] == "swf":
|
||||
self.content = self.swf_to_png()
|
||||
self._reload_info()
|
||||
|
||||
@property
|
||||
def width(self) -> int:
|
||||
|
@ -60,10 +63,7 @@ class Image:
|
|||
"png",
|
||||
"-",
|
||||
]
|
||||
if (
|
||||
"duration" in self.info["format"]
|
||||
and self.info["format"]["format_name"] != "swf"
|
||||
):
|
||||
if "duration" in self.info["format"]:
|
||||
duration = float(self.info["format"]["duration"])
|
||||
if duration > 3:
|
||||
cli = [
|
||||
|
@ -76,6 +76,19 @@ class Image:
|
|||
self.content = content
|
||||
self._reload_info()
|
||||
|
||||
def swf_to_png(self) -> bytes:
|
||||
return self._execute(
|
||||
[
|
||||
"--silent",
|
||||
"-g",
|
||||
"gl",
|
||||
"--",
|
||||
"{path}",
|
||||
"-",
|
||||
],
|
||||
program="exporter",
|
||||
)
|
||||
|
||||
def to_png(self) -> bytes:
|
||||
return self._execute(
|
||||
[
|
||||
|
@ -315,7 +328,7 @@ class Image:
|
|||
)
|
||||
assert "format" in self.info
|
||||
assert "streams" in self.info
|
||||
if len(self.info["streams"]) < 1:
|
||||
if len(self.info["streams"]) < 1 and self.info["format"]["format_name"] != "swf":
|
||||
logger.warning("The video contains no video streams.")
|
||||
raise errors.ProcessingError(
|
||||
"The video contains no video streams."
|
||||
|
|
Loading…
Reference in a new issue