ffmpeg
- exception mautrix.util.ffmpeg.ConverterError
Bases:
ChildProcessError
- exception mautrix.util.ffmpeg.NotInstalledError
- async mautrix.util.ffmpeg.convert_bytes(data, output_extension, input_args=None, output_args=None, input_mime=None, logger=None)
Convert media file data using ffmpeg.
- Parameters
data (bytes) – The bytes of the file to convert.
output_extension (str) – The extension that the output file should be.
input_args (Optional[Iterable[str]]) – Arguments to tell ffmpeg how to parse the input file.
output_args (Optional[Iterable[str]]) – Arguments to tell ffmpeg how to convert the file to reach the wanted output.
input_mime (Optional[str]) – The mime type of the input data. If not specified, will be guessed using magic.
logger (Optional[logging.Logger]) –
- Returns
The converted file as bytes.
- Raises
ConverterError – if ffmpeg returns a non-zero exit code.
- Return type
- async mautrix.util.ffmpeg.convert_path(input_file, output_extension, input_args=None, output_args=None, remove_input=False, output_path_override=None, logger=None)
Convert a media file on the disk using ffmpeg.
- Parameters
input_file (os.PathLike[str] | str) – The full path to the file.
output_extension (str | None) – The extension that the output file should be.
input_args (Optional[Iterable[str]]) – Arguments to tell ffmpeg how to parse the input file.
output_args (Optional[Iterable[str]]) – Arguments to tell ffmpeg how to convert the file to reach the wanted output.
remove_input (bool) – Whether the input file should be removed after converting. Not compatible with
output_path_override
.output_path_override (Optional[Union[os.PathLike[str], str]]) – A custom output path to use (instead of using the input path with a different extension).
logger (Optional[logging.Logger]) –
- Returns
The path to the converted file, or the stdout if
output_path_override
was set to-
.- Raises
ConverterError – if ffmpeg returns a non-zero exit code.
- Return type
- async mautrix.util.ffmpeg.probe_bytes(data, input_mime=None, logger=None)
Probe media file data using ffprobe.
- Parameters
data (bytes) – The bytes of the file to probe.
input_mime (Optional[str]) – The mime type of the input data. If not specified, will be guessed using magic.
logger (Optional[logging.Logger]) –
- Returns
A Python object containing the parsed JSON response from ffprobe
- Raises
ConverterError – if ffprobe returns a non-zero exit code.
- Return type
Any
- async mautrix.util.ffmpeg.probe_path(input_file, logger=None)
Probes a media file on the disk using ffprobe.
- Parameters
input_file (os.PathLike[str] | str) – The full path to the file.
logger (Optional[logging.Logger]) –
- Returns
A Python object containing the parsed JSON response from ffprobe
- Raises
ConverterError – if ffprobe returns a non-zero exit code.
- Return type
Any