Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tgs_converter to match updated lottieconverter #694

Merged
merged 3 commits into from
Nov 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mautrix_telegram/example-config.yaml
Original file line number Diff line number Diff line change
@@ -223,16 +223,15 @@ bridge:
# Format to which animated stickers should be converted.
# disable - No conversion, send as-is (gzipped lottie)
# png - converts to non-animated png (fastest),
# gif - converts to animated gif, but loses transparency
# gif - converts to animated gif
# webm - converts to webm video, requires ffmpeg executable with vp9 codec and webm container support
target: gif
# Arguments for converter. All converters take width and height.
# GIF converter takes background as a hex color.
args:
width: 256
height: 256
background: "020202" # only for gif
fps: 30 # only for webm
fps: 25 # only for webm and gif (2, 5, 10, 20, 25 and 50 recommended)
# End-to-bridge encryption support options. These require matrix-nio to be installed with pip
# and login_shared_secret to be configured in order to get a device for the bridge bot.
#
4 changes: 2 additions & 2 deletions mautrix_telegram/util/tgs_converter.py
Original file line number Diff line number Diff line change
@@ -64,10 +64,10 @@ async def tgs_to_png(file: bytes, width: int, height: int, **_: Any) -> Converte
return ConvertedSticker("application/gzip", file)


async def tgs_to_gif(file: bytes, width: int, height: int, background: str = "202020",
async def tgs_to_gif(file: bytes, width: int, height: int, fps: int = 25,
**_: Any) -> ConvertedSticker:
proc = await asyncio.create_subprocess_exec(lottieconverter, "-", "-", "gif",
f"{width}x{height}", f"0x{background}",
f"{width}x{height}", str(fps),
stdout=asyncio.subprocess.PIPE,
stdin=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate(file)