ffmpeg-python
Advanced tools
| Metadata-Version: 1.1 | ||
| Name: ffmpeg-python | ||
| Version: 0.1.11 | ||
| Version: 0.1.12 | ||
| Summary: Python bindings for FFmpeg - with support for complex filtering | ||
@@ -9,3 +9,3 @@ Home-page: https://github.com/kkroening/ffmpeg-python | ||
| License: UNKNOWN | ||
| Download-URL: https://github.com/kkroening/ffmpeg-python/archive/v0.1.11.zip | ||
| Download-URL: https://github.com/kkroening/ffmpeg-python/archive/v0.1.12.zip | ||
| Description: ffmpeg-python: Python bindings for FFmpeg | ||
@@ -12,0 +12,0 @@ ========================================= |
+12
-1
@@ -19,2 +19,7 @@ from __future__ import unicode_literals | ||
| Any supplied kwargs are passed to ffmpeg verbatim (e.g. ``t=20``, | ||
| ``f='mp4'``, ``acodec='pcm'``, etc.). | ||
| To tell ffmpeg to read from stdin, use ``pipe:`` as the filename. | ||
| Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__ | ||
@@ -61,4 +66,10 @@ """ | ||
| If multiple streams are provided, they are mapped to the same output. | ||
| If multiple streams are provided, they are mapped to the same | ||
| output. | ||
| Any supplied kwargs are passed to ffmpeg verbatim (e.g. ``t=20``, | ||
| ``f='mp4'``, ``acodec='pcm'``, etc.). | ||
| To tell ffmpeg to write to stdout, use ``pipe:`` as the filename. | ||
| Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__ | ||
@@ -65,0 +76,0 @@ """ |
+6
-10
| import json | ||
| import subprocess | ||
| from ._run import Error | ||
| class ProbeException(Exception): | ||
| def __init__(self, stderr_output): | ||
| super(ProbeException, self).__init__('ffprobe error') | ||
| self.stderr_output = stderr_output | ||
| def probe(filename): | ||
@@ -15,4 +10,6 @@ """Run ffprobe on the specified file and return a JSON representation of the output. | ||
| Raises: | ||
| ProbeException: if ffprobe returns a non-zero exit code, a ``ProbeException`` is returned with a generic error | ||
| message. The stderr output can be retrieved by accessing the ``stderr_output`` property of the exception. | ||
| :class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code, | ||
| an :class:`Error` is returned with a generic error message. | ||
| The stderr output can be retrieved by accessing the | ||
| ``stderr`` property of the exception. | ||
| """ | ||
@@ -23,3 +20,3 @@ args = ['ffprobe', '-show_format', '-show_streams', '-of', 'json', filename] | ||
| if p.returncode != 0: | ||
| raise ProbeException(err) | ||
| raise Error('ffprobe', out, err) | ||
| return json.loads(out.decode('utf-8')) | ||
@@ -30,3 +27,2 @@ | ||
| 'probe', | ||
| 'ProbeException', | ||
| ] |
+52
-14
| from __future__ import unicode_literals | ||
| from .dag import get_outgoing_edges, topo_sort | ||
| from ._utils import basestring | ||
| from builtins import str | ||
| from functools import reduce | ||
| from past.builtins import basestring | ||
| from .dag import get_outgoing_edges, topo_sort | ||
| from functools import reduce | ||
| from ._utils import basestring | ||
| import copy | ||
| import operator | ||
| import subprocess as _subprocess | ||
| import subprocess | ||
@@ -26,2 +26,9 @@ from ._ffmpeg import ( | ||
| class Error(Exception): | ||
| def __init__(self, cmd, stdout, stderr): | ||
| super(Error, self).__init__('{} error (see stderr output for detail)'.format(cmd)) | ||
| self.stdout = stdout | ||
| self.stderr = stderr | ||
| def _convert_kwargs_to_cmd_line_args(kwargs): | ||
@@ -84,4 +91,5 @@ args = [] | ||
| # TODO: automatically insert `splits` ahead of time via graph transformation. | ||
| raise ValueError('Encountered {} with multiple outgoing edges with same upstream label {!r}; a ' | ||
| '`split` filter is probably required'.format(upstream_node, upstream_label)) | ||
| raise ValueError( | ||
| 'Encountered {} with multiple outgoing edges with same upstream label {!r}; a ' | ||
| '`split` filter is probably required'.format(upstream_node, upstream_label)) | ||
| stream_name_map[upstream_node, upstream_label] = 's{}'.format(stream_count) | ||
@@ -127,3 +135,3 @@ stream_count += 1 | ||
| def get_args(stream_spec, overwrite_output=False): | ||
| """Get command-line arguments for ffmpeg.""" | ||
| """Build command-line arguments to be passed to ffmpeg.""" | ||
| nodes = get_stream_spec_nodes(stream_spec) | ||
@@ -150,4 +158,13 @@ args = [] | ||
| @output_operator() | ||
| def compile(stream_spec, cmd='ffmpeg', **kwargs): | ||
| """Build command-line for ffmpeg.""" | ||
| def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): | ||
| """Build command-line for invoking ffmpeg. | ||
| The :meth:`run` function uses this to build the commnad line | ||
| arguments and should work in most cases, but calling this function | ||
| directly is useful for debugging or if you need to invoke ffmpeg | ||
| manually for whatever reason. | ||
| This is the same as calling :meth:`get_args` except that it also | ||
| includes the ``ffmpeg`` command as the first argument. | ||
| """ | ||
| if isinstance(cmd, basestring): | ||
@@ -157,13 +174,33 @@ cmd = [cmd] | ||
| cmd = list(cmd) | ||
| return cmd + get_args(stream_spec, **kwargs) | ||
| return cmd + get_args(stream_spec, overwrite_output=overwrite_output) | ||
| @output_operator() | ||
| def run(stream_spec, cmd='ffmpeg', **kwargs): | ||
| """Run ffmpeg on node graph. | ||
| def run( | ||
| stream_spec, cmd='ffmpeg', capture_stdout=False, capture_stderr=False, input=None, | ||
| quiet=False, overwrite_output=False): | ||
| """Ivoke ffmpeg for the supplied node graph. | ||
| Args: | ||
| **kwargs: keyword-arguments passed to ``get_args()`` (e.g. ``overwrite_output=True``). | ||
| capture_stdout: if True, capture stdout (to be used with | ||
| ``pipe:`` ffmpeg outputs). | ||
| capture_stderr: if True, capture stderr. | ||
| quiet: shorthand for setting ``capture_stdout`` and ``capture_stderr``. | ||
| input: text to be sent to stdin (to be used with ``pipe:`` | ||
| ffmpeg inputs) | ||
| **kwargs: keyword-arguments passed to ``get_args()`` (e.g. | ||
| ``overwrite_output=True``). | ||
| Returns: (out, err) tuple containing captured stdout and stderr data. | ||
| """ | ||
| _subprocess.check_call(compile(stream_spec, cmd, **kwargs)) | ||
| args = compile(stream_spec, cmd, overwrite_output=overwrite_output) | ||
| stdin_stream = subprocess.PIPE if input else None | ||
| stdout_stream = subprocess.PIPE if capture_stdout or quiet else None | ||
| stderr_stream = subprocess.PIPE if capture_stderr or quiet else None | ||
| p = subprocess.Popen(args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream) | ||
| out, err = p.communicate(input) | ||
| retcode = p.poll() | ||
| if retcode: | ||
| raise Error('ffmpeg', out, err) | ||
| return out, err | ||
@@ -173,4 +210,5 @@ | ||
| 'compile', | ||
| 'Error', | ||
| 'get_args', | ||
| 'run', | ||
| ] |
+2
-2
| Metadata-Version: 1.1 | ||
| Name: ffmpeg-python | ||
| Version: 0.1.11 | ||
| Version: 0.1.12 | ||
| Summary: Python bindings for FFmpeg - with support for complex filtering | ||
@@ -9,3 +9,3 @@ Home-page: https://github.com/kkroening/ffmpeg-python | ||
| License: UNKNOWN | ||
| Download-URL: https://github.com/kkroening/ffmpeg-python/archive/v0.1.11.zip | ||
| Download-URL: https://github.com/kkroening/ffmpeg-python/archive/v0.1.12.zip | ||
| Description: ffmpeg-python: Python bindings for FFmpeg | ||
@@ -12,0 +12,0 @@ ========================================= |
+2
-2
| from setuptools import setup | ||
| from textwrap import dedent | ||
| version = '0.1.11' | ||
| version = '0.1.12' | ||
| download_url = 'https://github.com/kkroening/ffmpeg-python/archive/v{}.zip'.format(version) | ||
@@ -60,3 +60,3 @@ | ||
| setup_requires=['pytest-runner'], | ||
| tests_require=['pytest'], | ||
| tests_require=['pytest', 'pytest-mock'], | ||
| version=version, | ||
@@ -63,0 +63,0 @@ description='Python bindings for FFmpeg - with support for complex filtering', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
65191
2.94%1196
3.28%