{"id":15941446,"url":"https://github.com/imager-io/ffmpeg-dev-rs","last_synced_at":"2025-10-19T03:31:16.792Z","repository":{"id":55967698,"uuid":"226736667","full_name":"imager-io/ffmpeg-dev-rs","owner":"imager-io","description":"Rust - Self Contained FFmpeg Bindings","archived":false,"fork":false,"pushed_at":"2020-12-03T21:15:30.000Z","size":29870,"stargazers_count":53,"open_issues_count":6,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-29T08:04:14.877Z","etag":null,"topics":["ffmpeg","ffmpeg-wrapper","rust","rust-ffi","rust-ffi-bindings"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ffmpeg-dev","language":"C","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/imager-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-08T21:48:28.000Z","updated_at":"2024-12-29T10:35:59.000Z","dependencies_parsed_at":"2022-08-15T10:31:07.980Z","dependency_job_id":null,"html_url":"https://github.com/imager-io/ffmpeg-dev-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imager-io%2Fffmpeg-dev-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imager-io%2Fffmpeg-dev-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imager-io%2Fffmpeg-dev-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imager-io%2Fffmpeg-dev-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imager-io","download_url":"https://codeload.github.com/imager-io/ffmpeg-dev-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237062174,"owners_count":19249017,"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":["ffmpeg","ffmpeg-wrapper","rust","rust-ffi","rust-ffi-bindings"],"created_at":"2024-10-07T07:04:18.809Z","updated_at":"2025-10-19T03:31:15.757Z","avatar_url":"https://github.com/imager-io.png","language":"C","readme":"# WARNING\n\nNot recommend for beginners. This library isn’t safe nor idiomatic rust, a consequence offering direct bindings to the FFmpeg C APIs. \n\nFurthermore:\n\n* this library will complicate compilation\n* this library will only be convenient for experienced Rust and C devs\n\n# About\nDirect, unobscured and self contained FFmpeg (sys) bindings.\n\nBy self contained I mean:\n* Does not require or link against any FFmpeg system dependencies.\n* Does not require a network connection for building.\n\n**The FFmpeg bindings now include doc comments, including struct fields!** See [here](https://docs.rs/ffmpeg-dev/0.2.2/ffmpeg_dev/sys/avcodec/struct.AVCodec.html).\n\n## Example\n\n```rust\nlet input_path_cstr = std::ffi::CString::new(\"path/to/source.mp4\").unwrap();\n\n// Open an e.g. MP4 file\navformat_open_input(\n    \u0026mut ifmt_ctx,\n    input_path_cstr.as_ptr(),\n    std::ptr::null_mut(),\n    std::ptr::null_mut(),\n);\navformat_find_stream_info(ifmt_ctx, std::ptr::null_mut());\n\n// Print info about the loaded file\nav_dump_format(\n    ifmt_ctx,\n    0,\n    input_path_cstr.as_ptr(),\n    0,\n);\n```\n\nFor the uninitiated, the std includes lots of convenient ffi related utilities. E.g. using `std::slice::from_raw_parts`:\n```rust\nuse ffmpeg_dev::sys::{\n    AVMediaType_AVMEDIA_TYPE_VIDEO as AVMEDIA_TYPE_VIDEO,\n    AVMediaType_AVMEDIA_TYPE_AUDIO as AVMEDIA_TYPE_AUDIO,\n};\nlet ifmt_ctx: AVFormatContext = *ifmt_ctx;\nlet nb_streams = (*ifmt_ctx).nb_streams as usize;\n\n// Extract video/audio/etc. streams from our mp4 file.\nlet streams = std::slice::from_raw_parts((*ifmt_ctx).streams, nb_streams)\n    .iter()\n    .map(|x| (*x).as_ref().expect(\"not null\"))\n    .collect::\u003cVec\u003c\u0026AVStream\u003e\u003e();\n\nfor (index, stream_ptr) in streams.iter().enumerate() {\n    let codecpar = *stream_ptr.codecpar;\n    if codecpar.codec_type == AVMEDIA_TYPE_AUDIO {\n        println!(\"found audio stream at index {}\", index);\n    } else if codecpar.codec_type == AVMEDIA_TYPE_VIDEO {\n        println!(\"found video stream at index {}\", index);\n    }\n}\n```\n\n## Stability\nAPI bindings should be **practically** stable now.\n\n## Internal Behavior\n\nBy default the debug or dev builds compile FFmpeg without optimizations, this is for the purpose of speeding up compilation. Compiling on release mode or setting `opt-level` \u003e 1 will disable this behavior.\n\n# LICENSE WARNING\n\u003e I’m not a lawyer, furthermore I really don’t understand software licenses.\n* This codebase is MIT.\n* At compile time, this library builds and statically links against LGPL code.\n    * This is for the purpose of being self contained, without burdening any library consumers with dependency issues.\n\nHopefully one day the rust ecosystem will get a decent FFmpeg alternative for e.g. container muxing/demuxing.\n\n# Future\nIt would be interesting to experiment with compiling FFmpeg to WebAssembly. Perhaps as an alternative to static linking, if a local version isn’t available it could link to a remote lib over the network.\n\n# Examples\n\n```shell\n$ cargo run --example h264_video_dec\n```\n\n## Added as of this writing\n* `./examples/remux.rs`\n* `./examples/h264_video_dec.rs`\n\n# Miscellaneous\n\n## RLS - Editor/IDE Issues\n\nFor some reason (as of this writing) RLS has issues with multiple versions of `ffmpeg-dev` downloaded (under `target`). If there’s something I can fix on my side I’m happy to implement such changes. For now I’m just resorting my deleting the cache folder whenever I update `ffmpeg-dev`.\n\n## Miscellaneous Links:\n* [FFmpeg docs overview](https://ffmpeg.org/documentation.html)\n* [FFmpeg C API documentation](https://ffmpeg.org/doxygen/trunk/index.html)\n* [FFmpeg C Examples](https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples) (pretty easy to convert to rust in my experience)\n* [Rust docs](https://docs.rs/ffmpeg-dev)\n\n### Sample or Test Content\n\n* [sintel_trailer-1080p.mp4](https://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4)\n* `./assets/test/test.h264` - heavily compressed version of the video stream from `sintel_trailer-1080p.mp4`. This is a raw H264 encoded video binary.\n\n\u003chr/\u003e\n\nBuilt for [Imager](https://imager.io) - Site performance tools for efficiently distributing media on the web.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimager-io%2Fffmpeg-dev-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimager-io%2Fffmpeg-dev-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimager-io%2Fffmpeg-dev-rs/lists"}