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).
inputsandoutputsare 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
ffmpegcommand will be searched for in thePATH, but can be overridden with an absolute path toffmpegexecutable - global_options (iterable) – global options passed to
ffmpegexecutable (e.g.-y,-vetc.); 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_datacan contain input for FFmpeg in casepipeprotocol is used for input.stdoutandstderrspecify where to redirect thestdoutandstderrof 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 FFmpegpipeprotocol is used for output,stdoutmust be redirected to a pipe by passingsubprocess.PIPEasstdoutargument.Returns a 2-tuple containing
stdoutandstderrof 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 twoNonevalues, otherwise it will contain the actualstdoutandstderrdata returned by ffmpeg process.More info about
pipeprotocol here.参数: 返回: a 2-tuple containing
stdoutandstderrof the process返回类型: Raise: FFRuntimeErrorin case FFmpeg command exits with a non-zero code;FFExecutableNotFoundErrorin 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
PATHbut 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