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

Telegram Animated Sticker TGS Dependency Lottie - add to Docker Image #1466

Closed
computeronix opened this issue May 10, 2021 · 5 comments
Closed
Labels
enhancement New feature or request telegram

Comments

@computeronix
Copy link
Contributor

As a feature request,

In PR #1173 there was mention of an external dependency for lottie.

So I don't have to create my own Docker image - could you add this dependency to the Docker image to support the capability in the PR?

@computeronix computeronix added the enhancement New feature or request label May 10, 2021
@Funatiker
Copy link
Contributor

You are talking about this Dockerfile? https://github.com/42wim/matterbridge/blob/master/tgs.Dockerfile

What is the external dependency that is missing?

@computeronix
Copy link
Contributor Author

computeronix commented May 12, 2021

correct, "lottie cairosvg"

In the docker it looks like lottie is mentioned but when I went to ran this variable on Telegram it error'd out saying lottie was not there
MediaConvertTgs="png"

@Funatiker
Copy link
Contributor

Funatiker commented May 12, 2021

This is extremely confusing. The linked Dockerfile does work for me but only for png, not for webp.

Steps to reproduce:

  1. Clone Repo as mattermost
  2. Make a directory mattermost-config and in it serverlol
  3. Run a webserver in serverlol using python3 -m http.server
  4. Compile the repo mattermost using sudo docker build . -f tgs.Dockerfile -t matterbridge-lottie
  5. Configure a matterbridge.toml in the mattermost-config directory with a telegram, and an XMPP interface, and one bridge for both. Also configure your webserver in it.
  6. Start the container from mattermost-config with sudo docker run -ti --name matterbridge --mount "type=bind,source=$(pwd),target=/etc/matterbridge" matterbridge-lottie --debug
  7. Send an animated sticker from telegram and receive a PNG (link)

Relevant debug output:

[0033] DEBUG gateway:      [func1:gateway/gateway.go:488] => Send from telegram.mytelegrambot (1873815045) to telegram.mytelegrambot (1873815045) took 200.335µs
[0033] DEBUG telegram:     [HandleDownloadSize:bridge/helper/helper.go:157] Trying to download "file_5.tgs.webp" with size 17984
[0033] DEBUG telegram:     [maybeConvertTgs:bridge/telegram/handlers.go:234] Tgs to PNG conversion enabled, converting 0xc000660940
[0034] DEBUG telegram:     [HandleDownloadData:bridge/helper/helper.go:173] Download OK "file_5.png" 84816

Used config:

[general]
        # this is in the mountpoint we will use in our docker container
        MediaDownloadPath="/etc/matterbridge/serverlol/"
        # the IP address in our local network, and the port announced by python
        MediaServerDownload="https://192.168.178.28:8000"
        # the converted lottie files get quite big, see #1459
        MediaDownloadSize=20000000

[telegram]
        [telegram.mytelegrambot]
        #See https://core.telegram.org/bots#6-botfather 
        #and https://www.linkedin.com/pulse/telegram-bots-beginners-marco-frau
        Token="…:…"
        RemoteNickFormat="<{NICK}> "
        # this enables lottie!
        MediaConvertTgs="png"

[xmpp]
        [xmpp.myxmppbot]
        Server="…:5222"
        #Jid your userid
        Jid="…@…"
        Password="…"
        Muc="…"
        Nick="Bridge"
        RemoteNickFormat="<{NICK}> "

[[gateway]]
        name="testbridge"
        enable=true

        [[gateway.inout]]
        account="telegram.mytelegrambot"
        channel="…"

        [[gateway.inout]]
        account="xmpp.myxmppbot"
        channel="…"

Weirdly, it doesn't for for webp:

$ sudo docker exec matterbridge lottie_convert.py --input-format lottie --output-format webp /etc/matterbridge/serverlol/06303fcc/file_2_tgs.webp /etc/matterbridge/serverlol/06303fcc/file_2_tgs_2.webp
Traceback (most recent call last):
  File "/usr/bin/lottie_convert.py", line 158, in <module>
    exporter.process(an, outfile, **o_options)
  File "/usr/lib/python3.8/site-packages/lottie/parsers/baseporter.py", line 18, in process
    return self.callback(*a, **kw)
  File "/usr/lib/python3.8/site-packages/lottie/exporters/gif.py", line 77, in export_webp
    raise Exception("WebP animations not supported in this system")
Exception: WebP animations not supported in this system

Looks like a certain webp library (libwebp-dev) isn't present in the right version: https://github.com/python-pillow/Pillow/blob/b3bb58746ca97229b728fea110701c9181a01b96/docs/handbook/image-file-formats.rst#saving-sequences https://pillow.readthedocs.io/en/latest/installation.html#building-on-linux

@Funatiker
Copy link
Contributor

@computeronix I couldn't reproduce your bug. I compiles the tgs.Dockerfile as described above and it worked for png. After adding the dependency, I could compile the image, and even create webp files in the docker container.

@42wim 42wim added the telegram label May 22, 2021
@42wim
Copy link
Owner

42wim commented May 22, 2021

Fixed in #1476 thanks to @Funatiker

@42wim 42wim closed this as completed May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request telegram
Projects
None yet
Development

No branches or pull requests

3 participants