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

media-filtering.mddocs/

Media Filtering

Comprehensive audio and video filtering pipeline for effects, transformations, format conversions, and complex processing graphs using FFmpeg's libavfilter.

Capabilities

Filter Graph Management

Graph Operations

/**
 * Allocate a filter graph
 * @return Allocated filter graph or null on failure
 */
AVFilterGraph avfilter_graph_alloc();

/**
 * Free filter graph and all filters in it
 * @param graph Pointer to filter graph to free
 */
void avfilter_graph_free(AVFilterGraph graph);

/**
 * Check and configure filter graph
 * @param graphctx Filter graph to configure
 * @param log_ctx Logging context
 * @return >= 0 on success
 */
int avfilter_graph_config(AVFilterGraph graphctx, Pointer log_ctx);

/**
 * Create filter instance in graph
 * @param filt_ctx Pointer to receive filter context
 * @param filt Filter definition
 * @param name Instance name
 * @param args Filter arguments
 * @param opaque User data
 * @param graph_ctx Parent graph
 * @return >= 0 on success
 */
int avfilter_graph_create_filter(AVFilterContext filt_ctx, AVFilter filt,
    String name, String args, Pointer opaque, AVFilterGraph graph_ctx);

Filter Discovery

Finding Filters

/**
 * Get filter by name
 * @param name Filter name
 * @return Filter definition or null if not found
 */
AVFilter avfilter_get_by_name(String name);

/**
 * Iterate over all registered filters
 * @param opaque Iterator state
 * @return Next filter or null when done
 */
AVFilter av_filter_iterate(Pointer opaque);

Filter Linking

Connecting Filters

/**
 * Link two filters together
 * @param src Source filter context
 * @param srcpad Source pad index
 * @param dst Destination filter context  
 * @param dstpad Destination pad index
 * @return >= 0 on success
 */
int avfilter_link(AVFilterContext src, int srcpad, AVFilterContext dst, int dstpad);

/**
 * Add frame to filter input
 * @param link Filter link
 * @param frame Frame to add
 * @return >= 0 on success
 */
int av_buffersrc_add_frame(AVFilterContext ctx, AVFrame frame);

/**
 * Get frame from filter output
 * @param link Filter link
 * @param frame Frame to receive data
 * @return >= 0 on success
 */
int av_buffersink_get_frame(AVFilterContext ctx, AVFrame frame);

Usage Example:

import org.bytedeco.ffmpeg.avfilter.*;
import static org.bytedeco.ffmpeg.global.avfilter.*;

// Create filter graph
AVFilterGraph filterGraph = avfilter_graph_alloc();

// Create buffer source (input)
AVFilter bufferSrc = avfilter_get_by_name("buffer");
AVFilterContext bufferCtx = new AVFilterContext(null);
String args = String.format("width=%d:height=%d:pix_fmt=%d:time_base=1/30:pixel_aspect=1/1",
    1920, 1080, AV_PIX_FMT_YUV420P);
avfilter_graph_create_filter(bufferCtx, bufferSrc, "in", args, null, filterGraph);

// Create scale filter
AVFilter scaleFilter = avfilter_get_by_name("scale");
AVFilterContext scaleCtx = new AVFilterContext(null);
avfilter_graph_create_filter(scaleCtx, scaleFilter, "scale", "640:480", null, filterGraph);

// Create buffer sink (output)
AVFilter bufferSink = avfilter_get_by_name("buffersink");
AVFilterContext sinkCtx = new AVFilterContext(null);
avfilter_graph_create_filter(sinkCtx, bufferSink, "out", null, null, filterGraph);

// Link filters: input -> scale -> output
avfilter_link(bufferCtx, 0, scaleCtx, 0);
avfilter_link(scaleCtx, 0, sinkCtx, 0);

// Configure graph
avfilter_graph_config(filterGraph, null);

// Process frames
AVFrame inputFrame = av_frame_alloc();
AVFrame outputFrame = av_frame_alloc();

// Add input frame
av_buffersrc_add_frame(bufferCtx, inputFrame);

// Get output frame
while (av_buffersink_get_frame(sinkCtx, outputFrame) >= 0) {
    // Process output frame
    System.out.println("Filtered frame: " + outputFrame.width() + "x" + outputFrame.height());
    av_frame_unref(outputFrame);
}

// Cleanup
av_frame_free(inputFrame);
av_frame_free(outputFrame);
avfilter_graph_free(filterGraph);

Common Filters

Video Filters

// Scale filter - resize video
"scale=width:height[:flags]"

// Crop filter - crop video to region
"crop=width:height:x:y"

// Overlay filter - overlay one video on another
"overlay=x:y[:options]"

// Rotate filter - rotate video
"rotate=angle*PI/180"

// Blur filter - apply blur effect
"boxblur=luma_radius:luma_power:chroma_radius:chroma_power"

// Color adjustment
"eq=brightness:contrast:saturation:gamma"

Audio Filters

// Volume filter - adjust audio volume
"volume=volume[:precision]"

// Audio resample - change sample rate
"aresample=sample_rate"

// Audio format - change audio format
"aformat=sample_fmts:sample_rates:channel_layouts"

// Audio mix - mix multiple audio streams
"amix=inputs:duration:dropout_transition"

// Audio delay
"adelay=delays:all"

Filter Context Information

Filter Properties

/**
 * Filter context representing filter instance
 */
class AVFilterContext extends Pointer {
    /** Filter definition */
    AVFilter filter();
    
    /** Instance name */
    BytePointer name();
    
    /** Number of input pads */
    int nb_inputs();
    
    /** Number of output pads */
    int nb_outputs();
    
    /** Input pads */
    AVFilterPad input_pads();
    
    /** Output pads */
    AVFilterPad output_pads();
}

/**
 * Filter definition
 */
class AVFilter extends Pointer {
    /** Filter name */
    BytePointer name();
    
    /** Filter description */
    BytePointer description();
    
    /** Input pad descriptors */
    AVFilterPad inputs();
    
    /** Output pad descriptors */
    AVFilterPad outputs();
    
    /** Filter flags */
    int flags();
}

Constants

Filter Flags

// Filter capability flags
int AVFILTER_FLAG_DYNAMIC_INPUTS = 1;   // Number of inputs can change
int AVFILTER_FLAG_DYNAMIC_OUTPUTS = 2;  // Number of outputs can change
int AVFILTER_FLAG_SLICE_THREADS = 4;    // Filter supports slice threading
int AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC = 16; // Filter supports timeline
int AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL = 32; // Filter supports internal timeline

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