Skip to content

io

Input/output utilities for FFmpeg DAG operations.

Modules:

Name Description
output_args

Output arguments.

Functions:

Name Description
input

Input file URL (ffmpeg -i option)

output

Output file URL

input

input(
    filename: str | Path,
    *,
    f: Func = None,
    c: Func = None,
    codec: Func = None,
    t: Func = None,
    to: Func = None,
    ss: Func = None,
    sseof: Func = None,
    seek_timestamp: Func = None,
    accurate_seek: Func = None,
    isync: Func = None,
    itsoffset: Func = None,
    itsscale: Func = None,
    re: Func = None,
    readrate: Func = None,
    bitexact: Func = None,
    tag: Func = None,
    reinit_filter: Func = None,
    dump_attachment: Func = None,
    stream_loop: Func = None,
    discard: Func = None,
    thread_queue_size: Func = None,
    find_stream_info: Func = None,
    r: Func = None,
    s: Func = None,
    pix_fmt: Func = None,
    vn: Func = None,
    vcodec: Func = None,
    top: Func = None,
    vtag: Func = None,
    hwaccel: Func = None,
    hwaccel_device: Func = None,
    hwaccel_output_format: Func = None,
    autorotate: Func = None,
    ar: Func = None,
    ac: Func = None,
    an: Func = None,
    acodec: Func = None,
    sample_fmt: Func = None,
    channel_layout: Func = None,
    ch_layout: Func = None,
    guess_layout_max: Func = None,
    sn: Func = None,
    scodec: Func = None,
    fix_sub_duration: Func = None,
    canvas_size: Func = None,
    bsf: Func = None,
    dcodec: Func = None,
    dn: Func = None,
    decoder_options: FFMpegDecoderOption | None = None,
    demuxer_options: FFMpegDemuxerOption | None = None,
    format_options: (
        FFMpegAVFormatContextDecoderOption | None
    ) = None,
    codec_options: (
        FFMpegAVCodecContextDecoderOption | None
    ) = None,
    extra_options: dict[str, Any] | None = None
) -> AVStream

Input file URL (ffmpeg -i option)

Parameters:

Name Type Description Default
filename str | Path

Input file URL

required
f Func

force format

None
c Func

codec name

None
codec Func

codec name

None
t Func

record or transcode "duration" seconds of audio/video

None
to Func

record or transcode stop time

None
ss Func

set the start time offset

None
sseof Func

set the start time offset relative to EOF

None
seek_timestamp Func

enable/disable seeking by timestamp with -ss

None
accurate_seek Func

enable/disable accurate seeking with -ss

None
isync Func

Indicate the input index for sync reference

None
itsoffset Func

set the input ts offset

None
itsscale Func

set the input ts scale

None
re Func

read input at native frame rate; equivalent to -readrate 1

None
readrate Func

read input at specified rate

None
bitexact Func

bitexact mode

None
tag Func

force codec tag/fourcc

None
reinit_filter Func

reinit filtergraph on input parameter changes

None
dump_attachment Func

extract an attachment into a file

None
stream_loop Func

set number of times input stream shall be looped

None
discard Func

discard

None
thread_queue_size Func

set the maximum number of queued packets from the demuxer

None
find_stream_info Func

read and decode the streams to fill missing information with heuristics

None
r Func

set frame rate (Hz value, fraction or abbreviation)

None
s Func

set frame size (WxH or abbreviation)

None
pix_fmt Func

set pixel format

None
vn Func

disable video

None
vcodec Func

force video codec ('copy' to copy stream)

None
top Func

top=1/bottom=0/auto=-1 field first

None
vtag Func

force video tag/fourcc

None
hwaccel Func

use HW accelerated decoding

None
hwaccel_device Func

select a device for HW acceleration

None
hwaccel_output_format Func

select output format used with HW accelerated decoding

None
autorotate Func

automatically insert correct rotate filters

None
ar Func

set audio sampling rate (in Hz)

None
ac Func

set number of audio channels

None
an Func

disable audio

None
acodec Func

force audio codec ('copy' to copy stream)

None
sample_fmt Func

set sample format

None
channel_layout Func

set channel layout

