xcamera 0.1.0 copy "xcamera: ^0.1.0" to clipboard
xcamera: ^0.1.0 copied to clipboard

PlatformLinux

A lightweight Flutter camera plugin for Linux supporting high-performance V4L2 streaming and synchronized H.264/AAC video recording.

XCamera #

pub package Platform Support CI Flutter Dart C++ CMake License: BSD 3-Clause

A high-performance, lightweight Flutter camera plugin built exclusively for Linux platforms.

It uses a Clean Architecture design with Flutter Method Channels, Event Channels, and Flutter Textures to provide efficient real-time camera streaming with low CPU and memory overhead.

Features #

Core Video & Audio Operations

  • Device Discovery & Hotplug Events: Enumerate camera devices and listen to udev connection events in real-time.
  • High-Performance Live Preview: Render real-time camera streams using optimized Flutter Textures (FlPixelBufferTexture).
  • H.264 Video Recording: Capture and encode video in H.264 format with optional AAC audio support into MP4 files.
  • Multi-Backend Streaming: Support for both direct kernel Video4Linux2 (v4l2) and modern PipeWire multimedia framework.

Network & Streaming

  • RTSP & HTTP MJPEG Stream Server: Stream H.264 video over RTSP/TCP or MJPEG over HTTP directly from the local camera.
  • IP Camera Stream Client: Connect to and preview remote RTSP and HTTP network IP cameras using a single client interface.
  • Virtual Camera Output: Stream processed frames to a local v4l2loopback virtual webcam node (e.g. for OBS/Zoom/Teams).

Advanced Hardware & PTZ Controls

  • Hardware V4L2 Controls: Discover and adjust hardware parameters (brightness, contrast, focus, exposure, gain, white balance).
  • Digital Zoom & PTZ Crop: Apply digital zoom (1.0x to 8.0x) with horizontal and vertical panning.
  • Retroactive Pre-Roll Buffering: Maintain an in-memory ring buffer to retroactively save video recorded before pressing record.

Image Processing & Analytics

  • Real-Time Motion Detection: Frame-difference luminance motion analysis with configurable threshold events and snapshots.
  • OSD Watermark & Timestamp: Overlay custom text watermarks and microsecond-accurate timestamps directly onto frames.
  • Image Filters: Low-light CLAHE Night Vision enhancement, Green Screen Chroma Key background removal, and Barrel Fisheye Distortion lens correction.
  • Camera Assist Overlays: Focus Peaking edge highlights, and Zebra exposure lines.

Hardware Acceleration & Telemetry

  • Hardware Acceleration: Native hardware video encoding via VA-API (Intel/AMD) and V4L2 M2M (ARM/SoC), with OpenH264 software fallback.
  • DMA-BUF Export: Export V4L2 video buffers as DMA-BUF file descriptors for zero-copy memory sharing with GPU/Vulkan.
  • Performance Telemetry: Real-time metrics monitoring (FPS, frame drop count, latency, bitrates).

System Prerequisites & Dependencies #

Ensure the following tools and development headers are installed on your Linux host:

Ubuntu / Debian

sudo apt install -y libgtk-3-dev libudev-dev libyuv-dev libopenh264-dev libpipewire-0.3-dev libva-dev

Fedora / RHEL

sudo dnf install -y gtk3-devel systemd-devel libyuv-devel openh264-devel pipewire-devel libva-devel

Arch Linux

sudo pacman -S --needed gtk3 systemd libyuv openh264 pipewire libva

Virtual Camera Support (Optional) #

To use Virtual Camera loopback streaming, install v4l2loopback:

# Ubuntu / Debian
sudo apt install -y v4l2loopback-dkms

# Fedora / RHEL
sudo dnf install -y v4l2loopback

# Arch Linux
sudo pacman -S --needed v4l2loopback-dkms

Load the kernel module:

sudo modprobe v4l2loopback video_nr=10 card_label="Virtual Camera" exclusive_caps=1

Native Implementation Details #

The native Linux C++ plugin is built directly into the application bundle using CMake. It leverages:

  • Video4Linux2 (V4L2): Kernel level video capture and hardware control management.
  • PipeWire: Modern Linux desktop multimedia capture backend.
  • udev: Linux kernel device hotplug tracking.
  • Hardware Acceleration (VA-API / V4L2 M2M): GPU hardware video encoding on Intel, AMD, and ARM SoCs.
  • OpenH264 & libyuv: System-level software video encoding and SIMD pixel color space conversions.
  • Bundled C Libraries (in linux/third_party/):
    • vo-aacenc: Embedded VisualOn AAC encoder for offline audio encoding.
    • miniaudio: Header-only C audio capture engine.
    • minimp4: Header-only C MP4 container multiplexer.
1
likes
160
points
168
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight Flutter camera plugin for Linux supporting high-performance V4L2 streaming and synchronized H.264/AAC video recording.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

cross_file, equatable, flutter, get_it, plugin_platform_interface

More

Packages that depend on xcamera

Packages that implement xcamera