### Get FFmpeg Probe Info with Custom Options Source: https://livingbio.github.io/typed-ffmpeg/usage/probe Retrieves detailed information about a media file using `ffmpeg.probe`. This example shows how to specify a custom ffprobe command path, set a timeout, control the log level, and include frame and packet data in the output. ```python import ffmpeg info = ffmpeg.probe( "video.mp4", cmd="/usr/local/bin/ffprobe", # Custom ffprobe path timeout=30, # 30 second timeout loglevel="quiet", # Suppress ffprobe output show_frames=True, # Include frame information show_packets=True # Include packet information ) ``` -------------------------------- ### Basic API Usage in Python Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/filters Demonstrates the fundamental usage of the typed-ffmpeg library for interacting with FFmpeg. This section covers initial setup and common operations. ```Python from ffmpeg import FFmpeg ffmpeg = FFmpeg() # Example: Get FFmpeg version version = ffmpeg.get_version() print(f"FFmpeg version: {version}") ``` -------------------------------- ### Input Stream Example Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/base Demonstrates how to create an input stream using the `input` function. ```python >>> input('input.mp4') ``` -------------------------------- ### Add Input Options (Start Time and Duration) Source: https://livingbio.github.io/typed-ffmpeg/usage/basic-api-usage Shows how to add specific options like start time (ss) and duration (t) when creating an input stream with ffmpeg.input. The ss option sets the start time in seconds, and the t option sets the duration in seconds. ```python import ffmpeg # Create a new input stream with specific options ffmpeg.input("input.mp4", ss=10, t=20) # Start at 10 seconds and last for 20 seconds ``` -------------------------------- ### Example: Using OutputStream for Global Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Demonstrates how to create an output file, obtain its OutputStream, and apply global FFmpeg options like overwriting the output. ```Python # Create an output file and add global options output_node = video.output("output.mp4") output_stream = output_node.stream() with_global_opts = output_stream.global_args(y=True) ``` -------------------------------- ### Python FFmpeg Command Generation Source: https://livingbio.github.io/typed-ffmpeg/-playground This Python code snippet demonstrates how to generate FFmpeg commands using the typed-ffmpeg library. It requires the library to be installed via pip. The example provided indicates that no valid FFmpeg command was generated in this specific instance. ```python # No valid FFmpeg command generated ``` -------------------------------- ### FFmpeg Command for Input Options Source: https://livingbio.github.io/typed-ffmpeg/usage/basic-api-usage Represents the FFmpeg command-line equivalent for specifying input options, including start time and duration. ```bash ffmpeg -t 20 -ss 10 -i input.mp4 ``` -------------------------------- ### Specify Output Options (Python) Source: https://livingbio.github.io/typed-ffmpeg/usage/basic-api-usage Creates an output file starting at 10 seconds and lasting for 20 seconds. This demonstrates how to set start time ('ss') and duration ('t') options for the output. ```Python import ffmpeg # Create and configure a new output stream ffmpeg.input("input.mp4").output( filename="output.mp4", ss=10, t=20 ) # Output starting at 10 seconds with a duration of 20 seconds ``` ```Bash ffmpeg -i input.mp4 -t 20 -ss 10 output.mp4 ``` -------------------------------- ### Python FFmpeg Basic API Usage Source: https://livingbio.github.io/typed-ffmpeg/index This example illustrates the basic usage of the typed-ffmpeg library for constructing and executing FFmpeg commands. It covers input, filter application, and output specification. ```Python from typed_ffmpeg import FFmpeg # Create an FFmpeg command instance ffmpeg_command = FFmpeg() # Specify input file input_file = ffmpeg_command.input('input.mp4') # Apply a filter (e.g., scaling) filtered_output = input_file.filter('scale', 1280, 720) # Specify output file output_file = filtered_output.output('output.mp4') # Execute the command (this would typically run ffmpeg) # output_file.run() print("FFmpeg command constructed successfully.") ``` -------------------------------- ### Basic FFmpeg API Usage (TypeScript) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/schema Demonstrates the fundamental usage of the typed-ffmpeg library for basic FFmpeg operations. This section likely covers creating FFmpeg instances and setting up simple commands. ```TypeScript import ffmpeg from 'typed-ffmpeg'; const command = ffmpeg(); command.input('input.mp4').output('output.mp4').run(); ``` -------------------------------- ### Get Media File Duration and Stream Count using FFmpeg Probe Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/probe This example demonstrates how to use the probe function to retrieve the duration and number of streams from a media file. It prints the duration in seconds and the number of streams. ```python info = probe("video.mp4") print(f"Duration: {float(info['format']['duration']):.2f} seconds") print(f"Streams: {len(info['streams'])} ") ``` -------------------------------- ### Basic FFmpeg Command Execution with typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/sources Demonstrates how to construct and execute a basic FFmpeg command using the typed-ffmpeg library. This involves creating an FFmpeg instance and chaining methods to define input, output, and filters. ```TypeScript import ffmpeg from 'typed-ffmpeg'; async function runBasicCommand() { const output = await ffmpeg() .input('input.mp4') .output('output.mp4') .run(); console.log(output); } ``` -------------------------------- ### QCP Input (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Sets up QCP input for FFmpeg. This demuxer is used for QCP files. ```python qcp() -> FFMpegDemuxerOption ``` -------------------------------- ### Main CLI Entry Point Source: https://livingbio.github.io/typed-ffmpeg/reference/scripts The main module serves as the command-line interface entry point for the typed-ffmpeg scripts package, allowing users to execute various FFmpeg-related parsing and generation tasks. ```Python from typed_ffmpeg.scripts.main import main ``` -------------------------------- ### Video Filters: Guided Filter Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/filters The `guided` filter applies a guided filter, using a guidance image (second input) to enhance or denoise the primary video stream. ```ffmpeg ffmpeg -i input.mp4 -i guidance.png -filter_complex "guided=r=4:eps=0.1" output.mp4 ``` -------------------------------- ### Pytest Configuration Source: https://livingbio.github.io/typed-ffmpeg/reference/scripts This module contains the pytest configuration for the typed-ffmpeg scripts package, ensuring proper setup for testing the various parsing and generation utilities. ```Python from typed_ffmpeg.scripts.conftest import pytest_plugins ``` -------------------------------- ### Execute Command - typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/common/schema Demonstrates how to execute the generated ffmpeg commands using typed-ffmpeg. This section likely covers running commands directly or capturing their output. ```Python from ffmpeg import FFmpeg ffmpeg = FFmpeg() # Example of executing a command and getting output command = ffm.input('input.mp4').output('output.mp4') result = command.execute() print(result.stdout) ``` -------------------------------- ### FFmpeg guided filter Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/filters The guided filter applies a guided filter to video streams. It supports various parameters such as radius, epsilon, mode, subsampling, guidance, and planes. Timeline and extra options can also be provided. ```python guided( *streams: VideoStream, radius: Int = Default("3"), eps: Float = Default("0.01"), mode: ( Int | Literal["basic", "fast"] | Default ) = Default("basic"), sub: Int = Default("4"), guidance: ( Int | Literal["off", "on"] | Default ) = Default("off"), planes: Int = Default("1"), timeline_options: FFMpegTimelineOption | None = None, extra_options: dict[str, Any] | None = None ) -> VideoStream ``` -------------------------------- ### FFmpeg: Guided Filter Source: https://livingbio.github.io/typed-ffmpeg/-playground Applies a Guided filter to the video. A powerful edge-preserving smoothing filter. ```ffmpeg ffmpeg -i input.mp4 -vf guided=... output.mp4 ``` -------------------------------- ### Basic FFmpeg API Usage with typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio Demonstrates the fundamental usage of the typed-ffmpeg library for interacting with FFmpeg. This section covers how to initialize the FFmpeg instance and perform basic operations. ```TypeScript import ffmpeg from 'typed-ffmpeg'; // Example of basic API usage const command = ffmpeg(); command.input('input.mp4').output('output.mp4').run(); ``` -------------------------------- ### FFmpeg Parse Help CLI Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Describes the command-line interface for parsing FFmpeg help output. ```Python from typed_ffmpeg.scripts.parse_help.cli import parse_help_cli # Example usage (conceptual) # parse_help_cli(['--formats', 'ffmpeg_help.txt']) ``` -------------------------------- ### Get Node Label in FFmpeg Filter Graph Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/compile/compile_cli Retrieves the string label for a specific node within an FFmpeg filter graph. The label format varies by node type: input nodes get sequential numbers (0, 1, 2...), filter nodes get 's' followed by a number (s0, s1, s2...), and output nodes get 'out'. Requires a Node and DAGContext. ```Python get_node_label(node: Node, context: DAGContext) -> str: """Get the string label for a specific node in the filter graph.""" pass ``` -------------------------------- ### FFmpeg Parse Help Utils Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Covers utility functions used in parsing FFmpeg help output. ```Python from typed_ffmpeg.scripts.parse_help.utils import parse_section # Example usage (conceptual) # section_data = parse_section(help_text, 'Codecs:') ``` -------------------------------- ### Benchmark Filtergraph (bench) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/video Benchmarks a specific part of a filtergraph by starting or stopping the measurement. It accepts an action parameter ('start' or 'stop') and extra options. ```Python bench( *, action: ( Int | Literal["start", "stop"] | Default ) = Default("start"), extra_options: dict[str, Any] | None = None ) -> VideoStream ``` -------------------------------- ### Example Usage of afilter for Volume Adjustment Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio This example demonstrates how to use the afilter function to apply a volume filter to an audio stream, increasing its volume by a factor of 2.0. ```Python # Apply a volume filter to an audio stream louder = stream.afilter(name="volume", volume=2.0) ``` -------------------------------- ### Compiling FFmpeg CLI Command Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/sources Demonstrates the process of compiling an FFmpeg command-line interface (CLI) command, likely using a helper script or function within the typed-ffmpeg ecosystem. ```Bash ffmpeg -i input.mp4 -vf "scale=640:360" output.mp4 ``` -------------------------------- ### FFmpeg loop filter Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/video Loops video frames a specified number of times or for a given duration. It supports setting the number of loops, maximum frames to loop, start frame, and start time. ```python loop( *, loop: Int = Default("0"), size: Int64 = Default("0"), start: Int64 = Default("0"), time: Duration = Default("INT64_MAX"), extra_options: dict[str, Any] | None = None ) -> VideoStream ``` -------------------------------- ### Pytest Configuration: pytest_runtest_setup Source: https://livingbio.github.io/typed-ffmpeg/reference/scripts/conftest Sets up the test execution environment by applying custom options defined via pytest_addoption. It operates on a specific pytest Item. ```Python pytest_runtest_setup(item: Item) -> None ``` -------------------------------- ### Loop audio samples with aloop Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio The aloop function loops audio samples. It allows specifying the number of loops, the maximum number of samples to loop, the start sample, and the loop start time. It returns the looped AudioStream. ```Python aloop( *, loop: Int = Default("0"), size: Int64 = Default("0"), start: Int64 = Default("0"), time: Duration = Default("INT64_MAX"), extra_options: dict[str, Any] | None = None ) -> AudioStream ``` -------------------------------- ### APTX HD Demuxer Option Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the Raw aptX HD demuxer. It accepts an optional sample rate for customization. ```python aptx_hd( sample_rate: int | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Apply Guided Filter (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/sources Applies the Guided filter to a video stream, adjusting parameters like radius, epsilon, mode, subsampling, guidance, and planes for image processing. It supports timeline and extra options for advanced customization. ```Python guided( *streams: VideoStream, radius: Int = Default("3"), eps: Float = Default("0.01"), mode: (Int | Literal["basic", "fast"] | Default) = Default("basic"), sub: Int = Default("4"), guidance: (Int | Literal["off", "on"] | Default) = Default("off"), planes: Int = Default("1"), timeline_options: FFMpegTimelineOption | None = None, extra_options: dict[str, Any] | None = None ) -> VideoStream ``` -------------------------------- ### APTX Demuxer Option Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the Raw aptX demuxer. It accepts an optional sample rate for customization. ```python aptx(sample_rate: int | None = None) -> FFMpegDemuxerOption ``` -------------------------------- ### RealMedia Input (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Sets up RealMedia input for FFmpeg. This demuxer is used for RealMedia files. ```python rm() -> FFMpegDemuxerOption ``` -------------------------------- ### typed-ffmpeg fade filter Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/video Applies a fade-in or fade-out effect to an input video stream. Supports controlling the fade direction, start frame, number of frames, alpha channel usage, start time, duration, and color. It can also accept timeline and extra options. ```Python fade( *, type: Int | Literal["in", "out"] | Default = Default( "in" ), start_frame: Int = Default("0"), nb_frames: Int = Default("25"), alpha: Boolean = Default("false"), start_time: Duration = Default("0"), duration: Duration = Default("0"), color: Color = Default("black"), timeline_options: FFMpegTimelineOption | None = None, extra_options: dict[str, Any] | None = None ) -> VideoStream ``` -------------------------------- ### Get Hexadecimal Hash of Object Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio Retrieves the hexadecimal hash of an object. This property is cached for efficiency. ```Python hex: str ``` -------------------------------- ### Parsing FFmpeg Help Utility Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Describes the general utility for parsing FFmpeg help output, including common helper functions. ```Python from typed_ffmpeg.scripts.parse_help.utils import clean_text # Example usage # cleaned = clean_text(' some text \n') ``` -------------------------------- ### FFmpeg Context Management in Python Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/codecs/encoders Demonstrates how to manage FFmpeg contexts or processes using typed-ffmpeg, ensuring proper initialization and cleanup. ```Python from ffmpeg import FFmpeg # Example: Using FFmpeg within a context manager (conceptual) # with FFmpeg() as ffmpeg_instance: # ffmpeg_instance.input('input.mp4').output('output.mp4').run() ``` -------------------------------- ### Get Hexadecimal Hash of Stream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/video Retrieves the hexadecimal hash of a stream object. This is a property that returns a string representation of the hash. ```Python hex: str ``` -------------------------------- ### Get Node Representation Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/schema Returns a string representation of the node. This is often used for debugging or logging purposes. ```Python repr() -> str ``` -------------------------------- ### Executing FFmpeg Commands with typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio Illustrates the execution of FFmpeg commands generated by typed-ffmpeg. This covers running commands, handling output, and managing potential errors during execution. ```TypeScript import ffmpeg from 'typed-ffmpeg'; // Example of executing a command ffmpeg() .input('input.mp4') .output('output.mp4') .on('end', () => console.log('Processing finished')) .on('error', (err) => console.error('Error:', err)) .run(); ``` -------------------------------- ### Crop Filter Example: ffmpeg-python vs typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/faq Demonstrates the difference in defining a 'crop' filter between ffmpeg-python and typed-ffmpeg. typed-ffmpeg requires explicit video/audio filter declaration (e.g., 'vfilter') and uses keyword-only arguments for filter options. ```Python import ffmpeg # ffmpeg-python example ( \ ffmpeg.input("in.mp4") .filter('crop', 'in_w-2*10', 'in_h-2*20') ) ``` ```Python import ffmpeg # typed-ffmpeg example ( \ ffmpeg.input("in.mp4") .vfilter("crop", out_w="in_w-2*10", out_h="in_h-2*20") ) ``` -------------------------------- ### Basic API Usage - typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/common/schema Demonstrates the fundamental usage of the typed-ffmpeg library for constructing ffmpeg commands. This section likely covers importing necessary modules and creating basic command structures. ```Python from ffmpeg import FFmpeg ffmpeg = FFmpeg() # Example of building a simple command command = ffm.input('input.mp4').output('output.mp4').run() print(command) ``` -------------------------------- ### Get Stream Index Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/video Represents the index of the stream within the node's output streams. This attribute can be an integer or None if not applicable. ```Python index: int | None = None ``` -------------------------------- ### Get Upstream Node Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio Represents the node from which the stream originates. In the context of data flow, this is the source providing the data. ```Python node: FilterNode | InputNode ``` -------------------------------- ### FFmpeg Manual CLI (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/schema Details the command-line interface for generating manual pages or documentation for typed-ffmpeg. This helps in creating user-friendly documentation. ```Python from typed_ffmpeg.scripts.manual.cli import generate_manual generate_manual() ``` -------------------------------- ### Get Hexadecimal Hash of Stream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Retrieves the hexadecimal hash of the Stream object, providing a unique identifier. ```Python hex: str ``` -------------------------------- ### Get Hexadecimal Hash of OutputStream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Returns the hexadecimal hash of the OutputStream object, useful for identification or comparison. ```Python hex: str ``` -------------------------------- ### RedSpark Input (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Sets up RedSpark input for FFmpeg. This demuxer is used for RedSpark files. ```python redspark() -> FFMpegDemuxerOption ``` -------------------------------- ### Parsing FFmpeg Help for Formats Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Explains the Python script that parses FFmpeg's help output to extract details about supported formats (demuxers and muxers). ```Python from typed_ffmpeg.scripts.parse_help.parse_formats import parse_formats # Example usage with help text # help_text = '...' # formats = parse_formats(help_text) ``` -------------------------------- ### Get Upstream Node of Stream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/video Represents the node from which the stream receives its data. This attribute links the stream to its source node, which can be a FilterNode or InputNode. ```Python node: FilterNode | InputNode ``` -------------------------------- ### HLS Demuxer Option Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures Apple HTTP Live Streaming (HLS) for FFMpeg. Provides options for live start index, preference for X-START, allowed extensions, reload attempts, HTTP connection settings, and segment format options. Returns FFMpegDemuxerOption. ```python hls( live_start_index: int | None = None, prefer_x_start: bool | None = None, allowed_extensions: str | None = None, max_reload: int | None = None, m3u8_hold_counters: int | None = None, http_persistent: bool | None = None, http_multiple: bool | None = None, http_seekable: bool | None = None, seg_format_options: str | None = None, seg_max_retry: int | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Get Stream Index Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio Represents the index of the stream within the node's output streams. This attribute can be an integer or None. ```Python index: int | None = None ``` -------------------------------- ### xbin: Configure Extended BINary Text Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures Extended BINary text (XBIN) demuxer options, allowing setting of line speed, video size, and framerate. Returns FFMpegDemuxerOption. ```python xbin( linespeed: int | None = None, video_size: str | None = None, framerate: str | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### txd: Renderware TeXture Dictionary Demuxer Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Initializes the Renderware TeXture Dictionary demuxer. This function takes no arguments and returns FFMpegDemuxerOption. ```python txd() -> FFMpegDemuxerOption ``` -------------------------------- ### Get Hexadecimal Hash of OutputStream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Retrieves the hexadecimal hash of an OutputStream object. This can be used for uniquely identifying stream instances. ```Python hex: str ``` -------------------------------- ### Executing FFmpeg Commands (TypeScript) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/schema Covers the execution of FFmpeg commands generated by typed-ffmpeg. This includes running the commands and handling their output and potential errors. ```TypeScript import ffmpeg from 'typed-ffmpeg'; const command = ffmpeg(); command.input('input.mp4').output('output.mp4'); command.on('progress', (progress) => { console.log(`Processing: ${progress.percent}%`); }); command.on('end', () => { console.log('Processing finished.'); }); command.on('error', (err) => { console.error('Error:', err); }); command.run(); ``` -------------------------------- ### Get String Representation of Output Node Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Retrieves a string representation of an output node. This is useful for debugging or logging purposes. ```Python repr() ``` -------------------------------- ### Configure SDP Demuxer Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the SDP (Session Description Protocol) demuxer with various flags and settings. This includes listen timeout, local address, allowed media types, reorder queue size, and buffer size. ```python sdp( sdp_flags: str | None = None, listen_timeout: str | None = None, localaddr: str | None = None, allowed_media_types: str | None = None, reorder_queue_size: int | None = None, buffer_size: int | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Get Stream Hexadecimal Hash Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/schema Retrieves the hexadecimal hash of the Stream object. This hash can be used for uniquely identifying the stream. ```Python hex: str ``` -------------------------------- ### FFmpeg IO Handling Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Covers the input/output handling mechanisms within the FFmpeg DAG, including input and output configurations. ```Python from typed_ffmpeg.dag.io import Input, Output # Example usage # input_config = Input(filename='input.mp4') # output_config = Output(filename='output.mp4') ``` -------------------------------- ### Get Hexadecimal Hash of FilterableStream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Retrieves the hexadecimal hash of the FilterableStream object. This can be used for uniquely identifying or comparing stream instances. ```Python hex: str ``` -------------------------------- ### Get FFmpeg Encoder Codec Context Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options/codec A function to retrieve encoder codec context options for FFmpeg. ```python def encoder_codec_context(): """Encoder codec context options.""" pass ``` -------------------------------- ### Basic FFmpeg API Usage Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Demonstrates the fundamental usage of the typed-ffmpeg library for basic FFmpeg operations. This section covers initializing the API and performing simple tasks. ```TypeScript import ffmpeg from 'typed-ffmpeg'; async function basicUsage() { const result = await ffmpeg().input('input.mp4').output('output.mp4').run(); console.log(result); } ``` -------------------------------- ### FFmpeg Parse Help CLI Tool (General) in Python Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/codecs/encoders Provides a general overview of the CLI tool for parsing FFmpeg's help output, covering various aspects like codecs, filters, and formats. ```Python # Example usage of the parse_help CLI script (conceptual) # python -m scripts.parse_help.cli --help ``` -------------------------------- ### Get FFmpeg Decoder Codec Context Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options/codec A function to retrieve decoder codec context options for FFmpeg. ```python def decoder_codec_context(): """Decoder codec context options.""" pass ``` -------------------------------- ### Request Channel Layout Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options Requests a specific channel layout for the audio output. This allows the user to guide the decoder's channel arrangement. ```python request_channel_layout: str | None ``` -------------------------------- ### FFmpeg Run Utility Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Covers the utility for running external commands, likely used internally by typed-ffmpeg. ```Python from typed_ffmpeg.utils.run import run_command # Example usage # result = run_command(['ls', '-l']) # print(result.stdout) ``` -------------------------------- ### FFmpeg Info and Options: Codec, Format, Framesync, Timeline Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options This section details FFmpeg info and various options like codec, format, framesync, and timeline. It provides schema definitions for these configurations. ```TypeScript import { FFmpegOptions } from 'typed-ffmpeg'; const info = FFmpegOptions.info; const codecOptionsSchema = FFmpegOptions.options.codec.schema({}); const formatOptionsSchema = FFmpegOptions.options.format.schema({}); const framesyncOptionsSchema = FFmpegOptions.options.framesync.schema({}); const timelineOptionsSchema = FFmpegOptions.options.timeline.schema({}); ``` -------------------------------- ### FFprobe Usage with typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/sources Illustrates how to use FFprobe via typed-ffmpeg to get information about media files. This includes parsing probe data. ```TypeScript import ffmpeg from 'typed-ffmpeg'; async function probeFile() { const probeData = await ffmpeg.ffprobe('input.mp4'); console.log(probeData); } ``` -------------------------------- ### Get Hexadecimal Hash of FilterableStream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Retrieves the hexadecimal hash of the FilterableStream object. This can be used for uniquely identifying or comparing stream instances. ```Python hex: str ``` -------------------------------- ### Executing FFmpeg Commands in Python Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/codecs/encoders Covers the execution of FFmpeg commands generated by typed-ffmpeg. This includes running the commands and handling their output and potential errors. ```Python from ffmpeg import FFmpeg ffmpeg = FFmpeg() # Execute a command and capture output process = ( ffmpeg .input('input.mp4') .output('output.mp4') .run_async() ) # Wait for the process to complete stdout, stderr = process.wait() print(stdout) print(stderr) ``` -------------------------------- ### Get Upstream Nodes of a Node Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/schema Retrieves all upstream nodes connected to a given node in the graph. This is useful for understanding data flow dependencies. ```Python upstream_nodes: set[Node] ``` -------------------------------- ### Executing FFmpeg Commands Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Covers the execution of FFmpeg commands using typed-ffmpeg, including handling the output and potential errors. ```TypeScript import ffmpeg from 'typed-ffmpeg'; async function executeCommand() { try { const result = await ffmpeg().input('input.mp4').output('output.mp4').run(); console.log('FFmpeg command executed successfully:', result); } catch (error) { console.error('Error executing FFmpeg command:', error); } } ``` -------------------------------- ### FFmpeg Parse Docs Scripts: CLI, Helpers, Schema Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options This snippet details scripts used for parsing FFmpeg documentation, including CLI tools, helper functions, and schema definitions. This is crucial for generating structured information from FFmpeg's help output. ```TypeScript import { FFmpegOptions } from 'typed-ffmpeg'; // Example for parsing documentation schema const parseDocsSchema = FFmpegOptions.scripts.parse_docs.schema({}); // Example for documentation parsing helpers const parseDocsHelpers = FFmpegOptions.scripts.parse_docs.helpers; ``` -------------------------------- ### tedcaptions() - FFmpeg Demuxer Option Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Sets the demuxer option for TED Talks captions. Allows configuration of the start time offset. Returns an FFMpegDemuxerOption object. ```python tedcaptions( start_time: int | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Round Expression Value (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/expressions Rounds the value of a given expression to the nearest integer. For example, `round(1.5)` evaluates to `2.0`. ```Python round(expr: Any) -> Expression ``` -------------------------------- ### Get Types from XSD Choice Element Source: https://livingbio.github.io/typed-ffmpeg/reference/scripts/parse_c/xsd_to_dataclasses Extracts the type names from an XSD 'choice' element. This function requires the choice element and namespace mappings. ```Python get_choice_types( choice: Element, ns: dict[str, str] ) -> list[str] ``` -------------------------------- ### Configure libopenmpt Demuxer Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the libopenmpt demuxer for tracker music formats. Supports setting the sample rate, channel layout, and specific subsongs. ```python libopenmpt( sample_rate: int | None = None, layout: str | None = None, subsong: int | None | Literal["all", "auto"] = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Get String Representation of Node Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Returns a string representation of an input node, typically the basename of the input file. This is useful for debugging and logging purposes. ```Python repr() -> str ``` -------------------------------- ### Code Generation from Schema Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Illustrates the use of Python scripts to generate code based on provided schemas, likely for FFmpeg options or structures. ```Python from typed_ffmpeg.scripts.code_gen.schema import generate_from_schema # Example usage (assuming schema file exists) # generate_from_schema('path/to/schema.json', 'output_code.py') ``` -------------------------------- ### Get Upstream Nodes Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Retrieves all upstream nodes connected to a given node in the FFmpeg filter graph. This is useful for understanding data flow and dependencies. ```Python upstream_nodes: set[Node] ``` -------------------------------- ### FFmpeg Parse Help Scripts: CLI, Codecs, Filters, Formats Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options This section covers scripts for parsing FFmpeg's help output, including extracting information about codecs, filters, and formats. It provides CLI tools and utility functions for this purpose. ```TypeScript import { FFmpegOptions } from 'typed-ffmpeg'; // Example for parsing codecs from help const parseCodecs = FFmpegOptions.scripts.parse_help.parse_codecs; // Example for parsing filters from help const parseFilters = FFmpegOptions.scripts.parse_help.parse_filters; // Example for parsing formats from help const parseFormats = FFmpegOptions.scripts.parse_help.parse_formats; // Example for general help parsing schema const parseHelpSchema = FFmpegOptions.scripts.parse_help.schema({}); ``` -------------------------------- ### Python Symbol: Get Required Keys Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/utils/lazy_eval/schema The keys() method for a Symbol returns a set containing its own key, as it's the only symbol required for its evaluation. ```Python keys() -> set[str] ``` -------------------------------- ### FFmpeg Global Runnable Execution Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Explains the execution of global runnable FFmpeg tasks, including handling global arguments. ```Python from typed_ffmpeg.dag.global_runnable import GlobalRunnable # Example usage # runnable = GlobalRunnable(command='ffmpeg', args=['-version']) # runnable.run() ``` -------------------------------- ### Get Upstream Nodes of a Node Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Retrieves all nodes that feed into the current node within the graph. This is useful for understanding data flow and dependencies. ```Python upstream_nodes: set[Node] ``` -------------------------------- ### FFmpeg Code Generation for Manual CLI Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Details Python scripts for generating manual command-line interface code for FFmpeg. ```Python from typed_ffmpeg.scripts.code_gen.manual import generate_manual_cli # Example usage (assuming schema) # generate_manual_cli('path/to/schema.json', 'manual_cli.py') ``` -------------------------------- ### Probe Media File for Detailed Stream and Format Info (Python) Source: https://livingbio.github.io/typed-ffmpeg/usage/probe This example demonstrates how to use the `ffmpeg.probe` function to extract detailed format and stream information from a media file. It prints key details like format name, duration, bitrate, video resolution, and audio sample rate. ```python import ffmpeg # Get detailed information about streams info = ffmpeg.probe("video.mp4", show_streams=True, show_format=True) # Print format information print("Format Information:") print(f"Format: {info['format']['format_name']}") print(f"Duration: {float(info['format']['duration']):.2f} seconds") print(f"Bitrate: {int(info['format']['bit_rate'])/1000:.0f} kbps") # Print stream information print("\nStream Information:") for stream in info['streams']: if stream['codec_type'] == 'video': print(f"\nVideo Stream:") print(f" Codec: {stream['codec_name']}") print(f" Resolution: {stream['width']}x{stream['height']}") print(f" Frame Rate: {eval(stream['r_frame_rate']):.2f} fps") elif stream['codec_type'] == 'audio': print(f"\nAudio Stream:") print(f" Codec: {stream['codec_name']}") print(f" Sample Rate: {stream['sample_rate']} Hz") print(f" Channels: {stream['channels']}") ``` -------------------------------- ### Bitpacked Demuxer Option Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the bitpacked demuxer. Allows setting pixel format, video size, and framerate. Returns the set codec options. ```python bitpacked( pixel_format: str | None = None, video_size: str | None = None, framerate: str | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Configure WebM DASH Manifest with Typed FFMpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Generates a WebM DASH manifest for FFMpeg. Supports defining adaptation sets, live stream manifests, chunk start index and duration, UTC timing URLs, time shift buffer depth, and minimum update periods. ```python webm_dash_manifest( adaptation_sets: str | None = None, live: bool | None = None, chunk_start_index: int | None = None, chunk_duration_ms: int | None = None, utc_timing_url: str | None = None, time_shift_buffer_depth: float | None = None, minimum_update_period: int | None = None, ) -> FFMpegMuxerOption ``` -------------------------------- ### Get OutputStream from OutputNode Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Obtains an OutputStream object from an OutputNode, enabling the addition of global options to FFmpeg commands. This is a crucial step for configuring FFmpeg execution. ```Python stream() -> OutputStream ``` -------------------------------- ### Get Stream Index Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Represents the index of the stream within the node's output streams. This attribute is crucial for distinguishing between multiple streams originating from the same node. ```Python index: int | None = None ``` -------------------------------- ### Parsing FFmpeg Help Output (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/schema Explains the Python scripts used to parse FFmpeg's help output. This is crucial for extracting information about available options, filters, and codecs. ```Python from typed_ffmpeg.scripts.parse_help.cli import parse_help_command parse_help_command(['--help-filters']) parse_help_command(['--help-formats']) parse_help_command(['--help-codecs']) ``` -------------------------------- ### Parsing FFmpeg Help Output Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Describes Python scripts designed to parse the help output of FFmpeg commands, extracting information about codecs, filters, and formats. ```Python from typed_ffmpeg.scripts.parse_help.cli import parse_help_cli # Example usage (assuming help file exists) # parse_help_cli(['--codecs', 'path/to/ffmpeg_help.txt']) ``` -------------------------------- ### Get Root Node in DAGContext Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/compile/context Accesses the root node of the DAG, which is the destination or output node of the graph. All other nodes in the context are upstream from this node. ```Python node: Node ``` -------------------------------- ### Detect Black Frames Source: https://livingbio.github.io/typed-ffmpeg/-playground Detects individual frames in a video that are almost entirely black. Useful for identifying the start or end of content, or silent black segments. ```FFmpeg ffmpeg -i input.mp4 -vf "blackframe=planes=1:threshold=0.9" -f null - ``` -------------------------------- ### Configure SLN Demuxer Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the SLN (Asterisk raw pcm) demuxer. Options include sample rate, channels, and channel layout. Returns FFmpegDemuxerOption. ```python sln( sample_rate: int | None = None, channels: int | None = None, ch_layout: str | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### FFmpeg Common Options: Cache, Schema, Serialize Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options This section covers common FFmpeg options including caching, schema definitions, and serialization utilities. These are fundamental for managing FFmpeg processes efficiently. ```TypeScript import { FFmpegOptions } from 'typed-ffmpeg'; const commonOptions = FFmpegOptions.common.schema({ cache: true, serialize: true }); ``` -------------------------------- ### Get Combined Audio-Video Stream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Retrieves a combined audio-video stream from an input file. This method is useful when both audio and video components need to be processed or output together. ```Python stream() -> AVStream # Access both audio and video from an input file input_node = ffmpeg.input("input.mp4") av_stream = input_node.stream() # Output both audio and video to a new file output = av_stream.output("output.mp4") ``` -------------------------------- ### Validating FFmpeg Configurations with Python Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/streams/audio Details the process of validating FFmpeg configurations using Python. This ensures that the generated commands or configurations adhere to FFmpeg's expected structure and parameters. ```Python from typed_ffmpeg.validate import validate # Example of validating a configuration config_to_validate = {'inputs': [{'filename': 'input.mp4'}]} validation_result = validate(config_to_validate) print(validation_result) ``` -------------------------------- ### Get Upstream Node of FilterableStream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag/nodes Represents the node from which the stream originates. This attribute is essential for tracing the data flow and understanding the upstream dependencies in the FFmpeg filter graph. ```Python node: FilterNode | InputNode ``` -------------------------------- ### FFmpeg Scripts: Code Gen, Conftest, Main Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options This snippet covers FFmpeg related scripts, including code generation, testing configurations, and main script functionalities. It details schema definitions for various script components. ```TypeScript import { FFmpegOptions } from 'typed-ffmpeg'; // Example for code generation schema const codeGenSchema = FFmpegOptions.scripts.code_gen.schema({}); // Example for conftest const conftest = FFmpegOptions.scripts.conftest; // Example for main script const mainScript = FFmpegOptions.scripts.main; ``` -------------------------------- ### x11grab: Configure X11 Screen Capture Options Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Captures the X11 screen using XCB, allowing configuration of window ID, capture coordinates, video size, framerate, mouse drawing, and region selection. Returns FFMpegDemuxerOption. ```python x11grab( window_id: int | None = None, x: int | None = None, y: int | None = None, grab_x: int | None = None, grab_y: int | None = None, video_size: str | None = None, framerate: str | None = None, draw_mouse: int | None = None, follow_mouse: int | None | Literal["centered"] = None, show_region: int | None = None, region_border: int | None = None, select_region: bool | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Get Required Symbol Names (keys) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/utils/lazy_eval/operator Retrieves the set of symbol names necessary for evaluating the operator. This method aggregates symbols from its operands, ensuring all dependencies are accounted for. ```Python keys() -> set[str] ``` -------------------------------- ### Get Stream Index Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Represents the index of the stream within the node's output streams. This attribute is crucial for distinguishing between multiple streams originating from the same node. ```Python index: int | None = None ``` -------------------------------- ### FFmpeg Complex Filtering with typed-ffmpeg Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/sources Shows how to apply complex filtering graphs in FFmpeg using typed-ffmpeg. This example illustrates chaining multiple filters and defining their parameters. ```TypeScript import ffmpeg from 'typed-ffmpeg'; async function runComplexFilter() { const output = await ffmpeg() .input('input.mp4') .complexFilter([ { filter: 'scale', options: { w: 640, h: 360 } }, { filter: 'fps', options: { fps: 30 } } ]) .output('output.mp4') .run(); console.log(output); } ``` -------------------------------- ### FFmpeg Command with Redundant Split Filter Source: https://livingbio.github.io/typed-ffmpeg/usage/execute An example of an FFmpeg command generated without auto-fixing, showing an inefficient command with a redundant split filter. ```bash ffmpeg -i input1.mp4 -filter_complex '[0:v]split=2[s0][s1];[s0]trim=end=5[t]' -map '[t]' tmp.mp4 ``` -------------------------------- ### FFmpeg Parse Docs CLI Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/muxers Describes the command-line interface for parsing documentation related to FFmpeg. ```Python from typed_ffmpeg.scripts.parse_docs.cli import parse_docs_cli # Example usage (conceptual) # parse_docs_cli(['--input', 'ffmpeg_docs.txt', '--output', 'parsed_docs.json']) ``` -------------------------------- ### Executing FFmpeg Commands in Python Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/filters Shows how to execute FFmpeg commands generated by typed-ffmpeg. This covers the final step of applying the configured operations to media files. ```Python from ffmpeg import FFmpeg, Input, Output ffmpeg = FFmpeg() input_file = Input('input.mp4') output_file = Output('output.mp4') # Example: Execute a simple transcoding operation process = ffmpeg.execute([input_file], output_file) print(f"FFmpeg process finished with return code: {process}") ``` -------------------------------- ### Binary Text Demuxer Option Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/formats/demuxers Configures the binary text demuxer. Allows setting linespeed, video size, and framerate. Returns the set codec options. ```python bin( linespeed: int | None = None, video_size: str | None = None, framerate: str | None = None, ) -> FFMpegDemuxerOption ``` -------------------------------- ### Get Filter Input Typings (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/scripts/code_gen/gen Fetches the input typings for an FFmpeg filter. This is essential for understanding and validating the types of data that a filter can accept as input. ```python input_typings(ffmpeg_filter: FFMpegFilter) -> str ``` -------------------------------- ### Get Upstream Node of FilterableStream Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/dag Represents the node from which the stream originates. This attribute is essential for tracing the data flow and understanding the upstream dependencies in the FFmpeg filter graph. ```Python node: FilterNode | InputNode ``` -------------------------------- ### FFmpeg DAG Utilities: Factory, Global Runnable, IO Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/options This section details the Directed Acyclic Graph (DAG) utilities within typed-ffmpeg, including factory functions, global runnable configurations, and input/output handling. It covers schema definitions and IO utilities. ```TypeScript import { FFmpegOptions } from 'typed-ffmpeg'; // Example using factory const factory = FFmpegOptions.dag.factory; // Example for global arguments const globalArgs = FFmpegOptions.dag.global_runnable.global_args; // Example for input/output schema const inputSchema = FFmpegOptions.dag.io._input.schema({}); const outputSchema = FFmpegOptions.dag.io._output.schema({}); ``` -------------------------------- ### FFmpeg Main Script (Python) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/schema Refers to the main entry point script for the typed-ffmpeg Python package. This script likely orchestrates various functionalities or provides a command-line interface. ```Python # Contents of main.py would be here, likely the main application logic. ``` -------------------------------- ### FFmpeg Probe Usage (TypeScript) Source: https://livingbio.github.io/typed-ffmpeg/reference/ffmpeg/ffprobe/schema Explains how to use the probe functionality of typed-ffmpeg to get information about media files. This involves using the ffprobe module to parse media metadata. ```TypeScript import { ffprobe } from 'typed-ffmpeg'; async function getInfo(filePath: string) { const info = await ffprobe(filePath); console.log(info); } ```