Skip to content

nodes

Classes:

Name Description
FilterNode

A filter node that can be used to apply filters to streams

FilterableStream

A stream that can be used as input to a filter

InputNode

A node that can be used to read from files

OutputNode
OutputStream
GlobalNode

A node that can be used to set global options

GlobalStream

FilterNode dataclass

FilterNode(
    *,
    kwargs: tuple[
        tuple[str, str | int | float | bool | LazyValue],
        ...,
    ] = (),
    inputs: tuple[FilterableStream, ...] = (),
    name: str,
    input_typings: tuple[StreamType, ...] = (),
    output_typings: tuple[StreamType, ...] = ()
)

Bases: Node

A filter node that can be used to apply filters to streams

Methods:

Name Description
replace

Replace the old node in the graph with the new node.

view

Visualize the Node.

repr

Get the representation of the node.

video

Return the video stream at the specified index

audio

Return the audio stream at the specified index

get_args

Get the arguments of the node.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

kwargs tuple[tuple[str, str | int | float | bool | LazyValue], ...]

Represents the keyword arguments of the node.

max_depth int

Get the maximum depth of the node.

upstream_nodes set[Node]

Get all upstream nodes of the node.

name str

The name of the filter

inputs tuple[FilterableStream, ...]

The input streams

input_typings tuple[StreamType, ...]

The input typings

output_typings tuple[StreamType, ...]

The output typings

hex cached property

hex: str

Get the hexadecimal hash of the object.

kwargs class-attribute instance-attribute

kwargs: tuple[
    tuple[str, str | int | float | bool | LazyValue], ...
] = ()

Represents the keyword arguments of the node.

max_depth property

max_depth: int

Get the maximum depth of the node.

Returns:

Type Description
int

The maximum depth of the node.

upstream_nodes property

upstream_nodes: set[Node]

Get all upstream nodes of the node.

Returns:

Type Description
set[Node]

The upstream nodes of the node.

name instance-attribute

name: str

The name of the filter

inputs class-attribute instance-attribute

inputs: tuple[FilterableStream, ...] = ()

The input streams

input_typings class-attribute instance-attribute

input_typings: tuple[StreamType, ...] = ()

The input typings

output_typings class-attribute instance-attribute

output_typings: tuple[StreamType, ...] = ()

The output typings

replace

replace(old_node: Node, new_node: Node) -> Node

Replace the old node in the graph with the new node.

Parameters:

Name Type Description Default
old_node Node

The old node to replace.

required
new_node Node

The new node to replace with.

required

Returns:

Type Description
Node

The new graph with the replaced node.

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the Node.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

repr

repr() -> str

Get the representation of the node.

Returns:

Type Description
str

The representation of the node.

video

video(index: int) -> 'VideoStream'

Return the video stream at the specified index

Parameters:

Name Type Description Default
index int

the index of the video stream

required

Returns:

Type Description
'VideoStream'

the video stream at the specified index

audio

audio(index: int) -> 'AudioStream'

Return the audio stream at the specified index

Parameters:

Name Type Description Default
index int

the index of the audio stream

required

Returns:

Type Description
'AudioStream'

the audio stream at the specified index

get_args

get_args(context: DAGContext = None) -> list[str]

Get the arguments of the node.

Parameters:

Name Type Description Default
context DAGContext

The DAG context.

None

Returns:

Type Description
list[str]

The arguments of the node.

FilterableStream dataclass

FilterableStream(
    *,
    node: "FilterNode | InputNode",
    index: int | None = None
)

Bases: Stream, OutputArgs

A stream that can be used as input to a filter

Methods:

Name Description
output

Output file URL

view

Visualize the stream.

vfilter

Apply a custom video filter which has only one output to this stream

afilter

Apply a custom audio filter which has only one output to this stream

filter_multi_output

Apply a custom filter which has multiple outputs to this stream

label

Return the label for this stream

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

index int | None

Represents the index of the stream in the node's output streams.

node 'FilterNode | InputNode'

Represents the node that the stream is connected to in the upstream direction.

hex cached property

hex: str

Get the hexadecimal hash of the object.

index class-attribute instance-attribute

index: int | None = None

Represents the index of the stream in the node's output streams.

Note

See Also: Stream specifiers stream_index

node instance-attribute

node: 'FilterNode | InputNode'

Represents the node that the stream is connected to in the upstream direction.

Note

In the context of a data stream, the 'upstream' refers to the source of the data, or where the data is coming from. Therefore, the 'upstream node' is the node that is providing the data to the current stream.

output

output(
    *streams: "FilterableStream",
    filename: str | Path,
    f: String = None,
    c: String = None,
    codec: String = None,
    pre: String = None,
    map: Func = None,
    map_metadata: String = None,
    map_chapters: Int = None,
    t: Time = None,
    to: Time = None,
    fs: Int64 = None,
    ss: Time = None,
    timestamp: Func = None,
    metadata: String = None,
    program: String = None,
    stream_group: String = None,
    dframes: Int64 = None,
    target: Func = None,
    shortest: Boolean = None,
    shortest_buf_duration: Float = None,
    bitexact: Boolean = None,
    apad: String = None,
    copyinkf: Boolean = None,
    copypriorss: Int = None,
    frames: Int64 = None,
    tag: String = None,
    q: Func = None,
    qscale: Func = None,
    profile: Func = None,
    filter: String = None,
    filter_script: String = None,
    attach: Func = None,
    disposition: String = None,
    thread_queue_size: Int = None,
    bits_per_raw_sample: Int = None,
    stats_enc_pre: String = None,
    stats_enc_post: String = None,
    stats_mux_pre: String = None,
    stats_enc_pre_fmt: String = None,
    stats_enc_post_fmt: String = None,
    stats_mux_pre_fmt: String = None,
    vframes: Int64 = None,
    r: String = None,
    fpsmax: String = None,
    s: String = None,
    aspect: String = None,
    pix_fmt: String = None,
    vn: Boolean = None,
    rc_override: String = None,
    vcodec: String = None,
    timecode: Func = None,
    _pass: Int = None,
    passlogfile: String = None,
    vf: String = None,
    intra_matrix: String = None,
    inter_matrix: String = None,
    chroma_intra_matrix: String = None,
    vtag: String = None,
    fps_mode: String = None,
    force_fps: Boolean = None,
    streamid: Func = None,
    force_key_frames: String = None,
    b: Func = None,
    autoscale: Boolean = None,
    fix_sub_duration_heartbeat: Boolean = None,
    aframes: Int64 = None,
    aq: Func = None,
    ar: Int = None,
    ac: Int = None,
    an: Boolean = None,
    acodec: String = None,
    ab: Func = None,
    atag: String = None,
    sample_fmt: String = None,
    channel_layout: String = None,
    ch_layout: String = None,
    af: String = None,
    sn: Boolean = None,
    scodec: String = None,
    stag: String = None,
    muxdelay: Float = None,
    muxpreload: Float = None,
    sdp_file: Func = None,
    time_base: String = None,
    enc_time_base: String = None,
    bsf: String = None,
    apre: String = None,
    vpre: String = None,
    spre: String = None,
    fpre: String = None,
    max_muxing_queue_size: Int = None,
    muxing_queue_data_threshold: Int = None,
    dcodec: String = None,
    dn: Boolean = None,
    top: Int = None,
    **kwargs: Any
) -> OutputStream

Output file URL

Parameters:

Name Type Description Default
*streams 'FilterableStream'

the streams to output

()
filename str | Path

the filename to output to

required
f String

force container format (auto-detected otherwise)

None
c String

select encoder/decoder ('copy' to copy stream without reencoding)

None
codec String

alias for -c (select encoder/decoder)

None
pre String

preset name

None
map Func

set input stream mapping

None
map_metadata String

set metadata information of outfile from infile

None
map_chapters Int

set chapters mapping

None
t Time

stop transcoding after specified duration

None
to Time

stop transcoding after specified time is reached

None
fs Int64

set the limit file size in bytes

None
ss Time

start transcoding at specified time

None
timestamp Func

set the recording timestamp ('now' to set the current time)

None
metadata String

add metadata

None
program String

add program with specified streams

None
stream_group String

add stream group with specified streams and group type-specific arguments

None
dframes Int64

set the number of data frames to output

None
target Func

specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50 "with optional prefixes "pal-", "ntsc-" or "film-")

None
shortest Boolean

finish encoding within shortest input

None
shortest_buf_duration Float

maximum buffering duration (in seconds) for the -shortest option

None
bitexact Boolean

bitexact mode

None
apad String

audio pad

None
copyinkf Boolean

copy initial non-keyframes

None
copypriorss Int

copy or discard frames before start time

None
frames Int64

set the number of frames to output

None
tag String

force codec tag/fourcc

None
q Func

use fixed quality scale (VBR)

None
qscale Func

use fixed quality scale (VBR)

None
profile Func

set profile

None
filter String

apply specified filters to audio/video

None
filter_script String

deprecated, use -/filter

None
attach Func

add an attachment to the output file

None
disposition String

disposition

None
thread_queue_size Int

set the maximum number of queued packets from the demuxer

None
bits_per_raw_sample Int

set the number of bits per raw sample

None
stats_enc_pre String

write encoding stats before encoding

None
stats_enc_post String

write encoding stats after encoding

None
stats_mux_pre String

write packets stats before muxing

None
stats_enc_pre_fmt String

format of the stats written with -stats_enc_pre

None
stats_enc_post_fmt String

format of the stats written with -stats_enc_post

None
stats_mux_pre_fmt String

format of the stats written with -stats_mux_pre

None
vframes Int64

set the number of video frames to output

None
r String

override input framerate/convert to given output framerate (Hz value, fraction or abbreviation)

None
fpsmax String

set max frame rate (Hz value, fraction or abbreviation)

None
s String

set frame size (WxH or abbreviation)

None
aspect String

set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)

None
pix_fmt String

set pixel format

None
vn Boolean

disable video

None
rc_override String

rate control override for specific intervals

None
vcodec String

alias for -c:v (select encoder/decoder for video streams)

None
timecode Func

set initial TimeCode value.

None
_pass Int

select the pass number (1 to 3)

None
passlogfile String

select two pass log file name prefix

None
vf String

alias for -filter:v (apply filters to video streams)

None
intra_matrix String

specify intra matrix coeffs

None
inter_matrix String

specify inter matrix coeffs

None
chroma_intra_matrix String

specify intra matrix coeffs

None
vtag String

force video tag/fourcc

None
fps_mode String

set framerate mode for matching video streams; overrides vsync

None
force_fps Boolean

force the selected framerate, disable the best supported framerate selection

None
streamid Func

set the value of an outfile streamid

None
force_key_frames String

force key frames at specified timestamps

None
b Func

video bitrate (please use -b:v)

None
autoscale Boolean

automatically insert a scale filter at the end of the filter graph

None
fix_sub_duration_heartbeat Boolean

set this video output stream to be a heartbeat stream for fix_sub_duration, according to which subtitles should be split at random access points

None
aframes Int64

set the number of audio frames to output

None
aq Func

set audio quality (codec-specific)

None
ar Int

set audio sampling rate (in Hz)

None
ac Int

set number of audio channels

None
an Boolean

disable audio

None
acodec String

alias for -c:a (select encoder/decoder for audio streams)

None
ab Func

alias for -b:a (select bitrate for audio streams)

None
atag String

force audio tag/fourcc

None
sample_fmt String

set sample format

None
channel_layout String

set channel layout

None
ch_layout String

set channel layout

None
af String

alias for -filter:a (apply filters to audio streams)

None
sn Boolean

disable subtitle

None
scodec String

alias for -c:s (select encoder/decoder for subtitle streams)

None
stag String

force subtitle tag/fourcc

None
muxdelay Float

set the maximum demux-decode delay

None
muxpreload Float

set the initial demux-decode delay

None
sdp_file Func

specify a file in which to print sdp information

None
time_base String

set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)

None
enc_time_base String

set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). two special values are defined - 0 = use frame rate (video) or sample rate (audio),-1 = match source time base

None
bsf String

A comma-separated list of bitstream filters

None
apre String

set the audio options to the indicated preset

None
vpre String

set the video options to the indicated preset

None
spre String

set the subtitle options to the indicated preset

None
fpre String

set options from indicated preset file

None
max_muxing_queue_size Int

maximum number of packets that can be buffered while waiting for all streams to initialize

None
muxing_queue_data_threshold Int

set the threshold after which max_muxing_queue_size is taken into account

None
dcodec String

alias for -c:d (select encoder/decoder for data streams)

None
dn Boolean

disable data

None
top Int

deprecated, use the setfield video filter

None
**kwargs Any

the arguments for the output

{}

Returns:

Type Description
OutputStream

the output stream

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the stream.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

vfilter

vfilter(
    *streams: "FilterableStream",
    name: str,
    input_typings: tuple[StreamType, ...] = (video),
    **kwargs: Any
) -> "VideoStream"

Apply a custom video filter which has only one output to this stream

Parameters:

Name Type Description Default
*streams FilterableStream

the streams to apply the filter to

()
name str

the name of the filter

required
input_typings tuple[StreamType, ...]

the input typings

(video)
**kwargs Any

the arguments for the filter

{}

Returns:

Type Description
'VideoStream'

the output stream

afilter

afilter(
    *streams: "FilterableStream",
    name: str,
    input_typings: tuple[StreamType, ...] = (audio),
    **kwargs: Any
) -> "AudioStream"

Apply a custom audio filter which has only one output to this stream

Parameters:

Name Type Description Default
*streams FilterableStream

the streams to apply the filter to

()
name str

the name of the filter

required
input_typings tuple[StreamType, ...]

the input typings

(audio)
**kwargs Any

the arguments for the filter

{}

Returns:

Type Description
'AudioStream'

the output stream

filter_multi_output

filter_multi_output(
    *streams: "FilterableStream",
    name: str,
    input_typings: tuple[StreamType, ...] = (),
    output_typings: tuple[StreamType, ...] = (),
    **kwargs: Any
) -> "FilterNode"

Apply a custom filter which has multiple outputs to this stream

Parameters:

Name Type Description Default
*streams FilterableStream

the streams to apply the filter to

()
name str

the name of the filter

required
input_typings tuple[StreamType, ...]

the input typings

()
output_typings tuple[StreamType, ...]

the output typings

()
**kwargs Any

the arguments for the filter

{}

Returns:

Type Description
'FilterNode'

the FilterNode

label

label(context: DAGContext = None) -> str

Return the label for this stream

Parameters:

Name Type Description Default
context DAGContext

the DAG context

None

Returns:

Type Description
str

the label for this stream

InputNode dataclass

InputNode(*, kwargs: tuple[tuple[str, str | int | float | bool | LazyValue], ...] = (), inputs: tuple[] = (), filename: str)

Bases: Node

A node that can be used to read from files

Methods:

Name Description
replace

Replace the old node in the graph with the new node.

view

Visualize the Node.

repr

Get the representation of the node.

stream

Return the output stream of this node

get_args

Get the arguments of the node.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

kwargs tuple[tuple[str, str | int | float | bool | LazyValue], ...]

Represents the keyword arguments of the node.

max_depth int

Get the maximum depth of the node.

upstream_nodes set[Node]

Get all upstream nodes of the node.

filename str

The filename to read from

inputs tuple[]

Represents the input streams of the node.

video 'VideoStream'

Return the video stream of this node

audio 'AudioStream'

Return the audio stream of this node

hex cached property

hex: str

Get the hexadecimal hash of the object.

kwargs class-attribute instance-attribute

kwargs: tuple[
    tuple[str, str | int | float | bool | LazyValue], ...
] = ()

Represents the keyword arguments of the node.

max_depth property

max_depth: int

Get the maximum depth of the node.

Returns:

Type Description
int

The maximum depth of the node.

upstream_nodes property

upstream_nodes: set[Node]

Get all upstream nodes of the node.

Returns:

Type Description
set[Node]

The upstream nodes of the node.

filename instance-attribute

filename: str

The filename to read from

inputs class-attribute instance-attribute

inputs: tuple[] = ()

Represents the input streams of the node.

video property

video: 'VideoStream'

Return the video stream of this node

Returns:

Type Description
'VideoStream'

the video stream

audio property

audio: 'AudioStream'

Return the audio stream of this node

Returns:

Type Description
'AudioStream'

the audio stream

replace

replace(old_node: Node, new_node: Node) -> Node

Replace the old node in the graph with the new node.

Parameters:

Name Type Description Default
old_node Node

The old node to replace.

required
new_node Node

The new node to replace with.

required

Returns:

Type Description
Node

The new graph with the replaced node.

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the Node.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

repr

repr() -> str

Get the representation of the node.

Returns:

Type Description
str

The representation of the node.

stream

stream() -> 'AVStream'

Return the output stream of this node

Returns:

Type Description
'AVStream'

the output stream

get_args

get_args(context: DAGContext = None) -> list[str]

Get the arguments of the node.

Parameters:

Name Type Description Default
context DAGContext

The DAG context.

None

Returns:

Type Description
list[str]

The arguments of the node.

OutputNode dataclass

OutputNode(
    *,
    kwargs: tuple[
        tuple[str, str | int | float | bool | LazyValue],
        ...,
    ] = (),
    inputs: tuple[FilterableStream, ...],
    filename: str
)

Bases: Node

Methods:

Name Description
replace

Replace the old node in the graph with the new node.

view

Visualize the Node.

repr

Get the representation of the node.

stream

Return the output stream of this node

get_args

Get the arguments of the node.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

kwargs tuple[tuple[str, str | int | float | bool | LazyValue], ...]

Represents the keyword arguments of the node.

max_depth int

Get the maximum depth of the node.

upstream_nodes set[Node]

Get all upstream nodes of the node.

filename str

The filename to output to

inputs tuple[FilterableStream, ...]

Represents the input streams of the node.

hex cached property

