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

Don't give subprocess our stdin, give it os.devnull instead. #231

Merged
merged 1 commit into from
Nov 18, 2017

Conversation

mwoenker
Copy link
Contributor

When calling subprocess.Popen to call ffmpeg, the process inherits our standard input. Apparently ffmpeg modifies the terminal parameters if it is given a TTY on standard in. Usually this isn't a problem, because ffmpeg sets them back to what they were when it is done. However if you're calling AudioSegment.from_file() or AudioSegment.export() from multiple threads at once, the multiple ffmpeg process race each other in setting/getting the shared terminal parameters.

On my machine at least, this pretty consistently leaves my terminal hosed when my program exits -- turning off echoing, and other weirdness, which is only fixed by blindly typing reset into the terminal.

The easy solution seems to be to just give ffmpeg/avconv a file descriptor to os.devnull on stdin, which fixes the problem for me. Tested with ffmpeg, not with avconv, but I would be surprised if it broke anything.

@jiaaro jiaaro merged commit 0cd5dbb into jiaaro:master Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants