Skip to content

Feature request: Add Lottie export format #704

Open

Description

@ec1oud

It seems popular, and a good animation format for the web and for mobile devices (but I just discovered it ;-) I haven't found a proper spec for the JSON but there are open-source viewers, and JSON schema files here https://github.com/airbnb/lottie-web/tree/master/docs/json


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

  1. adampiskorski commented on Jan 28, 2019

    @adampiskorski

    I think this would be a killer feature, as otherwise to have a nice modern pipeline for animations on web + mobile you would need Adobe AE.
    Synfig could certainly reduce the barrier to entry and keep the pipeline in the open source world.

  2. ThobyV commented on Feb 27, 2019

    @ThobyV

    I support this move too. This would be very useful to have in synfig as also the web community Is large and svg-based animation on the web is growing. The thought of Having to use a great tool like synfig to make animations for the web makes me happy.

    May I ask, What are the core requirements that could make this happen.

  3. morevnaproject commented on Feb 28, 2019

    @morevnaproject
    Member

    We need someone who can code a converter from .sif (Synfig format) to Lottie. This could be done in simple language, like Python.

    This task requires knowledge of .sif format (this is just XML and easy to understand) and Lottie format (can be figured out from
    https://github.com/airbnb/lottie-web/tree/master/docs/json).

  4. dinolinjob commented on Mar 2, 2019

    @dinolinjob

    I want to implement this feature. Can I work on this one?

  5. ThobyV commented on Mar 2, 2019

    @ThobyV

    We need someone who can code a converter from .sif (Synfig format) to Lottie. This could be done in simple language, like Python.

    This task requires knowledge of .sif format (this is just XML and easy to understand) and Lottie format (can be figured out from
    https://github.com/airbnb/lottie-web/tree/master/docs/json).

    This would mean writing a Python converter that parses XML into structured JSON. Lottie uses JSON and uses a Javascript interface so it's works well for the web.

  6. ThobyV commented on Mar 2, 2019

    @ThobyV

    Am I right to assume this? Also Would it be some sort of plugin written for Synfig?

  7. AnishGG commented on Mar 2, 2019

    @AnishGG
    Member

    Hi,
    I am Anish from IIIT Hyderabad. I would like to contribute to this project in GSOC. I was going through the idea list and this seems interesting. Could anyone help me get started with this?

  8. morevnaproject commented on Mar 3, 2019

    @morevnaproject
    Member

    @ThobyV Yes, you right. I think this can be implemented as Python plugin - https://wiki.synfig.org/Doc:Plugins

    @dinolinjob @AnishGG welcome to the tread! I suggest to start by implementing a demo plugin that does some very simple conversion. I.e. converts some Synfig file with one simple layer (Rectangle or Circle or Image) to Lottie JSON.

  9. morevnaproject commented on Mar 3, 2019

    @morevnaproject
    Member

    @dinolinjob @AnishGG @ThobyV Before starting, please let me know which simple layer you choose to implement - so we make sure each one is taking different task. ^__^

  10. ThobyV commented on Mar 3, 2019

    @ThobyV

    @morevnaproject I think I'll go with a rectangle svg shape. I will make sure to update us here on my progress. 😄

  11. dinolinjob commented on Mar 3, 2019

    @dinolinjob

    @morevnaproject I will go with a circle.

  12. prasadrathod commented on Mar 3, 2019

    @prasadrathod

    @morevnaproject I am interested either. I'll go with the circle layer Synfig file. I will make sure to update you here. Most of my stuff is on Gitlab with id prasadPVR.

  13. morevnaproject commented on Mar 4, 2019

    @morevnaproject
    Member

    Hi @JagsPvr ! The Circle layer task is already allocated to @dinolinjob. Please choose some other layer type. I suggest to take Image Layer or Star Layer (https://wiki.synfig.org/Star_Layer).

  14. added
    Assigned
    on Mar 4, 2019
  15. 31 remaining items

  16. self-assigned this
    on Jul 7, 2019
  17. LaPingvino commented on Jul 8, 2019

    @LaPingvino

    @mbasaglia can you give an example output file so I can test if my Telegram picks it up independently? Also would you be able to create a command line tool just to convert Lottie JSON to tgs? I think that would be really helpful to get other people up to speed.

  18. mbasaglia commented on Jul 8, 2019

    @mbasaglia
    Contributor

    @LaPingvino
    Here's a test file (Note: I had to add the gz suffix to upload it to github, for telegram remove ".gz" from the file name, without extracting it)
    test.sifz.D35E47A0.tgs.gz

    Also keep in mind currently the Lottie exporter is very basic so it can't yet be used to export anything but the most trivial shapes and animations.

    I already have utility scripts in the same repo I've linked above. I'm also working on a python library based off the Lottie json schema

  19. mbasaglia commented on Jul 8, 2019

    @mbasaglia
    Contributor

    Quick question: What kind of reference/documentation has been used to describe the lottie format for exporting from synfig? I see some discrepancies between the json schema in the lottie repo and the output from the synfig plugin.
    The schema itself seems a bit low quality so I was wondering if there was a better source of info on the format.

  20. AnishGG commented on Jul 8, 2019

    @AnishGG
    Member

    Basically the above mentioned JSoN schema has been used. The keys which are serving no purpose have been removed intentionally. Even the schema has some mistakes in it.
    So to be fully sure, you can create the shape/layer in After Effects and use bodymovin plugin to export it to lottie format. This will give you the correct results.

  21. AnishGG commented on Jul 8, 2019

    @AnishGG
    Member

    @mbasaglia
    I had a look at the tgs code on gitlab. I noticed that you cloned the lottie-exporter's part which is merged in the master. It does not support splines yet.
    But the lattest version #756 supports splines. You might want to clone this instead of the previous version

  22. mbasaglia commented on Jul 8, 2019

    @mbasaglia
    Contributor

    thanks, I've subscribed to that PR, I'll keep my version up to date based on that

  23. mbasaglia commented on Jul 10, 2019

    @mbasaglia
    Contributor

    btw, I did a lot of work on making sense of the lottie format so I developed a python framework that can be used to read and write these files. If there's ever the need to import lottie files into synfig my framework is capable of doing so.

  24. GraithTiger commented on Jul 20, 2019

    @GraithTiger

    I've picked up Synfig and have been trying out the lottie exporter, and I've found that it fails on this file:
    noises_graithtiger.zip, giving the error:

    Traceback (most recent call last):
      File "lottie-exporter.py", line 161, in <module>
        new_file_name = parse(FILE_NAME)
      File "lottie-exporter.py", line 66, in parse
        gen_layers(settings.lottie_format["layers"], root, len(root) - 1)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\driver.py", line 82, in gen_layers
        itr)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\group.py", line 85, in gen_layer_group
        asset = add_precomp_asset(settings.lottie_format["assets"][-1], canvas[0], len(canvas[0]))
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\sources\precomp.py", line 26, in add_precomp_asset
        layers.driver.gen_layers(lottie["layers"], root, layer_itr-1)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\driver.py", line 82, in gen_layers
        itr)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\group.py", line 85, in gen_layer_group
        asset = add_precomp_asset(settings.lottie_format["assets"][-1], canvas[0], len(canvas[0]))
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\sources\precomp.py", line 26, in add_precomp_asset
        layers.driver.gen_layers(lottie["layers"], root, layer_itr-1)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\driver.py", line 82, in gen_layers
        itr)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\group.py", line 72, in gen_layer_group
        group.update_pos(pos)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\synfig\group.py", line 75, in update_pos
        add(waypoint[0], offset)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\synfig\group.py", line 91, in add
        vector[0].text = str(float(vector[0].text) + offset[0])
    ValueError: could not convert string to float: 
    

    Looking into it a little it appears that the script is operating on a scalar when it's expecting a vector and erroring out. Adding

    if vector.tag != "vector":
        return
    

    before the offending line seems to fix that issue, but a similar error crops up later:

    Traceback (most recent call last):
      File "lottie-exporter.py", line 161, in <module>
        new_file_name = parse(FILE_NAME)
      File "lottie-exporter.py", line 66, in parse
        gen_layers(settings.lottie_format["layers"], root, len(root) - 1)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\driver.py", line 82, in gen_layers
        itr)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\group.py", line 85, in gen_layer_group
        asset = add_precomp_asset(settings.lottie_format["assets"][-1], canvas[0], len(canvas[0]))
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\sources\precomp.py", line 26, in add_precomp_asset
        layers.driver.gen_layers(lottie["layers"], root, layer_itr-1)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\driver.py", line 82, in gen_layers
        itr)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\group.py", line 85, in gen_layer_group
        asset = add_precomp_asset(settings.lottie_format["assets"][-1], canvas[0], len(canvas[0]))
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\sources\precomp.py", line 26, in add_precomp_asset
        layers.driver.gen_layers(lottie["layers"], root, layer_itr-1)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\driver.py", line 82, in gen_layers
        itr)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\layers\group.py", line 76, in gen_layer_group
        gen_helpers_transform(lottie["ks"], layer.get_layer(), pos[0], anchor[0], scale[0], angle[0], opacity[0])
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\helpers\transform.py", line 53, in gen_helpers_transform
        index.inc())
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\properties\multiDimensionalKeyframed.py", line 32, in gen_properties_multi_dimensional_keyframed
        gen_properties_offset_keyframe(lottie["k"], animated, i)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\properties\offsetKeyframe.py", line 353, in gen_properties_offset_keyframe
        cur_pos = parse_position(animated, i)
      File "G:\Program Files\Synfig\share\synfig\plugins\lottie-exporter\common\misc.py", line 90, in parse_position
        pos = [float(animated[i][0][0].text),
    ValueError: could not convert string to float: 
    

    and it's seeming to fail on this part of the xml:

    <animated type="vector">
      <waypoint time="0s" before="constant" after="constant"><add type="vector">
                            <lhs>
                              <vector>
                                <x>0.0000000000</x>
                                <y>0.0000000000</y>
                              </vector>
                            </lhs>
                            <rhs>
                              <vector>
                                <x>0.0000000000</x>
                                <y>0.0000000000</y>
                              </vector>
                            </rhs>
                            <scalar>
                              <real value="1.0000000000"/>
                            </scalar>
                          </add>
                        </waypoint>
      <waypoint time="0.1s" before="constant" after="constant"><add type="vector">
                            <lhs>
                              <vector>
                                <x>0.0000000000</x>
                                <y>0.0000000000</y>
                              </vector>
                            </lhs>
                            <rhs>
                              <vector>
                                <x>0.0000000000</x>
                                <y>0.0000000000</y>
                              </vector>
                            </rhs>
                            <scalar>
                              <real value="1.0000000000"/>
                            </scalar>
                          </add>
                        </waypoint>
    </animated>
    
  25. AnishGG commented on Jul 20, 2019

    @AnishGG
    Member

    <add type="vector">

    Convert methods like add are not supported yet. These are yet to be implemented.

  26. morevnaproject commented on Feb 7, 2020

    @morevnaproject
    Member
  27. ohlr commented on Mar 3, 2020

    @ohlr

    Two things I noticed:

    1. framerate has an impact on filesize but no impact on the framerate when viewed in the browser(chrome).
    2. In firefox only the animated frames are shown independent of framerate.
  28. AnishGG commented on Mar 3, 2020

    @AnishGG
    Member
    1. Yes, this is expected, as the shapes and outlines are exported frame by frame using the most basic layer of Lottie, hence increasing the size of the file. This might also lead to a lag in animation on larger displays/screens.
    2. I have been using firefox and chrome both for testing but did not face this issue yet. Could you raise an issue mentioning the firefox version as well as the .sif file used.
  29. ohlr commented on Mar 3, 2020

    @ohlr

    Thanks for the quick response. I realized point 2 is mainly an issue with large/complex files. I think Firefox is just not as good/fast in rendering.

  30. fire commented on Feb 14, 2021

    @fire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AssignedFeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions