CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-bytedeco--ffmpeg

JavaCPP bindings for FFmpeg multimedia framework providing comprehensive Java access to audio/video encoding, decoding, filtering, and format conversion

Pending
Overview
Eval results
Files

device-io.mddocs/

Device I/O

Device enumeration and access for cameras, microphones, and other multimedia input/output devices across platforms using FFmpeg's libavdevice.

Capabilities

Device Enumeration

Device Discovery

/**
 * List devices for input format
 * @param s Format context
 * @param device_list Pointer to receive device list
 * @return >= 0 on success
 */
int avdevice_list_devices(AVFormatContext s, AVDeviceInfoList device_list);

/**
 * List input sources for device
 * @param device Input format
 * @param device_name Device name (optional)
 * @param device_options Device options (optional)
 * @param device_list Pointer to receive device list
 * @return >= 0 on success
 */
int avdevice_list_input_sources(AVInputFormat device, String device_name,
    AVDictionary device_options, AVDeviceInfoList device_list);

/**
 * List output sinks for device
 * @param device Output format
 * @param device_name Device name (optional)
 * @param device_options Device options (optional)
 * @param device_list Pointer to receive device list
 * @return >= 0 on success
 */
int avdevice_list_output_sinks(AVOutputFormat device, String device_name,
    AVDictionary device_options, AVDeviceInfoList device_list);

/**
 * Free device list
 * @param device_list Device list to free
 */
void avdevice_free_list_devices(AVDeviceInfoList device_list);

Usage Example:

import org.bytedeco.ffmpeg.avdevice.*;
import org.bytedeco.ffmpeg.avformat.*;
import static org.bytedeco.ffmpeg.global.avdevice.*;
import static org.bytedeco.ffmpeg.global.avformat.*;

// Initialize device library
avdevice_register_all();

// Find video4linux2 input format (Linux)
AVInputFormat v4l2Format = av_find_input_format("v4l2");
if (v4l2Format != null) {
    AVDeviceInfoList deviceList = new AVDeviceInfoList();
    int result = avdevice_list_input_sources(v4l2Format, null, null, deviceList);
    
    if (result >= 0) {
        System.out.println("Found " + deviceList.nb_devices() + " video devices:");
        for (int i = 0; i < deviceList.nb_devices(); i++) {
            AVDeviceInfo device = deviceList.devices(i);
            System.out.println("Device: " + device.device_name().getString());
            System.out.println("Description: " + device.device_description().getString());
        }
        avdevice_free_list_devices(deviceList);
    }
}

Device Opening

Device Access

/**
 * Register all device formats
 */
void avdevice_register_all();

/**
 * Send control message to device
 * @param s Format context
 * @param type Message type
 * @param data Message data
 * @param data_size Data size
 * @return >= 0 on success
 */
int avdevice_dev_to_app_control_message(AVFormatContext s, int type, Pointer data, long data_size);

/**
 * Receive control message from device
 * @param s Format context
 * @param type Message type
 * @param data Message data
 * @param data_size Data size
 * @return >= 0 on success
 */
int avdevice_app_to_dev_control_message(AVFormatContext s, int type, Pointer data, long data_size);

Platform-Specific Devices

Common Device Names

// Linux (Video4Linux2)
"v4l2"          // Video capture devices
"alsa"          // Audio capture/playback
"pulse"         // PulseAudio

// Windows
"dshow"         // DirectShow devices
"gdigrab"       // Screen capture
"wasapi"        // Windows Audio Session API

// macOS
"avfoundation"  // AVFoundation devices
"qtkit"         // QuickTime Kit (deprecated)

// Cross-platform
"lavfi"         // Libavfilter virtual devices
"sdl"           // SDL output

Data Structures

Device Information

/**
 * Device information structure
 */
class AVDeviceInfo extends Pointer {
    /** Device name/identifier */
    BytePointer device_name();
    
    /** Human-readable description */
    BytePointer device_description();
    
    /** Media types supported */
    IntPointer media_types();
    
    /** Number of media types */
    int nb_media_types();
}

/**
 * List of devices
 */
class AVDeviceInfoList extends Pointer {
    /** Array of device info */
    PointerPointer devices();
    
    /** Number of devices */
    int nb_devices();
    
    /** Default device index */
    int default_device();
}

Constants

Device Types

// Media types for devices
int AVMEDIA_TYPE_VIDEO = 0;      // Video devices
int AVMEDIA_TYPE_AUDIO = 1;      // Audio devices
int AVMEDIA_TYPE_DATA = 2;       // Data devices

Install with Tessl CLI

npx tessl i tessl/maven-org-bytedeco--ffmpeg

docs

audio-processing.md

codec-operations.md

command-line-tools.md

constants-enums.md

cryptographic-security.md

device-io.md

format-handling.md

hardware-acceleration.md

index.md

media-filtering.md

postproc.md

scaling-conversion.md

tile.json