hex: str

Get the hexadecimal hash of the object.

kwargs class-attribute instance-attribute

kwargs: tuple[
    tuple[str, str | int | float | bool | LazyValue], ...
] = ()

Represents the keyword arguments of the node.

max_depth property

max_depth: int

Get the maximum depth of the node.

Returns:

Type Description
int

The maximum depth of the node.

upstream_nodes property

upstream_nodes: set[Node]

Get all upstream nodes of the node.

Returns:

Type Description
set[Node]

The upstream nodes of the node.

filename instance-attribute

filename: str

The filename to output to

inputs instance-attribute

inputs: tuple[FilterableStream, ...]

Represents the input streams of the node.

replace

replace(old_node: Node, new_node: Node) -> Node

Replace the old node in the graph with the new node.

Parameters:

Name Type Description Default
old_node Node

The old node to replace.

required
new_node Node

The new node to replace with.

required

Returns:

Type Description
Node

The new graph with the replaced node.

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the Node.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

repr

repr() -> str

Get the representation of the node.

Returns:

Type Description
str

The representation of the node.

stream

stream() -> 'OutputStream'

Return the output stream of this node

Returns:

Type Description
'OutputStream'

the output stream

get_args

get_args(context: DAGContext = None) -> list[str]

Get the arguments of the node.

Parameters:

Name Type Description Default
context DAGContext

The DAG context.

None

Returns:

Type Description
list[str]

The arguments of the node.

OutputStream dataclass

OutputStream(*, node: OutputNode, index: int | None = None)

Bases: Stream, GlobalRunable

Methods:

Name Description
global_args

Set global options.

merge_outputs

Merge multiple output streams into one.

overwrite_output

Overwrite output files without asking (ffmpeg -y option)

compile

Build command-line for invoking ffmpeg.

compile_line

Build command-line for invoking ffmpeg.

run_async

Run ffmpeg asynchronously.

run

Run ffmpeg synchronously.

view

Visualize the stream.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

index int | None

Represents the index of the stream in the node's output streams.

node OutputNode

Represents the node that the stream is connected to in the upstream direction.

hex cached property

hex: str

Get the hexadecimal hash of the object.

index class-attribute instance-attribute

index: int | None = None

Represents the index of the stream in the node's output streams.

Note

See Also: Stream specifiers stream_index

node instance-attribute

node: OutputNode

Represents the node that the stream is connected to in the upstream direction.

Note

In the context of a data stream, the 'upstream' refers to the source of the data, or where the data is coming from. Therefore, the 'upstream node' is the node that is providing the data to the current stream.

global_args

global_args(
    *,
    loglevel: Func = None,
    v: Func = None,
    report: Func = None,
    max_alloc: Func = None,
    cpuflags: Func = None,
    cpucount: Func = None,
    hide_banner: Boolean = None,
    y: Boolean = None,
    n: Boolean = None,
    ignore_unknown: Boolean = None,
    copy_unknown: Boolean = None,
    recast_media: Boolean = None,
    benchmark: Boolean = None,
    benchmark_all: Boolean = None,
    progress: Func = None,
    stdin: Boolean = None,
    timelimit: Func = None,
    dump: Boolean = None,
    hex: Boolean = None,
    frame_drop_threshold: Float = None,
    copyts: Boolean = None,
    start_at_zero: Boolean = None,
    copytb: Int = None,
    dts_delta_threshold: Float = None,
    dts_error_threshold: Float = None,
    xerror: Boolean = None,
    abort_on: Func = None,
    filter_threads: Func = None,
    filter_complex: Func = None,
    filter_complex_threads: Int = None,
    lavfi: Func = None,
    filter_complex_script: Func = None,
    auto_conversion_filters: Boolean = None,
    stats: Boolean = None,
    stats_period: Func = None,
    debug_ts: Boolean = None,
    max_error_rate: Float = None,
    vstats: Func = None,
    vstats_file: Func = None,
    vstats_version: Int = None,
    init_hw_device: Func = None,
    filter_hw_device: Func = None,
    adrift_threshold: Func = None,
    qphist: Func = None,
    vsync: Func = None,
    **kwargs: Any
) -> GlobalStream

Set global options.

Parameters:

Name Type Description Default
loglevel Func

set logging level

None
v Func

set logging level

None
report Func

generate a report

None
max_alloc Func

set maximum size of a single allocated block

None
cpuflags Func

force specific cpu flags

None
cpucount Func

force specific cpu count

None
hide_banner Boolean

do not show program banner

None
y Boolean

overwrite output files

None
n Boolean

never overwrite output files

