mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/images: use ruffle exporter for swf thumbnails
Works with far more SWFs than ffmpeg. Using OpenGL backend.
This commit is contained in:
@ -28,6 +28,9 @@ class Image:
|
|||||||
def __init__(self, content: bytes) -> None:
|
def __init__(self, content: bytes) -> None:
|
||||||
self.content = content
|
self.content = content
|
||||||
self._reload_info()
|
self._reload_info()
|
||||||
|
if self.info["format"]["format_name"] == "swf":
|
||||||
|
self.content = self.swf_to_png()
|
||||||
|
self._reload_info()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def width(self) -> int:
|
def width(self) -> int:
|
||||||
@ -60,10 +63,7 @@ class Image:
|
|||||||
"png",
|
"png",
|
||||||
"-",
|
"-",
|
||||||
]
|
]
|
||||||
if (
|
if "duration" in self.info["format"]:
|
||||||
"duration" in self.info["format"]
|
|
||||||
and self.info["format"]["format_name"] != "swf"
|
|
||||||
):
|
|
||||||
duration = float(self.info["format"]["duration"])
|
duration = float(self.info["format"]["duration"])
|
||||||
if duration > 3:
|
if duration > 3:
|
||||||
cli = [
|
cli = [
|
||||||
@ -76,6 +76,19 @@ class Image:
|
|||||||
self.content = content
|
self.content = content
|
||||||
self._reload_info()
|
self._reload_info()
|
||||||
|
|
||||||
|
def swf_to_png(self) -> bytes:
|
||||||
|
return self._execute(
|
||||||
|
[
|
||||||
|
"--silent",
|
||||||
|
"-g",
|
||||||
|
"gl",
|
||||||
|
"--",
|
||||||
|
"{path}",
|
||||||
|
"-",
|
||||||
|
],
|
||||||
|
program="exporter",
|
||||||
|
)
|
||||||
|
|
||||||
def to_png(self) -> bytes:
|
def to_png(self) -> bytes:
|
||||||
return self._execute(
|
return self._execute(
|
||||||
[
|
[
|
||||||
@ -315,7 +328,7 @@ class Image:
|
|||||||
)
|
)
|
||||||
assert "format" in self.info
|
assert "format" in self.info
|
||||||
assert "streams" 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.")
|
logger.warning("The video contains no video streams.")
|
||||||
raise errors.ProcessingError(
|
raise errors.ProcessingError(
|
||||||
"The video contains no video streams."
|
"The video contains no video streams."
|
||||||
|
Reference in New Issue
Block a user