This is a simple, very experimental Rust library that makes a system call to FFmpeg
to generate an animated GIF from a video path.
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).
- The library assumes that the system has
ffmpeg version 5.0-tessus
orffmpeg version 6.0-tessus
installed on its path. You may runffmpeg -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 theSettings::ffmpeg_path
method.
- NOTE: It is now possible to specify the path of the
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.
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.
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.
- 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.
Please feel free to contact me by opening an issue on the repository if you have any questions, issues or suggestions for this project.
I am releasing this project under the MIT License.