Skip to content

quiet mode for run_async method might cause ffmpeg process to stick. #195

@ArchieMeng

Description

@ArchieMeng

What I experienced

Recently, I was using this module in my project for decoding video into pipe as well as encoding target frames into a result video.
But I found that setting the parameter "quiet" of the encoder process to True (which set both stdout and stderr to PIPE) will cause the ffmpeg process to stick at some stage ( and in this case, I cannot write anything into its stdin). If I leave "quiet" to default or set both pipe_stdout and pipe_stderr to False, everything goes well.

What I tried

I tried to edit the run_async function, changing it from

args = compile(stream_spec, cmd, overwrite_output=overwrite_output)
    stdin_stream = subprocess.PIPE if pipe_stdin else None
    stdout_stream = subprocess.PIPE if pipe_stdout or quiet else None
    stderr_stream = subprocess.PIPE if pipe_stderr or quiet else None
    return subprocess.Popen(
        args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream)

to

 args = compile(stream_spec, cmd, overwrite_output=overwrite_output)
    stdin_stream = subprocess.PIPE if pipe_stdin else None
    stdout_stream = subprocess.PIPE if pipe_stdout else None
    stderr_stream = subprocess.PIPE if pipe_stderr else None
    if quiet:
        stdout_stream = stderr_stream = subprocess.DEVNULL
    return subprocess.Popen(
        args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream)

Then, using this modified version of ffmpeg-python in my project, it works without any problems.

After all, I don't think this issue is solved, for it will stick again if setting either pipe_stdout or pipe_stderr (I confirmed).

My forked version works. Should I make a pull request? Or do it only when we find the real reason for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions