chrippa / livestreamer

Command-line utility that extracts streams from various services and pipes them into a video player of choice. No longer maintained, use streamlink or youtube-dl instead.
http://livestreamer.io/
BSD 2-Clause "Simplified" License
3.88k stars 579 forks source link

MPV closes out immediately when writer thread closes, using stdin pipe #854

Open baskervald opened 9 years ago

baskervald commented 9 years ago
$ livestreamer --player "mpv" http://www.crunchyroll.com/problem-children-are-coming-from-another-world-arent-they/problem-children-are-coming-from-another-world-arent-they-preview-617253 mid --loglevel debug
[cli][info] Found matching plugin crunchyroll for URL http://www.crunchyroll.com/problem-children-are-coming-from-another-world-arent-they/problem-children-are-coming-from-another-world-arent-they-preview-617253
[plugin.crunchyroll][debug] Creating session
[plugin.crunchyroll][debug] Session created
[plugin.crunchyroll][warning] No authentication provided, you won't be able to access premium restricted content
[cli][info] Available streams: high, low (worst), mid, ultra (best)
[cli][info] Opening stream: mid (hls)
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Segments in this playlist are encrypted
[stream.hls][debug] Adding segment 0 to queue
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Adding segment 1 to queue
[stream.hls][debug] Adding segment 2 to queue
[stream.hls][debug] Adding segment 3 to queue
[stream.hls][debug] Adding segment 4 to queue
[stream.hls][debug] Adding segment 5 to queue
[stream.hls][debug] Adding segment 6 to queue
[stream.hls][debug] Adding segment 7 to queue
[stream.hls][debug] Adding segment 8 to queue
[stream.hls][debug] Adding segment 9 to queue
[stream.hls][debug] Adding segment 10 to queue
[stream.hls][debug] Adding segment 11 to queue
[stream.hls][debug] Closing worker thread
[stream.hls][debug] Download of segment 0 complete
[cli][info] Starting player: mpv
[cli][debug] Writing stream to output
[stream.hls][debug] Download of segment 1 complete
[stream.hls][debug] Download of segment 2 complete
[stream.hls][debug] Download of segment 3 complete
[stream.hls][debug] Download of segment 4 complete
[stream.hls][debug] Download of segment 5 complete
[stream.hls][debug] Download of segment 6 complete
[stream.hls][debug] Download of segment 7 complete
[stream.hls][debug] Download of segment 8 complete
[stream.hls][debug] Download of segment 9 complete
[stream.hls][debug] Download of segment 10 complete
[stream.hls][debug] Download of segment 11 complete
[stream.hls][debug] Closing writer thread
[cli][info] Stream ended

I've tested using --player-fifo and --player-continuous-http and it works correctly, but it seems as though piping through stdin just stops when the writer thread closes.

$ livestreamer --version
livestreamer 1.12.1
$ mpv --version
mpv 0.8.3 (C) 2000-2015 mpv/MPlayer/mplayer2 projects
 built on 2015-03-17T07:32:24
ffmpeg library versions:
   libavutil       54.20.100
   libavcodec      56.26.100
   libavformat     56.25.101
   libswscale      3.1.101
   libavfilter     5.11.102
   libswresample   1.1.100

I'm running Arch Linux, with kernel version 3.19.3-3-ARCH

chrippa commented 9 years ago

Livestreamer closes the player when it has fed all the data to the player by default. You can use --player-no-close to avoid this.

While we're on the subject, it's probably time to change this silly behaviour now. It's been kept as is for a long time as I don't like to alter behaviour between releases of Livestreamer, but things change.

At the time Livestreamer was first created mplayer was in a crap state and mplayer2/mpv didn't exist yet, so using VLC was the only reasonable option. But I disliked the GUI hanging around when a stream ended so this behaviour was implemented. Nowdays mpv is the superior player and it handles end of stream much nicer than VLC aswell, so it's probably time for a change.

baskervald commented 9 years ago

It closes the player when it's fed all of the data, even if the player isn't done with playback? That seems... like an odd choice.

chrippa commented 9 years ago

It closes the player when it's fed all of the data, even if the player isn't done with playback? That seems... like an odd choice.

At the time the choice was made it made sense. It's hard to believe but Livestreamer is actually almost 4 years old now, back then it only did livestreams and losing a second or two of playback felt like a reasonably trade off to avoid having dead VLC windows floating around.

vadmium commented 9 years ago

Perhaps you could add the “vlc --play-and-exit” option by default to mitigate the dead VLC window problem. I guess the only problem with that would be if there are versions of VLC that don’t support that option.

VackerSimon commented 9 years ago

What about MPC-HC? I don't want dead MPC-HC windows hanging around, so if this were to change there should be an option to have the same behavior as now.

baskervald commented 9 years ago

I'm inclined to believe MPC-HC would have an option similar to --play-and-exit for VLC, although I could be wrong.

chrippa commented 9 years ago

What about MPC-HC? I don't want dead MPC-HC windows hanging around, so if this were to change there should be an option to have the same behavior as now.

Yes, of course. Though I'm thinking maybe it's worth a shot to attempt to detect what player is specified and set the default behaviour based on that instead.