Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom stdin support #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions ffmpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, executable='ffmpeg', global_options=None, inputs=None, output
def __repr__(self):
return '<{0!r} {1!r}>'.format(self.__class__.__name__, self.cmd)

def run(self, input_data=None, stdout=None, stderr=None):
def run(self, input_data=None, stdin=None, stdout=None, stderr=None):
"""Execute FFmpeg command line.

``input_data`` can contain input for FFmpeg in case ``pipe`` protocol is used for input.
Expand All @@ -78,6 +78,7 @@ def run(self, input_data=None, stdout=None, stderr=None):

:param str input_data: input data for FFmpeg to deal with (audio, video etc.) as bytes (e.g.
the result of reading a file in binary mode)
:param stdin: replace FFmpeg ``stdin`` (default is `None` which means `subprocess.PIPE`)
:param stdout: redirect FFmpeg ``stdout`` there (default is `None` which means no
redirection)
:param stderr: redirect FFmpeg ``stderr`` there (default is `None` which means no
Expand All @@ -87,10 +88,13 @@ def run(self, input_data=None, stdout=None, stderr=None):
:raise: `FFRuntimeError` in case FFmpeg command exits with a non-zero code;
`FFExecutableNotFoundError` in case the executable path passed was not valid
"""
if input_data is not None or stdin is None:
stdin = subprocess.PIPE

try:
self.process = subprocess.Popen(
self._cmd,
stdin=subprocess.PIPE,
stdin=stdin,
stdout=stdout,
stderr=stderr
)
Expand Down