{"id":18659422,"url":"https://github.com/gnurou/v4l2r","last_synced_at":"2025-04-05T15:06:02.639Z","repository":{"id":37762379,"uuid":"257308848","full_name":"Gnurou/v4l2r","owner":"Gnurou","description":"Rust bindings for V4L2","archived":false,"fork":false,"pushed_at":"2025-03-21T01:01:07.000Z","size":1090,"stargazers_count":29,"open_issues_count":11,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T14:08:58.984Z","etag":null,"topics":["linux","rust","v4l2","v4l2-m2m"],"latest_commit_sha":null,"homepage":"","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/Gnurou.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-20T14:36:08.000Z","updated_at":"2025-03-21T01:01:11.000Z","dependencies_parsed_at":"2024-01-29T03:26:16.078Z","dependency_job_id":"55c37d19-e179-4a03-b315-6909cd6497df","html_url":"https://github.com/Gnurou/v4l2r","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gnurou%2Fv4l2r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gnurou%2Fv4l2r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gnurou%2Fv4l2r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gnurou%2Fv4l2r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gnurou","download_url":"https://codeload.github.com/Gnurou/v4l2r/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353731,"owners_count":20925329,"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":["linux","rust","v4l2","v4l2-m2m"],"created_at":"2024-11-07T07:36:53.720Z","updated_at":"2025-04-05T15:06:02.617Z","avatar_url":"https://github.com/Gnurou.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust bindings for V4L2\n\n[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Build Status](https://github.com/Gnurou/v4l2r/actions/workflows/rust.yml/badge.svg)](https://github.com/Gnurou/v4l2r/actions)\n[![Crates.io](https://img.shields.io/crates/v/v4l2r.svg)](https://crates.io/crates/v4l2r)\n[![dependency status](https://deps.rs/repo/github/Gnurou/v4l2r/status.svg)](https://deps.rs/repo/github/Gnurou/v4l2r)\n[![Documentation](https://docs.rs/v4l2r/badge.svg)](https://docs.rs/v4l2r/)\n\nThis is a work-in-progress library to implement safe Rust bindings and high-level\ninterfaces for V4L2.\n\nCurrently the following is implemented:\n\n- Safe low-level abstractions to manage `OUTPUT` and `CAPTURE` queues, as well as\n  buffers allocation/queueing/dequeuing for `MMAP`, `USERPTR` and `DMABUF` memory\n  types,\n- High-level abstraction of the [stateful video decoder\n  interface](https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-decoder.html),\n- High-level abstraction of the [stateful video encoder\n  interface](https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-encoder.html),\n- C FFI for using the video decoder interface from C programs.\n\nThe library provides several levels of abstraction over V4L2:\n\n- At the lowest level is a very thin layer over the V4L2 ioctls, that stays as\n  close as possible to the actual kernel API while adding extra safety and\n  removing some of the historical baggage like the difference in format for\n  single-planar and multi-planar queues.\n\n- A higher-level abstraction exposes devices, queues, and other V4L2 concepts as\n  strongly typed objects. The goal here is to provide an nice-to-use interface\n  that remains generic enough to be used for any kind of V4L2 device.\n\n- Finally, more specialized abstractions can be used by applications for\n  performing specific tasks, like decoding a video using hardware acceleration.\n  For these abstractions, a C FFI is usually provided so their use is not\n  limited to Rust.\n\nDependencies shall be kept to a minimum: this library talks directly to the\nkernel using ioctls, and only depends on a few small, well-established crates.\n\n## Project Layout\n\n`lib` contains the Rust library (`v4l2r`), including the thin `ioctl`\nabstraction, the more usable `device` abstraction, and task-specific modules for\ne.g. video decoding and encoding.\n\n`ffi` contains the C FFI (`v4l2r-ffi`) which is currently exposed as a static\nlibrary other projects can link against. A `v4l2r.h` header file with the public\nAPI is generated upon build.\n\n## Build options\n\n`cargo build` will attempt to generate the V4L2 bindings from\n`/usr/include/linux/videodev2.h` by default. The `V4L2R_VIDEODEV2_H_PATH`\nenvironment variable can be set to a different location that contains a\n`videodev2.h` file if you need to generate the bindings from a different\nlocation.\n\n## How to use\n\nCheck `lib/examples/vicodec_test/device_api.rs` for a short example of how to\nuse the `device`-level interface, or `lib/examples/vicodec_test/ioctl_api.rs`\nfor the same example using the lower-level `ioctl` API. Both examples encode\ngenerated frames into the `FWHT` format using the `vicodec` kernel driver\n(which must be inserted beforehand, using e.g. `modprobe vicodec\nmultiplanar=1`).\n\nYou can try these examples with\n\n    cargo run --example vicodec_test -- /dev/video0\n\nfor running the `device` API example, or\n\n    cargo run --example vicodec_test -- /dev/video0 --use_ioctl\n\nfor the `ioctl` example, assuming `/dev/video0` is the path to the `vicodec`\nencoder.\n\n`lib/examples/fwht_encoder` contains another example program implementing a\nhigher-level vicodec encoder running in its own thread. It can be run as\nfollows:\n\n    cargo run --example fwht_encoder -- /dev/video0 --stop_after 20 --save test_encoder.fwht\n\nThis invocation will encode 20 generated frames and save the resulting stream in\n`test_encoder.fwht`. Pass `--help` to the program for further options.\n\n`lib/examples/simple_decoder` is a decoder example able to decode the streams\nproduced by the `fwht_encoder` example above, as well as simple Annex-B H.264\nstreams. For instance, to decode the FWHT stream we just created above:\n\n    cargo run --example simple_decoder -- test_encoder.fwht /dev/video1 --save test_decoder.bgr\n\n`test_decoder.bgr` can be checked with e.g.\n[YUView](https://github.com/IENT/YUView). The format will be 640x480 BGR, as\nreported by the decoding program.\n\nFinally, `ffi/examples/c_fwht_decode/` contains a C program demonstrating how\nto use the C FFI to decode a FWHT stream. See the `Makefile` in that directory\nfor build and use instructions. The program is purely for demonstration\npurposes of the C FII: it is hardcoded to decode the `sample.fwht` file in the\nsame directory and doesn't support any other output.\n\n## Using in Android\n\n`Android.bp` files are provided that should work on AOSP \u003e= 15. Just check this\nrepository into `external/rust/crates/v4l2r` and the `libv4l2r` library target\nwill be available.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnurou%2Fv4l2r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnurou%2Fv4l2r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnurou%2Fv4l2r/lists"}