Skip to content

fix: redirect FFmpeg stdin to /dev/null to prevent TTY corruption#996

Open
berettavexee wants to merge 1 commit into
nathom:devfrom
berettavexee:fix/ffmpeg-tty-corruption
Open

fix: redirect FFmpeg stdin to /dev/null to prevent TTY corruption#996
berettavexee wants to merge 1 commit into
nathom:devfrom
berettavexee:fix/ffmpeg-tty-corruption

Conversation

@berettavexee

@berettavexee berettavexee commented Jun 14, 2026

Copy link
Copy Markdown

Problem

After a successful download (with or without conversion), the terminal is left with echo disabled — the user can type but nothing is displayed. Running reset or stty echo restores it.

This is a classic TTY state corruption: a subprocess altered the terminal's echo/raw mode settings and exited without restoring them.

Root cause: both FFmpeg subprocess calls in streamrip are launched without stdin redirection, so FFmpeg inherits the controlling terminal. Even with -y (auto-overwrite), FFmpeg probes stdin to detect whether it is interactive and may modify TTY flags (disabling echo, enabling raw mode) for its interactive prompt handling. If the process exits abnormally — or in some cases even normally — those flags are not restored.

Affected calls:

  • converter.py — audio format conversion
  • client/downloadable.py — SoundCloud segment concatenation

Fix

Pass stdin=asyncio.subprocess.DEVNULL to both asyncio.create_subprocess_exec calls. FFmpeg receives /dev/null as its stdin, never touches the terminal, and cannot corrupt TTY state.

Test plan

  • Download a track/album without conversion → terminal echo works after exit
  • Download with -c mp3 / -c ogg / -c aac conversion → terminal echo works after exit
  • Download a SoundCloud track (uses segment concatenation) → terminal echo works after exit
  • Verify FFmpeg conversion still produces correct output files

🤖 Generated with Claude Code

When FFmpeg is launched without stdin redirection it inherits the
terminal. Even with -y (auto-overwrite), FFmpeg may alter TTY settings
(echo mode, raw mode) for its interactive prompt handling. If it exits
without restoring those settings the terminal is left with echo
disabled — the user can type but sees nothing.

Add stdin=asyncio.subprocess.DEVNULL to both FFmpeg subprocess calls
(converter.py and downloadable.py) so FFmpeg never touches the terminal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant