{"id":13572466,"url":"https://github.com/larksuite/rsmpeg","last_synced_at":"2025-05-14T06:14:17.618Z","repository":{"id":37855249,"uuid":"366927065","full_name":"larksuite/rsmpeg","owner":"larksuite","description":"A Rust crate that exposes FFmpeg's power as much as possible.","archived":false,"fork":false,"pushed_at":"2025-04-05T06:27:12.000Z","size":104704,"stargazers_count":751,"open_issues_count":10,"forks_count":50,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-12T07:07:32.731Z","etag":null,"topics":["bindings","ffi","ffmpeg","rust","video"],"latest_commit_sha":null,"homepage":"https://docs.rs/rsmpeg/latest/rsmpeg/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larksuite.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-13T03:50:26.000Z","updated_at":"2025-05-07T12:16:06.000Z","dependencies_parsed_at":"2025-04-11T01:03:38.526Z","dependency_job_id":null,"html_url":"https://github.com/larksuite/rsmpeg","commit_stats":{"total_commits":134,"total_committers":8,"mean_commits":16.75,"dds":0.08208955223880599,"last_synced_commit":"589cd36f6a59a4eda0990e0621b6592bffe911f0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larksuite%2Frsmpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larksuite%2Frsmpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larksuite%2Frsmpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larksuite%2Frsmpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larksuite","download_url":"https://codeload.github.com/larksuite/rsmpeg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254083863,"owners_count":22011903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","ffi","ffmpeg","rust","video"],"created_at":"2024-08-01T14:01:23.992Z","updated_at":"2025-05-14T06:14:17.563Z","avatar_url":"https://github.com/larksuite.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Rsmpeg\n\n[![Doc](https://docs.rs/rsmpeg/badge.svg?style=flat-square)](https://docs.rs/rsmpeg)\n[![Crates.io](https://img.shields.io/crates/v/rsmpeg)](https://crates.io/crates/rsmpeg)\n[![CI](https://github.com/larksuite/rsmpeg/workflows/CI/badge.svg?branch=master\u0026style=flat-square)](https://github.com/larksuite/rsmpeg/actions)\n\n`rsmpeg` is a thin\u0026safe layer above the FFmpeg's Rust bindings, it's main goal is safely exposing FFmpeg inner APIs in Rust as much as possible.\n\nTaking advantage of Rust's language design, you can build robust multi-media projects even quicker than using FFmpeg's C API.\n\n## Dependency requirements\n\nSupported FFmpeg versions are `6.*`, `7.*`.\n\nMinimum Supported Rust Version is `1.77.0`(stable channel).\n\n## Getting started\n\n### FFmpeg compilation\n\nTo use your first rsmpeg demo, you need to compile your FFmpeg:\n1. \u003chttps://github.com/ffmpeg/ffmpeg\u003e.\n2. \u003chttps://trac.ffmpeg.org/wiki/CompilationGuide\u003e\n\nIf you find the compilation complicated, there are some helpful compiling scripts for you (under the `utils` folder).\n\nTo build a FFmpeg with some common parameters: (don't forget to install the build dependencies)\n\n```bash\n# macOS\nzsh utils/mac_ffmpeg.rs\n# Linux\nbash utils/linux_ffmpeg.rs\n# Windows\n# You need a Linux machine for cross compiling, then copy the artifact to your\n# Windows machine.\nbash utils/windows_ffmpeg.rs\n```\n\nThese scripts build latest stable FFmpeg by default. You can build specific FFmpeg version explicitly:\n\n```bash\n# macOS \u0026 FFmpeg 7.0\nzsh utils/mac_ffmpeg.rs release/7.0\n```\n\n### Compiling FFmpeg through cargo-vcpkg\n\nUsing [vcpkg](https://github.com/microsoft/vcpkg) to manage ffmpeg dependencies may be easier as all the configuration is included in your `Cargo.toml`. \nThis is especially handy for users who download your project as they can build all necessary dependencies by running a single command.\nCare that by using this method building ffmpeg may take a lot of time, although after the first time the generated library files may be cached. \n\nTo begin, install the [cargo-vcpkg](https://github.com/mcgoo/cargo-vcpkg) tool:\n\n```bash\ncargo install cargo-vcpkg\n```\n\nAdd vcpkg dependencies:\n\n```rust\n[package.metadata.vcpkg]\ndependencies = [\"ffmpeg\"]\ngit = \"https://github.com/microsoft/vcpkg\"\nrev = \"4a600e9\" // Although it is possible to link to the master branch of vcpkg, it may be better to fix a specific revision in order to avoid unwanted breaking changes.\n```\n\n\nYou may want to specify a subset of features based on the modules of FFmpeg you need. For instance, if your code makes use of x264 and VPX codecs the dependency should look like:\n\n```rust\ndependencies = [\"ffmpeg[x264,vpx]\"]\n```\n\nIn some cases you may need to specify the triplet and/or additional dependencies. For instance, on Windows the above section would look similar to the following:\n\n```rust\n[package.metadata.vcpkg]\ndependencies = [\"ffmpeg[x264,vpx]:x64-windows-static-md\"]\ngit = \"https://github.com/microsoft/vcpkg\"\nrev = \"4a600e9\"\n```\n\nThe features may vary depending on your application, in our case to build the demo we need x264. \n\nSetup the environment: \n\n```bash\n# *nix (the path of the folder named after the triplet may change)\nexport FFMPEG_PKG_CONFIG_PATH=${PWD}/target/vcpkg/installed/x64-linux/lib/pkgconfig\n# Windows(CMD)\nset FFMPEG_PKG_CONFIG_PATH=%CD%\\target\\vcpkg\\installed\\x64-windows-static-md\\lib\\pkgconfig\n# Windows(PowerShell)\n$env:FFMPEG_PKG_CONFIG_PATH=\"$(($PWD).path)\\target\\vcpkg\\installed\\x64-windows-static-md\\lib\\pkgconfig\"\n```\n\nRun the vcpkg build:\n```bash\ncargo vcpkg --verbose build\n```\nThe `--verbose` option is not mandatory but may help to recognize any error in case the build fails.\n\nAfter those steps you are able to build and run your project. A full working example with the demo code presented in the next section is available at https://github.com/aegroto/rsmpeg-vcpkg-demo.\n\n\n### Rsmpeg demo\n\nEnsure that you have compiled the FFmpeg.\n\nStart by adding `rsmpeg` to your `Cargo.toml` file:\n\n```toml\n[dependencies]\n# Add this if you are using ffmpeg 6.*\nrsmpeg = { version = \"0.15.1\", default-features = false, features = [\"ffmpeg6\"] }\n# Add this if you are using ffmpeg 7.* (feature `ffmpeg7` is enabled by default)\nrsmpeg = \"0.15.1\"\n```\n\nWrite your simple media file info dumper:\n\n```rust\nuse std::ffi::{CStr, CString};\nuse std::error::Error;\nuse rsmpeg::avformat::AVFormatContextInput;\n\nfn dump_av_info(path: \u0026CStr) -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let mut input_format_context = AVFormatContextInput::open(path, None, \u0026mut None)?;\n    input_format_context.dump(0, path)?;\n    Ok(())\n}\n\nfn main() {\n    dump_av_info(\u0026CString::new(\"./test.jpg\").unwrap()).unwrap();\n}\n```\n\nPrepare a simple image in your current folder:\n\n![test.jpg](./assets/mountain.jpg)\n\nRun with `FFMPEG_PKG_CONFIG_PATH` set to the pkgconfig file path (**Absolute path!**) in your artifact folder (`xxx/ffmpeg_build/lib/pkgconfig`).\n\n```bash\n# macOS \u0026 Linux\nexport FFMPEG_PKG_CONFIG_PATH=xxx/ffmpeg_build/lib/pkgconfig\n# Windows\nset FFMPEG_PKG_CONFIG_PATH=xxx/ffmpeg_build/lib/pkgconfig\n\ncargo run\n```\n\nThen it works:\n\n```\nInput #0, image2, from './test.jpg':\n  Duration: 00:00:00.04, start: 0.000000, bitrate: 1390 kb/s\n  Stream #0:0: Video: mjpeg, none, 25 fps, 25 tbr, 25 tbn, 25 tbc\n```\n\n(A single image's duration under 25fps is 0.04s)\n\nYou can also put any video or audio file here, this program will dump the media info for you.\n\n## Advanced usage\n\n1. FFmpeg linking: refer to [`rusty_ffmpeg`](https://github.com/CCExtractor/rusty_ffmpeg)'s documentation for how to use environment variables to statically or dynamically link FFmpeg.\n\n2. Advanced usage of rsmpeg: Check out the `tests` folder.\n\n## Contributors\n\nThanks for your contributions!\n\n+ [@vnghia](https://github.com/vnghia)\n+ [@nxtn](https://github.com/nxtn)\n+ [@aegroto](https://github.com/aegroto)\n+ [@nanpuyue](https://github.com/nanpuyue)\n+ [@imxood](https://github.com/imxood)\n+ [@FallingSnow](https://github.com/FallingSnow)\n+ [@Jamyw7g](https://github.com/Jamyw7g)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarksuite%2Frsmpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarksuite%2Frsmpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarksuite%2Frsmpeg/lists"}