None
ignore_unknown Boolean

Ignore unknown stream types

None
copy_unknown Boolean

Copy unknown stream types

None
recast_media Boolean

allow recasting stream type in order to force a decoder of different media type

None
benchmark Boolean

add timings for benchmarking

None
benchmark_all Boolean

add timings for each task

None
progress Func

write program-readable progress information

None
stdin Boolean

enable or disable interaction on standard input

None
timelimit Func

set max runtime in seconds in CPU user time

None
dump Boolean

dump each input packet

None
hex Boolean

when dumping packets, also dump the payload

None
frame_drop_threshold Float

frame drop threshold

None
copyts Boolean

copy timestamps

None
start_at_zero Boolean

shift input timestamps to start at 0 when using copyts

None
copytb Int

copy input stream time base when stream copying

None
dts_delta_threshold Float

timestamp discontinuity delta threshold

None
dts_error_threshold Float

timestamp error delta threshold

None
xerror Boolean

exit on error

None
abort_on Func

abort on the specified condition flags

None
filter_threads Func

number of non-complex filter threads

None
filter_complex Func

create a complex filtergraph

None
filter_complex_threads Int

number of threads for -filter_complex

None
lavfi Func

create a complex filtergraph

None
filter_complex_script Func

deprecated, use -/filter_complex instead

None
auto_conversion_filters Boolean

enable automatic conversion filters globally

None
stats Boolean

print progress report during encoding

None
stats_period Func

set the period at which ffmpeg updates stats and -progress output

None
debug_ts Boolean

print timestamp debugging info

None
max_error_rate Float

ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.

None
vstats Func

dump video coding statistics to file

None
vstats_file Func

dump video coding statistics to file

None
vstats_version Int

Version of the vstats format to use.

None
init_hw_device Func

initialise hardware device

None
filter_hw_device Func

set hardware device used when filtering

None
adrift_threshold Func

deprecated, does nothing

None
qphist Func

deprecated, does nothing

None
vsync Func

set video sync method globally; deprecated, use -fps_mode

None
**kwargs Any

Additional options

{}

Returns:

Name Type Description
GlobalStream GlobalStream

GlobalStream instance

merge_outputs

merge_outputs(*streams: OutputStream) -> GlobalStream

Merge multiple output streams into one.

Parameters:

Name Type Description Default
*streams OutputStream

The output streams to merge.

()

Returns:

Type Description
GlobalStream

The merged output stream.

overwrite_output

overwrite_output() -> GlobalStream

Overwrite output files without asking (ffmpeg -y option)

Returns:

Type Description
GlobalStream

the output stream

compile

