{"id":28493544,"url":"https://github.com/dromara/rsmedia","last_synced_at":"2025-10-27T19:07:36.972Z","repository":{"id":259155351,"uuid":"868847488","full_name":"dromara/rsmedia","owner":"dromara","description":"audio/video toolkit based FFmpeg 6.x, 7.x supported for multimedia with Hardware Acceleration.","archived":false,"fork":false,"pushed_at":"2025-06-16T12:51:47.000Z","size":4787,"stargazers_count":38,"open_issues_count":0,"forks_count":5,"subscribers_count":0,"default_branch":"rsmpeg","last_synced_at":"2025-07-05T10:17:44.469Z","etag":null,"topics":["audio","audio-streaming","encoder-decoder","ffmpeg","hardware-acceleration","hardware-accelerator","media","multimedia","mux","muxer","video","video-streaming"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dromara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-10-07T09:38:34.000Z","updated_at":"2025-07-03T00:48:45.000Z","dependencies_parsed_at":"2024-11-19T10:25:03.182Z","dependency_job_id":"e84e14c1-6621-4ec5-be51-dd8104964442","html_url":"https://github.com/dromara/rsmedia","commit_stats":null,"previous_names":["phial3/rsmedia","dromara/rsmedia"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dromara/rsmedia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dromara%2Frsmedia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dromara%2Frsmedia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dromara%2Frsmedia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dromara%2Frsmedia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dromara","download_url":"https://codeload.github.com/dromara/rsmedia/tar.gz/refs/heads/rsmpeg","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dromara%2Frsmedia/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264259686,"owners_count":23580859,"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":["audio","audio-streaming","encoder-decoder","ffmpeg","hardware-acceleration","hardware-accelerator","media","multimedia","mux","muxer","video","video-streaming"],"created_at":"2025-06-08T09:09:16.849Z","updated_at":"2025-10-27T19:07:31.737Z","avatar_url":"https://github.com/dromara.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ccode\u003ersmedia\u003c/code\u003e\n\u003c/h1\u003e\n\nLow / High-level video toolkit based on [rsmpeg](https://github.com/larksuite/rsmpeg).\n\nffmpeg 6.x, 7.x is supported based [rusty_ffmpeg](https://github.com/CCExtractor/rusty_ffmpeg)\n\n## 🎬 Introduction\n\n`rsmedia` is a general-purpose video/audio media library for Rust that uses the\n`libav`-family libraries from `ffmpeg`.\n\nIt aims to provide a stable and Rusty interface to many common media tasks,\nsuch as reading, writing, muxing, encoding, decoding, Picture Quality Enhancement and Image Processing.\n\n## 🛠 S️️tatus\n\n⚠️ This project is still a work-in-progress, and will contain bugs. Some parts\nof the API have not been flushed out yet. Use with caution.\n\nSupported Platforms:\n\n| Platform | Arch    | Linking  | Toolchain   | Build Options | pkg Manager | Support | Notes                          |\n|----------|---------|----------|-------------|---------------|-------------|---------|--------------------------------|\n| Linux    | x86_64  | Static   | GCC/Clang   | Default       | apt, yum    | ✅       | `pkg-config` + `glibc`        |\n|          | x86_64  | Dynamic  | GCC/Clang   | Default       | apt, yum    | ✅       | `pkg-config` + `glibc`        |\n|          | aarch64 | Static   | GCC/Clang   | Default       | apt, yum    | ⚠️      | `pkg-config` + `glibc`        |\n|          | aarch64 | Dynamic  | GCC/Clang   | Default       | apt, yum    | ⚠️      | `pkg-config` + `glibc`        |\n| macOS    | x86_64  | Static   | Apple Clang | ⚠️            | Homebrew    | ❌       | `pkg-config`                  |\n|          | x86_64  | Dynamic  | Apple Clang | Default       | Homebrew    | ✅       | `pkg-config`                  |\n|          | aarch64 | Static   | Apple Clang | ⚠️            | Homebrew    | ❌       | `pkg-config`                  |\n|          | aarch64 | Dynamic  | Apple Clang | Default       | Homebrew    | ✅       | `pkg-config`                  |\n| Windows  | x86_64  | Static   | MSVC/MinGW  | `+crt-static` | vcpkg       | ✅       | `vs-2022` + `llvm` + `clang`  |\n|          | x86_64  | Dynamic  | MSVC/MinGW  | Default       | vcpkg       | ✅       | `vs-2022` + `llvm` + `clang`  |\n|          | aarch64 | Static   | MSVC        | `+crt-static` | vcpkg       | ✅       | `vs-2022` + `llvm` + `clang`  |\n|          | aarch64 | Dynamic  | MSVC        | Default       | vcpkg       | ✅       | `vs-2022` + `llvm` + `clang`  |\n\nHardware acceleration:\n\n| API        | Platform  | Arch    | Hardware Requirements          | Support         | Notes                    |\n|------------|-----------|---------|--------------------------------|-----------------|--------------------------|\n| VDPAU      | Linux     | x86_64  | NVIDIA GPU                     | ⚠️ Full         | `nvidia-vdpau-driver`    |\n|            | Linux     | aarch64 | NVIDIA GPU                     | ⚠️ Full         | Jetson AGX support       |\n| CUDA       | Linux     | x86_64  | NVIDIA GPU (Compute ≥3.5)      | ✅ Full          | Container-ready          |\n|            | Linux     | aarch64 | NVIDIA GPU (Compute ≥3.5)      | ✅ Full          | Jetson/Orin              |\n|            | Windows   | x86_64  | NVIDIA GPU (Compute ≥3.5)      | ✅ Full          |                          |\n|            | Windows   | aarch64 | NVIDIA GPU (Compute ≥3.5)      | ⚠️ Partial      | Limited driver support   |\n| VAAPI      | Linux     | x86_64  | Intel/AMD/Integrated GPU       | ⚠️ Full         | `intel-media-driver`     |\n|            | Linux     | aarch64 | Mali/AMD GPU                   | ⚠️ Partial      | Kernel 5.15+ required    |\n| DXVA2      | Windows   | x86_64  | DX11-compatible GPU            | ⚠️ Full         | WDDM 2.0+                |\n| QSV        | Linux     | x86_64  | Intel iGPU (≥6th Gen)          | ⚠️ Full         | `intel-media-va-driver`  |\n|            | Windows   | x86_64  | Intel iGPU (≥6th Gen)          | ⚠️ Full         | Intel Media SDK          |\n| TOOLBOX    | macOS     | x86_64  | Intel GPU                      | ✅ Native        | macOS 10.13+             |\n|            | macOS     | aarch64 | Apple Silicon GPU (M series)   | ✅ Native        |                          |\n| D3D11VA    | Windows   | x86_64  | DX11-compatible GPU            | ⚠️ Full         |                          |\n|            | Windows   | aarch64 | DX11-compatible GPU            | ⚠️ Partial      | ARM64 Windows 11         |\n| DRM        | Linux     | x86_64  | AMD/NVIDIA GPU                 | ⚠️ Partial      | `libdrm` + KMS           |\n|            | Linux     | aarch64 | Mali GPU                       | ⚠️ Partial      |                          |\n| MEDIACODEC | Android   | arm64   | Hardware decoder               | ⚠️ Full         | Android 12+              |\n| D3D12VA    | Windows   | x86_64  | DX12-compatible GPU            | ⚠️ Experimental | FFmpeg 7.0+              |\n|            | Windows   | aarch64 | DX12-compatible GPU            | ⚠️ Experimental | FFmpeg 7.0+              |\n\n\u003e **Note:**\n- ✅ Full support / Successful\n- ❌ Not support / Failed\n- ⚠️ Partially supported / Not clear\n\n## Wiki\n\n- [Home](https://github.com/dromara/rsmedia/wiki/rsmedia-Home)\n- [hardware-acceleration](https://github.com/dromara/rsmedia/wiki/rsmedia-Home#hardware-acceleration)\n\n## FFmpeg Documentation\n\n- [Official Documentation](https://ffmpeg.org/documentation.html)\n- [FFmpeg WIKI](https://trac.ffmpeg.org/wiki)\n- [Hardware acceleration](https://trac.ffmpeg.org/wiki/HWAccelIntro)\n- [FFmpeg API Documentation](https://ffmpeg.org/doxygen/trunk/)\n\n## FFI bindingss\n\n- [rusty_ffmpeg](https://github.com/CCExtractor/rusty_ffmpeg)\n- [rust-ffmpeg](https://github.com/meh/rust-ffmpeg/)\n- [ffmpeg-sys-next](https://github.com/zmwangx/rust-ffmpeg-sys)\n- [ffmpeg-the-third](https://github.com/shssoichiro/ffmpeg-the-third)\n\n## See also\n\u003e\n\u003e \u003chttps://github.com/zmwangx/rust-ffmpeg\u003e\n\u003e\n\u003e \u003chttps://github.com/oddity-ai/video-rs\u003e\n\u003e\n\u003e \u003chttps://github.com/YeautyYE/ez-ffmpeg\u003e\n\u003e \n\u003e \u003chttps://github.com/gcanat/video_reader-rs\u003e\n\u003e\n\u003e \u003chttps://github.com/angelcam/rust-ac-ffmpeg\u003e\n\u003e\n\u003e \u003chttps://github.com/larksuite/rsmpeg\u003e\n\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 `examples` folder.\n\n## ⚙️ Setup\n\n- (1) static linking with pkg-config(unix) or vcpkg(windows):\n```bash\n## (unix recommended):\nexport FFMPEG_DIR=/path/to/ffmpeg\nexport FFMPEG_INCLUDE_DIR=$FFMPEG_DIR/include\nexport FFMPEG_PKG_CONFIG_PATH=$FFMPEG_DIR/lib/pkgconfig\n## (windows recommended):\n## notes: if you install ffmpeg with vcpkg, you can add `$FFMPEG_DIR/bin` to system PATH.\nexport VCPKG_ROOT=/path/to/vcpkg\n```\n\n- (2) dynamic linking\n```bash\nexport FFMPEG_DIR=/path/to/ffmpeg\nexport FFMPEG_INCLUDE_DIR=$FFMPEG_DIR/include\n## manually set dylib path\n## dynamic linking for linux:\nexport FFMPEG_DLL_PATH=$FFMPEG_LIBS_DIR/libffmpeg.so\n## dynamic linking for macos:\nexport FFMPEG_DLL_PATH=$FFMPEG_LIBS_DIR/libffmpeg.dylib\n## dynamic linking for windows:\nexport FFMPEG_DLL_PATH=$FFMPEG_DIR/lib/libffmpeg.dll \n```\n\n## Features\n\n- `ndarray`: enable support to use raw frames with the [`ndarray`](https://github.com/rust-ndarray/ndarray)\n\n- `ffmpeg6`: enable support for `ffmpeg` 6.x.\n\n- `ffmpeg7`: enable support for `ffmpeg` 7.x.\n\n- `link_system_ffmpeg`: unxi system linking ffmpeg with pkg-config.\n\n- `link_vcpkg_ffmpeg`: windows linking ffmpeg with vcpkg.\n\n\u003e usage:\n\u003e\n\u003e - ffmpeg 7.x for unix:\n\u003e\n\u003e ```toml\n\u003e ## default feature is ok for ffmpeg 7.x unix:\n\u003e rsmedia = { git = \"https://github.com/dromara/rsmedia\", branch = \"rsmpeg\", default-features = false, features = [\"ndarray\", \"ffmpeg7\", \"link_system_ffmpeg\"] }\n\u003e ```\n\u003e\n\u003e - ffmpeg 7.x for windows:\n\u003e ```toml\n\u003e rsmedia = { git = \"https://github.com/dromara/rsmedia\", branch = \"rsmpeg\", default-features = false, features = [\"ndarray\", \"ffmpeg7\", \"link_vcpkg_ffmpeg\"] }\n\u003e ```\n\n## 📖 Examples\n\n### 1. Demux and mux a video:\n\n```rust\nfn main() {\n  rsmedia::init().unwrap();\n\n  let input_path = Path::new(\"/tmp/bear.mp4\");\n  let mut demuxer = Demuxer::new(input_path).unwrap();\n\n  // demux and mux all streams frame\n  loop {\n    match demuxer.demux() {\n      Ok(Some((stream_index, frame))) =\u003e {\n        println!(\"stream index:{}, {:?}\", stream_index, frame);\n      }\n      Ok(None) =\u003e {\n        log::info!(\"End of input file\");\n        break;\n      }\n      Err(e) =\u003e {\n        eprintln!(\"Demuxing error: {}\", e);\n        break;\n      }\n    }\n  }\n}\n```\n\n### 2. Decode a video and print the RGB value for the top left pixel:\n\n```rust\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    rsmedia::init()?;\n\n    let source = \"https://img.qunliao.info/4oEGX68t_9505974551.mp4\"\n        .parse::\u003cUrl\u003e()\n        .unwrap();\n\n    let mut decoder = DecoderBuilder::new(MediaType::VIDEO)\n          // decoder with CUDA acceleration\n          // .with_hardware_device(Some(HWDeviceType::CUDA.auto_best_config().unwrap()))\n          // .with_codec_name(Some(\"h264_cuvid\".to_string()))\n          .build_wrapped(source)\n          .context(\"failed to create decoder\")?;\n\n  loop {\n    match decoder.decode::\u003cu8\u003e() {\n      Ok(Some(yuv_frame)) =\u003e {\n        println!(\n          \"decoded frame pts: {}, type: {:?}, format:{:?}\",\n          yuv_frame.pts, yuv_frame.media_type, yuv_frame.format\n        );\n        \n        // processing frame here...\n        // process_frame(yuv_frame)?;\n      }\n      Ok(None) =\u003e {\n        println!(\"Decoder has reached the end of the stream\");\n        break;\n      }\n      Err(e) =\u003e {\n        println!(\"Error decoding frame: {}\", e);\n        break;\n      }\n    }\n  }\n  \n  Ok(())\n}\n```\n\n### 3. Encode a 🌈 video, using `ndarray` to create each frame:\n\n```rust\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n  rsmedia::init().unwrap();\n\n  let output_path = Path::new(\"/tmp/rainbow.mp4\");\n  let mut encoder = EncoderBuilder::new_video(width as usize, height as usize)\n          // encoder with CUDA acceleration\n          // .with_hardware_device(Some(HWDeviceType::CUDA.auto_best_config().unwrap()))\n          // libx264, libx265, h264_nvenc, h264_vaapi\n          // .with_codec_name(Some(\"h264_nvenc\".to_string()))\n          // .with_options(Some(Options::preset_h264_nvenc()))\n          .with_filters(Some(filters))\n          .build_wrapped(output_path)\n          .expect(\"failed to create encoder\");\n\n  let duration: Time = Time::from_nth_of_a_second(24);\n  let mut position = Time::zero();\n\n  for i in 0..256 {\n    // This will create a smooth rainbow animation video!\n    let mut frame = rainbow_frame(width as usize, height as usize, i as f32 / 256.0);\n\n    frame.set_pts(\n      position\n              .aligned_with_rational(encoder.time_base())\n              .into_value()\n              .unwrap(),\n    );\n\n    encoder.encode(frame)?;\n\n    println!(\"Encoded frame {} at position {}\", i, position);\n\n    // Update the current position and add the inter-frame duration to it.\n    position = position.aligned_with(duration).add();\n  }\n\n  encoder.finish()?;\n\n  Ok(())\n}\n\nfn rainbow_frame(p: f32) -\u003e FrameArray {\n  // This is what generated the rainbow effect!\n  // We loop through the HSV color spectrum and convert to RGB.\n  let rgb = colors::hsv_to_rgb(p * 360.0, 100.0, 100.0);\n\n  // This creates a frame with height 720, width 1280 and three channels. The RGB values for each\n  // pixel are equal, and determined by the `rgb` we chose above.\n  FrameArray::from_shape_fn((720, 1280, 3), |(_y, _x, c)| rgb[c])\n}\n```\n\n## 🪲 Debugging\n\nFfmpeg does not always produce useful error messages directly. It is\nrecommended to turn on tracing if you run into an issue to see if there is\nextra information present in the log messages.\n\nAdd the following packages to `Cargo.toml`:\n\n```toml\n[dependencies]\ntracing = \"0.1\"\ntracing-subscriber = \"0.3\"\n```\n\nAnd add the following to your main functions:\n\n```rust\nfn main() {\n    tracing_subscriber::fmt::init();\n\n    // ...\n}\n```\n\nSet the `RUST_LOG` environment variable to display tracing messages:\n\n```sh\nRUST_LOG=video=debug cargo run\n```\n\n## ✨ Credits\n\n`rsmedia` only exists thanks to the following organizations and people:\n\n* All [video-rs contributors](https://github.com/oddity-ai/video-rs/graphs/contributors) for their work!\n* All [rsmpeg contributors](https://github.com/larksuite/rsmpeg) for maintaining.\n* The [FFmpeg project](https://ffmpeg.org/) for `ffmpeg` and the `ffmpeg` libraries.\n\n## ⚖️ License\n\nLicensed under either of\n\n* Apache License, Version 2.0\n  ([LICENSE-APACHE](LICENSE-APACHE.md) or http://www.apache.org/licenses/LICENSE-2.0)\n* MIT license\n  ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdromara%2Frsmedia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdromara%2Frsmedia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdromara%2Frsmedia/lists"}