All Projects → larksuite → rsmpeg

larksuite / rsmpeg

Licence: MIT license
A Rust crate that exposes FFmpeg's power as much as possible.

Programming Languages

rust
11053 projects
shell
77523 projects
GLSL
2045 projects

Projects that are alternatives of or similar to rsmpeg

renderdoc-rs
RenderDoc application bindings for Rust
Stars: ✭ 28 (-92.82%)
Mutual labels:  ffi, bindings
Python Mpv
Python interface to the awesome mpv media player
Stars: ✭ 245 (-37.18%)
Mutual labels:  ffi, bindings
Fruity
Rusty bindings for Apple libraries
Stars: ✭ 72 (-81.54%)
Mutual labels:  ffi, bindings
rust-lang-interop
Rust language interoperability with other languages - C, C++ etc.
Stars: ✭ 53 (-86.41%)
Mutual labels:  ffi, bindings
Rust Bindgen
Automatically generates Rust FFI bindings to C (and some C++) libraries.
Stars: ✭ 2,453 (+528.97%)
Mutual labels:  ffi, bindings
RubyGateway
Embed Ruby in Swift: load Gems, run scripts, call APIs seamlessly in both directions.
Stars: ✭ 108 (-72.31%)
Mutual labels:  bindings
rust-ffi-examples
FFI examples written in Rust
Stars: ✭ 42 (-89.23%)
Mutual labels:  ffi
Rustler
Safe Rust bridge for creating Erlang NIF functions
Stars: ✭ 3,052 (+682.56%)
Mutual labels:  ffi
Pythonnet
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
Stars: ✭ 2,873 (+636.67%)
Mutual labels:  ffi
htaglib
Haskell bindings for TagLib, an audio meta-data library
Stars: ✭ 20 (-94.87%)
Mutual labels:  bindings
tflite native
A Dart interface to TensorFlow Lite (tflite) through dart:ffi
Stars: ✭ 127 (-67.44%)
Mutual labels:  ffi
pedax
Reversi Board with edax, which is the strongest reversi engine.
Stars: ✭ 18 (-95.38%)
Mutual labels:  ffi
samp-rs
SA:MP SDK written in Rust
Stars: ✭ 36 (-90.77%)
Mutual labels:  bindings
swift-tree-sitter
Swift bindings for the tree-sitter parsing library
Stars: ✭ 29 (-92.56%)
Mutual labels:  bindings
Curryrs
Bridge the gap between Haskell and Rust
Stars: ✭ 252 (-35.38%)
Mutual labels:  ffi
DotNetJS
Consume C# in JavaScript with comfort: single-file UMD library, auto-generated 2-way bindings and type definitions
Stars: ✭ 551 (+41.28%)
Mutual labels:  bindings
elixir-ffi
Foreign Function Interface (FFI) for Elixir
Stars: ✭ 52 (-86.67%)
Mutual labels:  ffi
loam
Javascript wrapper for GDAL in the browser
Stars: ✭ 174 (-55.38%)
Mutual labels:  bindings
hoedown
rust bindings for hoedown
Stars: ✭ 16 (-95.9%)
Mutual labels:  bindings
mapbox-ios-binding
Xamarin binding library for Mapbox iOS SDK
Stars: ✭ 15 (-96.15%)
Mutual labels:  bindings

Rsmpeg

Doc Crates.io CI

rsmpeg is a thin&safe layer above the FFmpeg's Rust bindings, it's main goal is safely exposing FFmpeg inner APIs in Rust as much as possible.

Taking advantage of Rust's language design, you can build robust multi-media projects even quicker than using FFmpeg's C API.

Getting started

FFmpeg compilation

To use your first rsmpeg demo, you need to compile your FFmpeg:

  1. https://github.com/ffmpeg/ffmpeg.
  2. https://trac.ffmpeg.org/wiki/CompilationGuide

If you find the compilation complicated, there are some helpful compiling scripts for you (under the utils folder).

To build a FFmpeg with some common parameters: (don't forget to install the build dependencies)

# macOS
zsh utils/mac_ffmpeg.rs
# Linux
bash utils/linux_ffmpeg.rs
# Windows
# You need a Linux machine for cross compiling, then copy the artifact to your
# Windows machine.
bash utils/windows_ffmpeg.rs

Rsmpeg demo

Ensure that you have compiled the FFmpeg.

Start by adding rsmpeg to your Cargo.toml file:

[dependencies]
rsmpeg = "0.11"

Write your simple media file info dumper:

use std::ffi::{CStr, CString};
use std::error::Error;
use rsmpeg::avformat::AVFormatContextInput;

fn dump_av_info(path: &CStr) -> Result<(), Box<dyn Error>> {
    let mut input_format_context = AVFormatContextInput::open(path)?;
    input_format_context.dump(0, path)?;
    Ok(())
}

fn main() {
    dump_av_info(&CString::new("./test.jpg").unwrap()).unwrap();
}

Prepare a simple image in your current folder:

test.jpg

Run with FFMPEG_PKG_CONFIG_PATH set to the pkgconfig file path (Absolute path!) in your artifact folder (xxx/ffmpeg_build/lib/pkgconfig).

# macOS & Linux
export FFMPEG_PKG_CONFIG_PATH=xxx/ffmpeg_build/lib/pkgconfig
# Windows
set FFMPEG_PKG_CONFIG_PATH=xxx/ffmpeg_build/lib/pkgconfig

cargo run

Then it works:

Input #0, image2, from './test.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 1390 kb/s
  Stream #0:0: Video: mjpeg, none, 25 fps, 25 tbr, 25 tbn, 25 tbc

(A single image's duration under 25fps is 0.04s)

You can also put any video or audio file here, this program will dump the media info for you.

Advanced usage

  1. FFmpeg linking: refer to rusty_ffmpeg's documentation for how to use environment variables to statically or dynamically link FFmpeg.

  2. Advanced usage of rsmpeg: Check out the tests and examples folder.

Dependency version

Supported FFmpeg version is 5.1.

Minimum Supported Rust Version is 1.62.0(Stable channel).

Contributors

Thanks for your contributions!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].