compile(
    cmd: str | list[str] = "ffmpeg",
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> list[str]

Build command-line for invoking ffmpeg.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Type Description
list[str]

the command-line

compile_line

compile_line(
    cmd: str | list[str] = "ffmpeg",
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> str

Build command-line for invoking ffmpeg.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Type Description
str

the command-line

run_async

run_async(
    cmd: str | list[str] = "ffmpeg",
    pipe_stdin: bool = False,
    pipe_stdout: bool = False,
    pipe_stderr: bool = False,
    quiet: bool = False,
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> Popen[bytes]

Run ffmpeg asynchronously.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
pipe_stdin bool

whether to pipe stdin

False
pipe_stdout bool

whether to pipe stdout

False
pipe_stderr bool

whether to pipe stderr

False
quiet bool

whether to pipe stderr to stdout

False
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Type Description
Popen[bytes]

the process

run

run(
    cmd: str | list[str] = "ffmpeg",
    capture_stdout: bool = False,
    capture_stderr: bool = False,
    input: bytes | None = None,
    quiet: bool = False,
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> tuple[bytes, bytes]

Run ffmpeg synchronously.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
capture_stdout bool

whether to capture stdout

False
capture_stderr bool

whether to capture stderr

False
input bytes | None

the input

None
quiet bool

whether to pipe stderr to stdout

False
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Name Type Description
stdout bytes

he stdout

stderr bytes

the stderr

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the stream.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

GlobalNode dataclass

GlobalNode(
    *,
    kwargs: tuple[
        tuple[str, str | int | float | bool | LazyValue],
        ...,
    ] = (),
    inputs: tuple[OutputStream, ...]
)

Bases: Node

A node that can be used to set global options

Methods:

Name Description
replace

Replace the old node in the graph with the new node.

view

Visualize the Node.

repr

Get the representation of the node.

stream

Return the output stream of this node

get_args

Get the arguments of the node.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

kwargs tuple[tuple[str, str | int | float | bool | LazyValue], ...]

Represents the keyword arguments of the node.

max_depth int

Get the maximum depth of the node.

upstream_nodes set[Node]

Get all upstream nodes of the node.

inputs tuple[OutputStream, ...]

Represents the input streams of the node.

hex cached property

hex: str

Get the hexadecimal hash of the object.

kwargs class-attribute instance-attribute

kwargs: tuple[
    tuple[str, str | int | float | bool | LazyValue], ...
] = ()

Represents the keyword arguments of the node.

max_depth property

max_depth: int

Get the maximum depth of the node.

Returns:

Type Description
int

The maximum depth of the node.

upstream_nodes property

upstream_nodes: set[Node]

Get all upstream nodes of the node.

Returns:

Type Description
set[Node]

The upstream nodes of the node.

inputs instance-attribute

inputs: tuple[OutputStream, ...]

Represents the input streams of the node.

replace

replace(old_node: Node, new_node: Node) -> Node

Replace the old node in the graph with the new node.

Parameters:

Name Type Description Default
old_node Node

The old node to replace.

required
new_node Node

The new node to replace with.

required

Returns:

Type Description
Node

The new graph with the replaced node.

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the Node.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

repr

repr() -> str

Get the representation of the node.

Returns:

Type Description
str

The representation of the node.

stream

stream() -> 'GlobalStream'

Return the output stream of this node

Returns:

Type Description
'GlobalStream'

the output stream

get_args

get_args(context: DAGContext = None) -> list[str]

Get the arguments of the node.

Parameters:

Name Type Description Default
context DAGContext

The DAG context.

None

Returns:

Type Description
list[str]

The arguments of the node.

GlobalStream dataclass

GlobalStream(*, node: GlobalNode, index: int | None = None)

Bases: Stream, GlobalRunable

Methods:

Name Description
global_args

Set global options.

merge_outputs

Merge multiple output streams into one.

overwrite_output

Overwrite output files without asking (ffmpeg -y option)

compile

Build command-line for invoking ffmpeg.

compile_line

Build command-line for invoking ffmpeg.

run_async

Run ffmpeg asynchronously.

run

Run ffmpeg synchronously.

view

Visualize the stream.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

index int | None

Represents the index of the stream in the node's output streams.

node GlobalNode

Represents the node that the stream is connected to in the upstream direction.

hex cached property

hex: str

Get the hexadecimal hash of the object.

index class-attribute instance-attribute

index: int | None = None

Represents the index of the stream in the node's output streams.

Note

See Also: Stream specifiers stream_index

node instance-attribute

node: GlobalNode

Represents the node that the stream is connected to in the upstream direction.

Note

In the context of a data stream, the 'upstream' refers to the source of the data, or where the data is coming from. Therefore, the 'upstream node' is the node that is providing the data to the current stream.

global_args

global_args(
    *,
    loglevel: Func = None,
    v: Func = None,
    report: Func = None,
    max_alloc: Func = None,
    cpuflags: Func = None,
    cpucount: Func = None,
    hide_banner: Boolean = None,
    y: Boolean = None,
    n: Boolean = None,
    ignore_unknown: Boolean = None,
    copy_unknown: Boolean = None,
    recast_media: Boolean = None,
    benchmark: Boolean = None,
    benchmark_all: Boolean = None,
    progress: Func = None,
    stdin: Boolean = None,
    timelimit: Func = None,
    dump: Boolean = None,
    hex: Boolean = None,
    frame_drop_threshold: Float = None,
    copyts: Boolean = None,
    start_at_zero: Boolean = None,
    copytb: Int = None,
    dts_delta_threshold: Float = None,
    dts_error_threshold: Float = None,
    xerror: Boolean = None,
    abort_on: Func = None,
    filter_threads: Func = None,
    filter_complex: Func = None,
    filter_complex_threads: Int = None,
    lavfi: Func = None,
    filter_complex_script: Func = None,
    auto_conversion_filters: Boolean = None,
    stats: Boolean = None,
    stats_period: Func = None,
    debug_ts: Boolean = None,
    max_error_rate: Float = None,
    vstats: Func = None,
    vstats_file: Func = None,
    vstats_version: Int = None,
    init_hw_device: Func = None,
    filter_hw_device: Func = None,
    adrift_threshold: Func = None,
    qphist: Func = None,
    vsync: Func = None,
    **kwargs: Any
) -> GlobalStream

Set global options.

Parameters:

Name Type Description Default
loglevel Func

set logging level

None
v Func

set logging level

None
report Func

generate a report

None
max_alloc Func

set maximum size of a single allocated block

None
cpuflags Func

force specific cpu flags

None
cpucount Func

force specific cpu count

None
hide_banner Boolean

do not show program banner

None
y Boolean

overwrite output files

None
n Boolean

never overwrite output files

None
ignore_unknown Boolean

Ignore unknown stream types

None
copy_unknown Boolean

Copy unknown stream types

None
recast_media Boolean

allow recasting stream type in order to force a decoder of different media type

None
benchmark Boolean

add timings for benchmarking

None
benchmark_all Boolean

add timings for each task

None
progress Func

write program-readable progress information

None
stdin Boolean

enable or disable interaction on standard input

None
timelimit Func

set max runtime in seconds in CPU user time

None
dump Boolean

dump each input packet

None
hex Boolean

when dumping packets, also dump the payload

None
frame_drop_threshold Float

frame drop threshold

None
copyts Boolean

copy timestamps

None
start_at_zero Boolean

shift input timestamps to start at 0 when using copyts

None
copytb Int

copy input stream time base when stream copying

None
dts_delta_threshold Float

timestamp discontinuity delta threshold

None
dts_error_threshold Float

timestamp error delta threshold

None
xerror Boolean

exit on error

None
abort_on Func

abort on the specified condition flags

None
filter_threads Func

number of non-complex filter threads

None
filter_complex Func

create a complex filtergraph

None
filter_complex_threads Int

number of threads for -filter_complex

None
lavfi Func

create a complex filtergraph

None
filter_complex_script Func

deprecated, use -/filter_complex instead

None
auto_conversion_filters Boolean

enable automatic conversion filters globally

None
stats Boolean

print progress report during encoding

None
stats_period Func

set the period at which ffmpeg updates stats and -progress output

None
debug_ts Boolean

print timestamp debugging info

None
max_error_rate Float

ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.

None
vstats Func

dump video coding statistics to file

None
vstats_file Func

dump video coding statistics to file

None
vstats_version Int

Version of the vstats format to use.

None
init_hw_device Func

initialise hardware device

None
filter_hw_device Func

set hardware device used when filtering

None
adrift_threshold Func

deprecated, does nothing

None
qphist Func

deprecated, does nothing

None
vsync Func

set video sync method globally; deprecated, use -fps_mode

None
**kwargs Any

Additional options

{}

Returns:

Name Type Description
GlobalStream GlobalStream

GlobalStream instance

merge_outputs

merge_outputs(*streams: OutputStream) -> GlobalStream

Merge multiple output streams into one.

Parameters:

Name Type Description Default
*streams OutputStream

The output streams to merge.

()

Returns:

Type Description
GlobalStream

The merged output stream.

overwrite_output

overwrite_output() -> GlobalStream

Overwrite output files without asking (ffmpeg -y option)

Returns:

Type Description
GlobalStream

the output stream

compile

compile(
    cmd: str | list[str] = "ffmpeg",
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> list[str]

Build command-line for invoking ffmpeg.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Type Description
list[str]

the command-line

compile_line

compile_line(
    cmd: str | list[str] = "ffmpeg",
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> str

Build command-line for invoking ffmpeg.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Type Description
str

the command-line

run_async

run_async(
    cmd: str | list[str] = "ffmpeg",
    pipe_stdin: bool = False,
    pipe_stdout: bool = False,
    pipe_stderr: bool = False,
    quiet: bool = False,
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> Popen[bytes]

Run ffmpeg asynchronously.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
pipe_stdin bool

whether to pipe stdin

False
pipe_stdout bool

whether to pipe stdout

False
pipe_stderr bool

whether to pipe stderr

False
quiet bool

whether to pipe stderr to stdout

False
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Type Description
Popen[bytes]

the process

run

run(
    cmd: str | list[str] = "ffmpeg",
    capture_stdout: bool = False,
    capture_stderr: bool = False,
    input: bytes | None = None,
    quiet: bool = False,
    overwrite_output: bool = None,
    auto_fix: bool = True,
) -> tuple[bytes, bytes]

Run ffmpeg synchronously.

Parameters:

Name Type Description Default
cmd str | list[str]

the command to invoke ffmpeg

'ffmpeg'
capture_stdout bool

whether to capture stdout

False
capture_stderr bool

whether to capture stderr

False
input bytes | None

the input

None
quiet bool

whether to pipe stderr to stdout

False
overwrite_output bool

whether to overwrite output files without asking

None
auto_fix bool

whether to automatically fix the stream

True

Returns:

Name Type Description
stdout bytes

he stdout

stderr bytes

the stderr

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the stream.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.