Skip to content

Commit

Permalink
Update tgs_converter to match updated lottieconverter (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
sot-tech authored Nov 15, 2021
1 parent 2cc4398 commit b4d4f84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions mautrix_telegram/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
4 changes: 2 additions & 2 deletions mautrix_telegram/util/tgs_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b4d4f84

Please sign in to comment.