Skip to content

info

Re-export from ffmpeg_core.info.

Classes:

Name Description
Codec

Represents an FFmpeg codec with its capabilities and description.

CodecFlags

Flag enumeration representing the capabilities of a codec.

Coder

Represents an FFmpeg encoder or decoder with its capabilities and description.

CoderFlags

Flag enumeration representing the capabilities of a coder (encoder/decoder).

FFMpegExecuteError

Exception raised when an FFmpeg command fails during execution.

Functions:

Name Description
command_line

Convert a list of command arguments to a properly escaped command-line string.

get_codecs

Query the system for all available FFmpeg codecs.

get_coders

Parse the output of an FFmpeg encoder/decoder listing into Coder objects.

get_decoders

Query the system for all available FFmpeg decoders.

get_encoders

Query the system for all available FFmpeg encoders.

parse_codec_flags

Parse the FFmpeg codec flags string into a CodecFlags enum.

parse_coder_flags

Parse the FFmpeg coder flags string into a CoderFlags enum.

Codec dataclass

Codec(name: str, flags: CodecFlags, description: str)

Represents an FFmpeg codec with its capabilities and description.

This immutable dataclass stores information about a codec identified by the ffmpeg -codecs command, including its name, supported features (as flags), and its textual description.

Attributes:

Name Type Description
name str

The codec identifier used in FFmpeg commands

flags CodecFlags

Bitmap of capabilities supported by the codec

description str

Human-readable description of the codec

CodecFlags

Bases: Flag

Flag enumeration representing the capabilities of a codec.

These flags correspond to the character flags in FFmpeg's codec information output and indicate what features a codec supports.

Coder dataclass

Coder(name: str, flags: CoderFlags, description: str)

Represents an FFmpeg encoder or decoder with its capabilities and description.

This dataclass stores information about a coder identified by the ffmpeg -encoders or ffmpeg -decoders command, including its name, supported features (as flags), and its textual description.

Attributes:

Name Type Description
name str

The coder identifier used in FFmpeg commands

flags CoderFlags

Bitmap of capabilities supported by the coder

description str

Human-readable description of the coder

CoderFlags

Bases: Flag

Flag enumeration representing the capabilities of a coder (encoder/decoder).

These flags correspond to the character flags in FFmpeg's encoder/decoder information output and indicate what features a coder supports.

FFMpegExecuteError

FFMpegExecuteError(
    retcode: int | None,
    cmd: str,
    stdout: bytes,
    stderr: bytes,
)

Bases: FFMpegError

Exception raised when an FFmpeg command fails during execution.

This exception is raised when an FFmpeg process returns a non-zero exit code, indicating that the command failed to execute properly. The exception captures the return code, command string, and stdout/stderr output to help diagnose the issue.

Attributes:

Name Type Description
stdout

The standard output of the failed command

stderr

The standard error output of the failed command

cmd

The command string that was executed

retcode

The process return code

Parameters:

Name Type Description Default
retcode int | None

The return code of the FFmpeg command

required
cmd str

The FFmpeg command string that was executed

required
stdout bytes

The captured standard output from the process

required
stderr bytes

The captured standard error from the process

required

command_line

command_line(args: list[str]) -> str

Convert a list of command arguments to a properly escaped command-line string.

This function takes a list of command arguments and converts it to a single string with proper shell escaping applied to each argument. This is useful for logging commands or displaying them to users.

Parameters:

Name Type Description Default
args list[str]

The command arguments to convert to a string

required

Returns:

Type Description
str

A properly escaped command-line string representation of the arguments

Example
cmd = ["ffmpeg", "-i", "input file.mp4", "-c:v", "libx264"]
print(command_line(cmd))  # 'ffmpeg -i "input file.mp4" -c:v libx264'

get_codecs

get_codecs() -> tuple[Codec, ...]

Query the system for all available FFmpeg codecs.

This function calls ffmpeg -codecs and parses the output to create a tuple of Codec objects representing all codecs available on the system.

Returns:

Type Description
tuple[Codec, ...]

A tuple of Codec objects with information about each codec

Raises:

Type Description
FFMpegExecuteError

If the ffmpeg command fails

get_coders

get_coders(codes: str) -> tuple[Coder, ...]

Parse the output of an FFmpeg encoder/decoder listing into Coder objects.

This function parses the text output from ffmpeg -encoders or ffmpeg -decoders commands and constructs Coder objects for each entry.

Parameters:

Name Type Description Default
codes str

String output from the FFmpeg encoders/decoders command

required

Returns:

Type Description
tuple[Coder, ...]

A tuple of Coder objects representing the available encoders/decoders

get_decoders

get_decoders() -> tuple[Coder, ...]

Query the system for all available FFmpeg decoders.

This function calls ffmpeg -decoders and parses the output to create a tuple of Coder objects representing all decoders available on the system.

Returns:

Type Description
tuple[Coder, ...]

A tuple of Coder objects with information about each decoder

Raises:

Type Description
FFMpegExecuteError

If the ffmpeg command fails

get_encoders

get_encoders() -> tuple[Coder, ...]

Query the system for all available FFmpeg encoders.

This function calls ffmpeg -encoders and parses the output to create a tuple of Coder objects representing all encoders available on the system.

Returns:

Type Description
tuple[Coder, ...]

A tuple of Coder objects with information about each encoder

Raises:

Type Description
FFMpegExecuteError

If the ffmpeg command fails

parse_codec_flags

parse_codec_flags(flags: str) -> CodecFlags

Parse the FFmpeg codec flags string into a CodecFlags enum.

This function interprets the character flags from FFmpeg's codec listing and converts them to the corresponding CodecFlags enum values.

Parameters:

Name Type Description Default
flags str

A string of flag characters from FFmpeg codec information

required

Returns:

Type Description
CodecFlags

A CodecFlags bitmap with the appropriate flags set

parse_coder_flags

parse_coder_flags(flags: str) -> CoderFlags

Parse the FFmpeg coder flags string into a CoderFlags enum.

This function interprets the character flags from FFmpeg's encoder/decoder listing and converts them to the corresponding CoderFlags enum values.

Parameters:

Name Type Description Default
flags str

A string of flag characters from FFmpeg encoder/decoder information

required

Returns:

Type Description
CoderFlags

A CoderFlags bitmap with the appropriate flags set