None
ch_layout Func

set channel layout

None
guess_layout_max Func

set the maximum number of channels to try to guess the channel layout

None
sn Func

disable subtitle

None
scodec Func

force subtitle codec ('copy' to copy stream)

None
fix_sub_duration Func

fix subtitles duration

None
canvas_size Func

set canvas size (WxH or abbreviation)

None
bsf Func

A comma-separated list of bitstream filters

None
dcodec Func

force data codec ('copy' to copy stream)

None
dn Func

disable data

None
decoder_options FFMpegDecoderOption | None

ffmpeg's decoder options

None
demuxer_options FFMpegDemuxerOption | None

ffmpeg's demuxer options

None
format_options FFMpegAVFormatContextDecoderOption | None

ffmpeg's AVFormatContext options

None
codec_options FFMpegAVCodecContextDecoderOption | None

ffmpeg's AVCodecContext options

None
extra_options dict[str, Any] | None

ffmpeg's input file options

None

Returns:

Type Description
AVStream

Input stream

Examples:

>>> input('input.mp4')
<AVStream:input.mp4:0>

output

output(
    *streams: FilterableStream,
    filename: str | Path,
    f: Func = None,
    c: Func = None,
    codec: Func = None,
    pre: Func = None,
    map: Func = None,
    map_channel: Func = None,
    map_metadata: Func = None,
    map_chapters: Func = None,
    t: Func = None,
    to: Func = None,
    fs: Func = None,
    ss: Func = None,
    timestamp: Func = None,
    metadata: Func = None,
    program: Func = None,
    dframes: Func = None,
    target: Func = None,
    shortest: Func = None,
    bitexact: Func = None,
    apad: Func = None,
    copyinkf: Func = None,
    copypriorss: Func = None,
    frames: Func = None,
    tag: Func = None,
    q: Func = None,
    qscale: Func = None,
    profile: Func = None,
    filter: Func = None,
    filter_script: Func = None,
    attach: Func = None,
    disposition: Func = None,
    bits_per_raw_sample: Func = None,
    vframes: Func = None,
    r: Func = None,
    fpsmax: Func = None,
    s: Func = None,
    aspect: Func = None,
    pix_fmt: Func = None,
    vn: Func = None,
    rc_override: Func = None,
    vcodec: Func = None,
    timecode: Func = None,
    _pass: Func = None,
    passlogfile: Func = None,
    vf: Func = None,
    intra_matrix: Func = None,
    inter_matrix: Func = None,
    chroma_intra_matrix: Func = None,
    top: Func = None,
    vtag: Func = None,
    fps_mode: Func = None,
    force_fps: Func = None,
    streamid: Func = None,
    force_key_frames: Func = None,
    ab: Func = None,
    b: Func = None,
    autoscale: Func = None,
    aframes: Func = None,
    aq: Func = None,
    ar: Func = None,
    ac: Func = None,
    an: Func = None,
    acodec: Func = None,
    atag: Func = None,
    sample_fmt: Func = None,
    channel_layout: Func = None,
    ch_layout: Func = None,
    af: Func = None,
    sn: Func = None,
    scodec: Func = None,
    stag: Func = None,
    muxdelay: Func = None,
    muxpreload: Func = None,
    sdp_file: Func = None,
    time_base: Func = None,
    enc_time_base: Func = None,
    bsf: Func = None,
    absf: Func = None,
    vbsf: Func = None,
    apre: Func = None,
    vpre: Func = None,
    spre: Func = None,
    fpre: Func = None,
    max_muxing_queue_size: Func = None,
    muxing_queue_data_threshold: Func = None,
    dcodec: Func = None,
    dn: Func = None,
    encoder_options: FFMpegEncoderOption | None = None,
    muxer_options: FFMpegMuxerOption | None = None,
    format_options: (
        FFMpegAVFormatContextEncoderOption | None
    ) = None,
    codec_options: (
        FFMpegAVCodecContextEncoderOption | None
    ) = None,
    extra_options: dict[str, Any] | None = None
) -> 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 Func

force format

None
c Func

codec name

None
codec Func

codec name

None
pre Func

preset name

None
map Func

set input stream mapping

None
map_channel Func

map an audio channel from one stream to another

None
map_metadata Func

set metadata information of outfile from infile

None
map_chapters Func

set chapters mapping

None
t Func

record or transcode "duration" seconds of audio/video

None
to Func

record or transcode stop time

None
fs Func

set the limit file size in bytes

None
ss Func

set the start time offset

None
timestamp Func

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

None
metadata Func

add metadata

None
program Func

add program with specified streams

None
dframes Func

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 Func

finish encoding within shortest input

None
bitexact Func

bitexact mode

None
apad Func

audio pad

None
copyinkf Func

copy initial non-keyframes

None
copypriorss Func

copy or discard frames before start time

None
frames Func

set the number of frames to output

None
tag Func

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 Func

set stream filtergraph

None
filter_script Func

read stream filtergraph description from a file

None
attach Func

add an attachment to the output file

None
disposition Func

disposition

None
bits_per_raw_sample Func

set the number of bits per raw sample

None
vframes Func

set the number of video frames to output

None
r Func

set frame rate (Hz value, fraction or abbreviation)

None
fpsmax Func

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

None
s Func

set frame size (WxH or abbreviation)

None
aspect Func

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

None
pix_fmt Func

set pixel format

None
vn Func

disable video

None
rc_override Func

rate control override for specific intervals

None
vcodec Func

force video codec ('copy' to copy stream)

None
timecode Func

set initial TimeCode value.

None
_pass Func

select the pass number (1 to 3)

None
passlogfile Func

select two pass log file name prefix

None
vf Func

set video filters

None
intra_matrix Func

specify intra matrix coeffs

None
inter_matrix Func

specify inter matrix coeffs

None
chroma_intra_matrix Func

specify intra matrix coeffs

None
top Func

top=1/bottom=0/auto=-1 field first

None
vtag Func

force video tag/fourcc

None
fps_mode Func

set framerate mode for matching video streams; overrides vsync

None
force_fps Func

force the selected framerate, disable the best supported framerate selection

None
streamid Func

set the value of an outfile streamid

None
force_key_frames Func

force key frames at specified timestamps

None
ab Func

audio bitrate (please use -b:a)

None
b Func

video bitrate (please use -b:v)

None
autoscale Func

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

None
aframes Func

set the number of audio frames to output

None
aq Func

set audio quality (codec-specific)

None
ar Func

set audio sampling rate (in Hz)

None
ac Func

set number of audio channels

None
an Func

disable audio

None
acodec Func

force audio codec ('copy' to copy stream)

None
atag Func

force audio tag/fourcc

None
sample_fmt Func

set sample format

None
channel_layout Func

set channel layout

None
ch_layout Func

set channel layout

None
af Func

set audio filters

None
sn Func

disable subtitle

None
scodec Func

force subtitle codec ('copy' to copy stream)

None
stag Func

force subtitle tag/fourcc

None
muxdelay Func

set the maximum demux-decode delay

None
muxpreload Func

set the initial demux-decode delay

None
sdp_file Func

specify a file in which to print sdp information

None
time_base Func

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

None
enc_time_base Func

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 Func

A comma-separated list of bitstream filters

None
absf Func

deprecated

None
vbsf Func

deprecated

None
apre Func

set the audio options to the indicated preset

None
vpre Func

set the video options to the indicated preset

None
spre Func

set the subtitle options to the indicated preset

None
fpre Func

set options from indicated preset file

None
max_muxing_queue_size Func

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

None
muxing_queue_data_threshold Func

set the threshold after which max_muxing_queue_size is taken into account

None
dcodec Func

force data codec ('copy' to copy stream)

None
dn Func

disable data

None
encoder_options FFMpegEncoderOption | None

ffmpeg's encoder options

None
muxer_options FFMpegMuxerOption | None

ffmpeg's muxer options

None
format_options FFMpegAVFormatContextEncoderOption | None

ffmpeg's AVFormatContext options

None
codec_options FFMpegAVCodecContextEncoderOption | None

ffmpeg's AVCodecContext options

None
extra_options dict[str, Any] | None

the arguments for the output

None

Returns:

Type Description
OutputStream

the output stream