ffmpeg-python
Advanced tools
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 1.1 | ||
| Metadata-Version: 2.1 | ||
| Name: ffmpeg-python | ||
| Version: 0.1.17 | ||
| Version: 0.1.18 | ||
| Summary: Python bindings for FFmpeg - with complex filtering support | ||
@@ -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.17.zip | ||
| Download-URL: https://github.com/kkroening/ffmpeg-python/archive/v0.1.18.zip | ||
| Description: ffmpeg-python: Python bindings for FFmpeg | ||
@@ -31,1 +31,2 @@ ========================================= | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Provides-Extra: dev |
| future | ||
| [dev] | ||
| future==0.17.1 | ||
| pytest-mock==1.10.4 | ||
| pytest==4.6.1 | ||
| Sphinx==2.1.0 | ||
| tox==3.12.1 | ||
| twine==1.13.0 |
+17
-5
| from __future__ import unicode_literals | ||
| from . import _filters, _ffmpeg, _run, _probe | ||
| from . import nodes | ||
| from . import _ffmpeg | ||
| from . import _filters | ||
| from . import _probe | ||
| from . import _run | ||
| from . import _view | ||
| from .nodes import * | ||
| from ._ffmpeg import * | ||
| from ._filters import * | ||
| from ._ffmpeg import * | ||
| from ._probe import * | ||
| from ._run import * | ||
| from ._view import * | ||
| from ._probe import * | ||
| __all__ = _filters.__all__ + _ffmpeg.__all__ + _run.__all__ + _view.__all__ + _probe.__all__ | ||
| __all__ = ( | ||
| nodes.__all__ | ||
| + _ffmpeg.__all__ | ||
| + _probe.__all__ | ||
| + _run.__all__ | ||
| + _view.__all__ | ||
| + _filters.__all__ | ||
| ) |
@@ -11,3 +11,3 @@ from __future__ import unicode_literals | ||
| This is the same as ``filter_`` except that the filter can produce more than one output. | ||
| This is the same as ``filter`` except that the filter can produce more than one output. | ||
@@ -33,3 +33,3 @@ To reference an output stream, use either the ``.stream`` operator or bracket shorthand: | ||
| ``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation | ||
| is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name | ||
| is missing from ``ffmpeg-python``, you can call ``filter_`` directly to have ``ffmpeg-python`` pass the filter name | ||
| and arguments to ffmpeg verbatim. | ||
@@ -36,0 +36,0 @@ |
+6
-2
| import json | ||
| import subprocess | ||
| from ._run import Error | ||
| from ._utils import convert_kwargs_to_cmd_line_args | ||
| def probe(filename, cmd='ffprobe'): | ||
| def probe(filename, cmd='ffprobe', **kwargs): | ||
| """Run ffprobe on the specified file and return a JSON representation of the output. | ||
@@ -15,3 +16,6 @@ | ||
| """ | ||
| args = [cmd, '-show_format', '-show_streams', '-of', 'json', filename] | ||
| args = [cmd, '-show_format', '-show_streams', '-of', 'json'] | ||
| args += convert_kwargs_to_cmd_line_args(kwargs) | ||
| args += [filename] | ||
| p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
@@ -18,0 +22,0 @@ out, err = p.communicate() |
+3
-13
| from __future__ import unicode_literals | ||
| from .dag import get_outgoing_edges, topo_sort | ||
| from ._utils import basestring | ||
| from ._utils import basestring, convert_kwargs_to_cmd_line_args | ||
| from builtins import str | ||
@@ -32,12 +32,2 @@ from functools import reduce | ||
| def _convert_kwargs_to_cmd_line_args(kwargs): | ||
| args = [] | ||
| for k in sorted(kwargs.keys()): | ||
| v = kwargs[k] | ||
| args.append('-{}'.format(k)) | ||
| if v is not None: | ||
| args.append('{}'.format(v)) | ||
| return args | ||
| def _get_input_args(input_node): | ||
@@ -54,3 +44,3 @@ if input_node.name == input.__name__: | ||
| args += ['-video_size', '{}x{}'.format(video_size[0], video_size[1])] | ||
| args += _convert_kwargs_to_cmd_line_args(kwargs) | ||
| args += convert_kwargs_to_cmd_line_args(kwargs) | ||
| args += ['-i', filename] | ||
@@ -141,3 +131,3 @@ else: | ||
| args += ['-video_size', video_size] | ||
| args += _convert_kwargs_to_cmd_line_args(kwargs) | ||
| args += convert_kwargs_to_cmd_line_args(kwargs) | ||
| args += [filename] | ||
@@ -144,0 +134,0 @@ return args |
+11
-0
@@ -81,1 +81,12 @@ from __future__ import unicode_literals | ||
| return text | ||
| def convert_kwargs_to_cmd_line_args(kwargs): | ||
| """Helper function to build command line arguments out of dict.""" | ||
| args = [] | ||
| for k in sorted(kwargs.keys()): | ||
| v = kwargs[k] | ||
| args.append('-{}'.format(k)) | ||
| if v is not None: | ||
| args.append('{}'.format(v)) | ||
| return args |
+57
-2
@@ -56,4 +56,4 @@ from __future__ import unicode_literals | ||
| input = ffmpeg.input('in.mp4') | ||
| audio = input[:'a'].filter("aecho", 0.8, 0.9, 1000, 0.3) | ||
| video = input[:'v'].hflip() | ||
| audio = input['a'].filter("aecho", 0.8, 0.9, 1000, 0.3) | ||
| video = input['v'].hflip() | ||
| out = ffmpeg.output(audio, video, 'out.mp4') | ||
@@ -67,3 +67,53 @@ """ | ||
| @property | ||
| def audio(self): | ||
| """Select the audio-portion of a stream. | ||
| Some ffmpeg filters drop audio streams, and care must be taken | ||
| to preserve the audio in the final output. The ``.audio`` and | ||
| ``.video`` operators can be used to reference the audio/video | ||
| portions of a stream so that they can be processed separately | ||
| and then re-combined later in the pipeline. This dilemma is | ||
| intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the | ||
| way while users may refer to the official ffmpeg documentation | ||
| as to why certain filters drop audio. | ||
| ``stream.audio`` is a shorthand for ``stream['a']``. | ||
| Example: | ||
| Process the audio and video portions of a stream independently:: | ||
| input = ffmpeg.input('in.mp4') | ||
| audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3) | ||
| video = input.video.hflip() | ||
| out = ffmpeg.output(audio, video, 'out.mp4') | ||
| """ | ||
| return self['a'] | ||
| @property | ||
| def video(self): | ||
| """Select the video-portion of a stream. | ||
| Some ffmpeg filters drop audio streams, and care must be taken | ||
| to preserve the audio in the final output. The ``.audio`` and | ||
| ``.video`` operators can be used to reference the audio/video | ||
| portions of a stream so that they can be processed separately | ||
| and then re-combined later in the pipeline. This dilemma is | ||
| intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the | ||
| way while users may refer to the official ffmpeg documentation | ||
| as to why certain filters drop audio. | ||
| ``stream.video`` is a shorthand for ``stream['v']``. | ||
| Example: | ||
| Process the audio and video portions of a stream independently:: | ||
| input = ffmpeg.input('in.mp4') | ||
| audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3) | ||
| video = input.video.hflip() | ||
| out = ffmpeg.output(audio, video, 'out.mp4') | ||
| """ | ||
| return self['v'] | ||
| def get_stream_map(stream_spec): | ||
@@ -291,1 +341,6 @@ if stream_spec is None: | ||
| return stream_operator(stream_classes={OutputStream}, name=name) | ||
| __all__ = [ | ||
| 'Stream', | ||
| ] |
+4
-3
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 1.1 | ||
| Metadata-Version: 2.1 | ||
| Name: ffmpeg-python | ||
| Version: 0.1.17 | ||
| Version: 0.1.18 | ||
| Summary: Python bindings for FFmpeg - with complex filtering support | ||
@@ -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.17.zip | ||
| Download-URL: https://github.com/kkroening/ffmpeg-python/archive/v0.1.18.zip | ||
| Description: ffmpeg-python: Python bindings for FFmpeg | ||
@@ -31,1 +31,2 @@ ========================================= | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Provides-Extra: dev |
+108
-30
@@ -35,4 +35,6 @@ # ffmpeg-python: Python bindings for FFmpeg | ||
| ## [API reference](https://kkroening.github.io/ffmpeg-python/) | ||
| ## Complex filter graphs | ||
| FFmpeg is extremely powerful, but its command-line interface gets really complicated really quickly - especially when working with signal graphs and doing anything more than trivial. | ||
| FFmpeg is extremely powerful, but its command-line interface gets really complicated rather quickly - especially when working with signal graphs and doing anything more than trivial. | ||
@@ -53,3 +55,3 @@ Take for example a signal graph that looks like this: | ||
| If you're like me and find Python to be powerful and readable, it's easy with `ffmpeg-python`: | ||
| If you're like me and find Python to be powerful and readable, it's easier with `ffmpeg-python`: | ||
| ```python | ||
@@ -73,12 +75,11 @@ import ffmpeg | ||
| `ffmpeg-python` takes care of running `ffmpeg` with the command-line arguments that correspond to the above filter diagram, and it's easy to see what's going on and make changes as needed. | ||
| `ffmpeg-python` takes care of running `ffmpeg` with the command-line arguments that correspond to the above filter diagram, in familiar Python terms. | ||
| <img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/screenshot.png" alt="Screenshot" align="middle" width="60%" /> | ||
| Real-world signal graphs can get a heck of a lot more complex, but `ffmpeg-python` handles them with ease. | ||
| Real-world signal graphs can get a heck of a lot more complex, but `ffmpeg-python` handles arbitrarily large (directed-acyclic) signal graphs. | ||
| ## Installation | ||
| The latest version of `ffmpeg-python` can be acquired via pip: | ||
| The latest version of `ffmpeg-python` can be acquired via a typical pip install: | ||
@@ -89,9 +90,6 @@ ``` | ||
| It's also possible to clone the source and put it on your python path (`$PYTHONPATH`, `sys.path`, etc.): | ||
| Or the source can be cloned and installed from locally: | ||
| ```bash | ||
| $ git clone git@github.com:kkroening/ffmpeg-python.git | ||
| $ export PYTHONPATH=${PYTHONPATH}:ffmpeg-python | ||
| $ python | ||
| >>> import ffmpeg | ||
| git clone git@github.com:kkroening/ffmpeg-python.git | ||
| pip install -e ./ffmpeg-python | ||
| ``` | ||
@@ -107,2 +105,3 @@ | ||
| - [Read raw PCM audio via pipe](https://github.com/kkroening/ffmpeg-python/blob/master/examples/README.md#convert-sound-to-raw-pcm-audio) | ||
| - [JupyterLab/Notebook stream editor](https://github.com/kkroening/ffmpeg-python/blob/master/examples/README.md#jupyter-stream-editor) | ||
@@ -112,18 +111,11 @@ | ||
| See the [Examples README](https://github.com/kkroening/ffmpeg-python/tree/master/examples) for additional examples. | ||
| - [Tensorflow/DeepDream streaming](https://github.com/kkroening/ffmpeg-python/blob/master/examples/README.md#tensorflow-streaming) | ||
| ## [API Reference](https://kkroening.github.io/ffmpeg-python/) | ||
| <img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/dream.png" alt="deep dream streaming" width="40%" /> | ||
| API documentation is automatically generated from python docstrings and hosted on github pages: https://kkroening.github.io/ffmpeg-python/ | ||
| See the [Examples README](https://github.com/kkroening/ffmpeg-python/tree/master/examples) for additional examples. | ||
| Alternatively, standard python help is available, such as at the python REPL prompt as follows: | ||
| ```python | ||
| >>> import ffmpeg | ||
| >>> help(ffmpeg) | ||
| ``` | ||
| ## Custom Filters | ||
| Don't see the filter you're looking for? `ffmpeg-python` includes shorthand notation for some of the most commonly used filters (such as `concat`), but it's easy to use any arbitrary ffmpeg filter: | ||
| Don't see the filter you're looking for? While `ffmpeg-python` includes shorthand notation for some of the most commonly used filters (such as `concat`), all filters can be referenced via the `.filter` operator: | ||
| ```python | ||
@@ -147,8 +139,10 @@ stream = ffmpeg.input('dummy.mp4') | ||
| Arguments with special names such as `-qscale:v` can be specified as a keyword-args dictionary as follows: | ||
| **Special option names:** | ||
| Arguments with special names such as `-qscale:v` (variable bitrate), `-b:v` (constant bitrate), etc. can be specified as a keyword-args dictionary as follows: | ||
| ```python | ||
| ( | ||
| ffmpeg | ||
| .input('dummy.mp4') | ||
| .output('dummy2.mp4', **{'qscale:v': 3}) | ||
| .input('in.mp4') | ||
| .output('out.mp4', **{'qscale:v': 3}) | ||
| .run() | ||
@@ -158,4 +152,72 @@ ) | ||
| **Multiple inputs:** | ||
| Filters that take multiple input streams can be used by passing the input streams as an array to `ffmpeg.filter`: | ||
| ```python | ||
| main = ffmpeg.input('main.mp4') | ||
| logo = ffmpeg.input('logo.png') | ||
| ( | ||
| ffmpeg | ||
| .filter([main, logo], 'overlay', 10, 10) | ||
| .output('out.mp4') | ||
| .run() | ||
| ) | ||
| ``` | ||
| **Multiple outputs:** | ||
| Filters that produce multiple outputs can be used with `.filter_multi_output`: | ||
| ```python | ||
| split = ( | ||
| ffmpeg | ||
| .input('in.mp4') | ||
| .filter_multi_output('split') # or `.split()` | ||
| ) | ||
| ( | ||
| ffmpeg | ||
| .concat(split[0], split[1].reverse()) | ||
| .output('out.mp4') | ||
| .run() | ||
| ) | ||
| ``` | ||
| (In this particular case, `.split()` is the equivalent shorthand, but the general approach works for other multi-output filters) | ||
| **String expressions:** | ||
| Expressions to be interpreted by ffmpeg can be included as string parameters and reference any special ffmpeg variable names: | ||
| ```python | ||
| ( | ||
| ffmpeg | ||
| .input('in.mp4') | ||
| .filter('crop', 'in_w-2*10', 'in_h-2*20') | ||
| .input('out.mp4') | ||
| ) | ||
| ``` | ||
| <br /> | ||
| When in doubt, refer to the [existing filters](https://github.com/kkroening/ffmpeg-python/blob/master/ffmpeg/_filters.py), [examples](https://github.com/kkroening/ffmpeg-python/tree/master/examples), and/or the [official ffmpeg documentation](https://ffmpeg.org/ffmpeg-filters.html). | ||
| ## Frequently asked questions | ||
| **Why do I get an import/attribute/etc. error from `import ffmpeg`?** | ||
| Make sure you ran `pip install ffmpeg-python` and not `pip install ffmpeg` or `pip install python-ffmpeg`. | ||
| **Why did my audio stream get dropped?** | ||
| Some ffmpeg filters drop audio streams, and care must be taken to preserve the audio in the final output. The ``.audio`` and ``.video`` operators can be used to reference the audio/video portions of a stream so that they can be processed separately and then re-combined later in the pipeline. | ||
| This dilemma is intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the way while users may refer to the official ffmpeg documentation as to why certain filters drop audio. | ||
| As usual, take a look at the [examples](https://github.com/kkroening/ffmpeg-python/tree/master/examples#audiovideo-pipeline) (*Audio/video pipeline* in particular). | ||
| **How do I do XYZ?** | ||
| Take a look at each of the links in the [Additional Resources](https://kkroening.github.io/ffmpeg-python/) section at the end of this README. If you look everywhere and can't find what you're looking for and have a question that may be relevant to other users, you may open an issue asking how to do it, while providing a thorough explanation of what you're trying to do and what you've tried so far. | ||
| Issues not directly related to `ffmpeg-python` or issues asking others to write your code for you or how to do the work of solving a complex signal processing problem for you that's not relevant to other users will be closed. | ||
| That said, we hope to continue improving our documentation and provide a community of support for people using `ffmpeg-python` to do cool and exciting things. | ||
| ## Contributing | ||
@@ -165,8 +227,22 @@ | ||
| Feel free to report any bugs or submit feature requests. | ||
| One of the best things you can do to help make `ffmpeg-python` better is to answer [open questions](https://github.com/kkroening/ffmpeg-python/labels/question) in the issue tracker. The questions that are answered will be tagged and incorporated into the documentation, examples, and other learning resources. | ||
| It's generally straightforward to use filters that aren't explicitly built into `ffmpeg-python` but if there's a feature you'd like to see included in the library, head over to the [issue tracker](https://github.com/kkroening/ffmpeg-python/issues). | ||
| If you notice things that could be better in the documentation or overall development experience, please say so in the [issue tracker](https://github.com/kkroening/ffmpeg-python/issues). And of course, feel free to report any bugs or submit feature requests. | ||
| Pull requests are welcome as well. | ||
| Pull requests are welcome as well, but it wouldn't hurt to touch base in the issue tracker or hop on the [Matrix chat channel](https://riot.im/app/#/room/#ffmpeg-python:matrix.org) first. | ||
| Anyone who fixes any of the [open bugs](https://github.com/kkroening/ffmpeg-python/labels/bug) or implements [requested enhancements](https://github.com/kkroening/ffmpeg-python/labels/enhancement) is a hero, but changes should include passing tests. | ||
| ### Running tests | ||
| ```bash | ||
| git clone git@github.com:kkroening/ffmpeg-python.git | ||
| cd ffmpeg-python | ||
| virtualenv venv | ||
| . venv/bin/activate # (OS X / Linux) | ||
| venv\bin\activate # (Windows) | ||
| pip install -e .[dev] | ||
| pytest | ||
| ``` | ||
| <br /> | ||
@@ -184,7 +260,9 @@ | ||
| - [API Reference](https://kkroening.github.io/ffmpeg-python/) | ||
| - [Examples](https://github.com/kkroening/ffmpeg-python/tree/master/examples) | ||
| - [Filters](https://github.com/kkroening/ffmpeg-python/blob/master/ffmpeg/_filters.py) | ||
| - [Tests](https://github.com/kkroening/ffmpeg-python/blob/master/ffmpeg/tests/test_ffmpeg.py) | ||
| - [FFmpeg Homepage](https://ffmpeg.org/) | ||
| - [FFmpeg Documentation](https://ffmpeg.org/ffmpeg.html) | ||
| - [FFmpeg Filters Documentation](https://ffmpeg.org/ffmpeg-filters.html) | ||
| - [Test cases](https://github.com/kkroening/ffmpeg-python/blob/master/ffmpeg/tests/test_ffmpeg.py) | ||
| - [Issue tracker](https://github.com/kkroening/ffmpeg-python/issues) | ||
| - Matrix Chat: [#ffmpeg-python:matrix.org](https://riot.im/app/#/room/#ffmpeg-python:matrix.org) |
+11
-1
| from setuptools import setup | ||
| from textwrap import dedent | ||
| version = '0.1.17' | ||
| version = '0.1.18' | ||
| download_url = 'https://github.com/kkroening/ffmpeg-python/archive/v{}.zip'.format(version) | ||
@@ -70,2 +70,12 @@ | ||
| install_requires=['future'], | ||
| extras_require={ | ||
| 'dev': [ | ||
| 'future==0.17.1', | ||
| 'pytest-mock==1.10.4', | ||
| 'pytest==4.6.1', | ||
| 'Sphinx==2.1.0', | ||
| 'tox==3.12.1', | ||
| 'twine==1.13.0', | ||
| ], | ||
| }, | ||
| classifiers=[ | ||
@@ -72,0 +82,0 @@ 'Intended Audience :: Developers', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
78774
9.19%1391
5.3%