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

Terminal input is ignored when playing stdin #4190

Closed
hxka opened this issue Feb 27, 2017 · 9 comments · Fixed by #4622
Closed

Terminal input is ignored when playing stdin #4190

hxka opened this issue Feb 27, 2017 · 9 comments · Fixed by #4622

Comments

@hxka
Copy link

hxka commented Feb 27, 2017

mpv version and platform

mpv git-6028244160 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
built on Mon Feb 27 22:36:29 MSK 2017

Platform is Linux

Reproduction steps

mpv --vo=null - < some-streamable-file

(--vo=null is to keep mpv from creating a window which would be able to receive input)

Expected behavior

Controls (e.g. space, p, q, etc) work

Actual behavior

Any input is ignored

Log file

output.txt

(I ran mpv, tried pressing some keys, closed it with ^C)

@CounterPillow
Copy link
Contributor

If you use stdin to stream data into mpv, you obviously cannot use stdin to send keyboard input to mpv at the same time.

Either use the window, or have a look at the JSON IPC, if you need to read from stdin while also controlling the player somehow.

@ion1
Copy link
Contributor

ion1 commented Feb 27, 2017

FWIW, foo | less has keyboard control. If stdout is a TTY (isatty(3)), I think it will be a read/write device.

@ChrisK2
Copy link
Member

ChrisK2 commented Feb 27, 2017

Either use the window, or have a look at the JSON IPC, if you need to read from stdin while also controlling the player somehow.

Or use a FIFO to pipe the steam to mpv as "file".

@hxka
Copy link
Author

hxka commented Feb 27, 2017

If you use stdin to stream data into mpv, you obviously cannot use stdin to send keyboard input to mpv at the same time.

The fact that mpv expects input from stdin instead of tty when being run from a terminal (what you seem to suggest is happening) is exactly the problem.

@hxka
Copy link
Author

hxka commented Feb 28, 2017

Or use a FIFO to pipe the steam to mpv as "file".

There's a cleaner workaround which doesn't require creating temporary files.

mpv /proc/self/fd/3 3<some-streamable-file

Or, using pipes:

some-command | mpv /proc/self/fd/3 3<&0 0</dev/tty

That's still a pretty clumsy way of doing that. If I had to do that every time I wanted to pipe something to less, I'd cut my veins.

@ChrisK2
Copy link
Member

ChrisK2 commented Feb 28, 2017

Does --input-file=/dev/tty work? If so, just put it in your config and you should be good.

If/How it makes sense to possibly do this by default is still up for discussion.

@ghost
Copy link

ghost commented Mar 1, 2017

It probably won't read terminal input from this option.

@qmega
Copy link
Contributor

qmega commented Mar 1, 2017 via email

@ddevault
Copy link
Contributor

By default it makes sense to open /dev/tty instead of expecting stdin to provide user input.

jeeb pushed a commit to jeeb/mpv that referenced this issue Dec 7, 2017
Fixes mpv-player#4190

This allows you to use terminal input even if you've piped something
into mpv.
@jeeb jeeb closed this as completed in #4622 Dec 7, 2017
jeeb pushed a commit that referenced this issue Dec 7, 2017
Fixes #4190

This allows you to use terminal input even if you've piped something
into mpv.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants