Giter Club home page Giter Club logo

rust-ffmpeg-gif-maker's Introduction

Animated GIF Generator Rust Library Based On A Simple FFmpeg Child Process Wrapper

This is a simple, very experimental Rust library that makes a system call to FFmpeg to generate an animated GIF from a video path.

Disclaimer

This project is still (and will likely always remain) in an early experimental state and was not thoroughly tested. I created this project as part of another toy project (add link here) and stopped as soon as I had a working prototype on my development system (i.e. macOS).

Requirements

  • The library assumes that the system has ffmpeg version 5.0-tessus or ffmpeg version 6.0-tessus installed on its path. You may run ffmpeg -version in a terminal to confirm that. See FFmpeg - Downloads if you need to install it. It is possible that the library will work with other versions, but this was not tested.
    • NOTE: It is now possible to specify the path of the ffmpeg binary using the Settings::ffmpeg_path method.

Feature flags

The library relies on mpsc channels for communication between threads. You can use the default (or, equivalently, no flag at all) feature flag to use std::sync::mpsc channels, or use the tokio feature flag to instead use the tokio::sync::mpsc unbounded channels. The tokio channels are allowed to be sent between asynchronous tasks, which may be a requirement for some applications.

Feature flags and documentation

To view the documentation for the default feature flag (or no flag at all), run cargo doc --features default --no-deps --open in a terminal; to view the documentation for the tokio feature flag, run cargo doc --features tokio --no-deps --open in a terminal.

Examples

The ./examples directory contains two examples that illustrate how the library can be used. One example uses blocking calls on the receiver's end, while the other example uses non blocking calls. Both examples require the tokio flag. The reason for which there is no example using the default flag is simply because I haven't been able to configure the rust-analyzer in a way that it wouldn't complain with examples of both types in the same workspace (i.e. I can only either specify tokio or default in ./.vscode/settings.json).

So, here's how to run the examples:

  • cargo run --features tokio --example how_to
  • cargo run --features tokio --example how_to_async

You could also run them in release mode by adding the --release flag like this: cargo run --release ...

You may also checkout my rust-iced-gif-maker repository for an example illustrating how the library is used in a simple GIF maker GUI application.

Other useful links and references

  • Check out How to Make a GIF from a Video using FFmpeg for a nice article on how to convert a video to an animated GIF using FFmpeg.
  • Using libav*: This webpage literally gave me my idea for this project. To quote them:
    ... Also note that if you just need to convert/transcode videos within your own application, you could make a system call out to the FFmpeg executable to do the heavy lifting for you. You can parse the output for stdout for status information, or use the -progress option to make the output even more parseable.

Contact

Please feel free to contact me by opening an issue on the repository if you have any questions, issues or suggestions for this project.

License

I am releasing this project under the MIT License.

rust-ffmpeg-gif-maker's People

Contributors

bb-301 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.