ffmpy¶
-
class
ffmpy.
FFmpeg
(executable='ffmpeg', global_options=None, inputs=None, outputs=None)[源代码]¶ Wrapper for various FFmpeg related applications (ffmpeg, ffprobe).
Initialize FFmpeg command line wrapper.
Compiles FFmpeg command line from passed arguments (executable path, options, inputs and outputs).
inputs
andoutputs
are dictionares containing inputs/outputs as keys and their respective options as values. One dictionary value (set of options) must be either a single space separated string, or a list or strings without spaces (i.e. each part of the option is a separate item of the list, the result of callingsplit()
on the options string). If the value is a list, it cannot be mixed, i.e. cannot contain items with spaces. An exception are complex FFmpeg command lines that contain quotes: the quoted part must be one string, even if it contains spaces (see Examples for more info). For more info about FFmpeg command line format see here.参数: - executable (str) – path to ffmpeg executable; by default the
ffmpeg
command will be searched for in thePATH
, but can be overridden with an absolute path toffmpeg
executable - global_options (iterable) – global options passed to
ffmpeg
executable (e.g.-y
,-v
etc.); can be specified either as a list/tuple/set of strings, or one space-separated string; by default no global options are passed - inputs (dict) – a dictionary specifying one or more input arguments as keys with their corresponding options (either as a list of strings or a single space separated string) as values
- outputs (dict) – a dictionary specifying one or more output arguments as keys with their corresponding options (either as a list of strings or a single space separated string) as values
-
run
(input_data=None, stdout=None, stderr=None)[源代码]¶ Execute FFmpeg command line.
input_data
can contain input for FFmpeg in casepipe
protocol is used for input.stdout
andstderr
specify where to redirect thestdout
andstderr
of the process. By default no redirection is done, which means all output goes to running shell (this mode should normally only be used for debugging purposes). If FFmpegpipe
protocol is used for output,stdout
must be redirected to a pipe by passingsubprocess.PIPE
asstdout
argument.Returns a 2-tuple containing
stdout
andstderr
of the process. If there was no redirection or if the output was redirected to e.g.os.devnull
, the value returned will be a tuple of twoNone
values, otherwise it will contain the actualstdout
andstderr
data returned by ffmpeg process.More info about
pipe
protocol here.参数: 返回: a 2-tuple containing
stdout
andstderr
of the process返回类型: Raise: FFRuntimeError
in case FFmpeg command exits with a non-zero code;FFExecutableNotFoundError
in case the executable path passed was not valid
- executable (str) – path to ffmpeg executable; by default the
-
class
ffmpy.
FFprobe
(executable='ffprobe', global_options='', inputs=None)[源代码]¶ Wrapper for ffprobe.
Create an instance of FFprobe.
Compiles FFprobe command line from passed arguments (executable path, options, inputs). FFprobe executable by default is taken from
PATH
but can be overridden with an absolute path. For more info about FFprobe command line format see here.参数: - executable (str) – absolute path to ffprobe executable
- global_options (iterable) – global options passed to ffmpeg executable; can be specified either as a list/tuple of strings or a space-separated string
- inputs (dict) – a dictionary specifying one or more inputs as keys with their corresponding options as values