Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ As usual, take a look at the [examples](https://github.com/kkroening/ffmpeg-pyth

You can run `stream.get_args()` before `stream.run()` to retrieve the command line arguments that will be passed to `ffmpeg`. You can also run `stream.compile()` that also includes the `ffmpeg` executable as the first argument.

**How do I read stderr output when `ffmpeg.Error` is raised?**

Catch `ffmpeg.Error` and read its `stderr` (or `stdout`) bytes attribute. `ffmpeg.probe()` captures stderr automatically, while `ffmpeg.run()` requires `capture_stderr=True` (otherwise `e.stderr` is `None`):
```python
try:
ffmpeg.input('in.mp4').output('out.mp4').run(capture_stderr=True)
except ffmpeg.Error as e:
print(e.stderr.decode('utf-8'))
```

**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.
Expand Down
13 changes: 13 additions & 0 deletions ffmpeg/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@


class Error(Exception):
"""Exception raised when an ffmpeg or ffprobe command exits non-zero.

Attributes:
stdout: Captured stdout bytes when stdout was piped, else ``None``.
stderr: Captured stderr bytes when stderr was piped, else ``None``.
"""

def __init__(self, cmd, stdout, stderr):
super(Error, self).__init__(
'{} error (see stderr output for detail)'.format(cmd)
Expand Down Expand Up @@ -320,6 +327,12 @@ def run(
``overwrite_output=True``).

Returns: (out, err) tuple containing captured stdout and stderr data.

Raises:
:class:`ffmpeg.Error`: if ffmpeg returns a non-zero exit code.
When ``capture_stdout`` or ``capture_stderr`` is True, the
captured bytes are available on the ``stdout`` and
``stderr`` attributes of the exception (otherwise ``None``).
"""
process = run_async(
stream_spec,
Expand Down