6

I prefer streaming Youtube videos via mpv,

mpv https://www.youtube.com/watch?v=<video-id>

However, for long videos sometimes the audio breaks down in the middle, leaving error messages like

[ffmpeg] tls: Error in the pull function.

Restarting the video is starting it from the beginning. How can I either directly in the command line start from, let's say, minute 30, or alternatively jump in the mpv interface to minute 30 without pressing 30 times the up button (which also has issues if done too fast)?

I haven't found an answer related to that issue in the man page. Is it possible at all?

Also alternative suggestions for streaming are welcome.

jjdb
  • 111
  • 1
  • 2
  • 9
  • 1
    Yes, [Tumbleweed badge](https://unix.stackexchange.com/help/badges/21/tumbleweed)!! – jjdb May 19 '17 at 11:15

2 Answers2

4

Get a decent cache with youtube-dl (to avoid the issue in the first place)

youtube-dl.py -q -f "(137/136)+(141/140)" "$URL"

Play the cache with any player (ffplay, vlc, omxplayer, c2play, mpv, etc) If you still want to seek;

ffplay -ss 30:00 *.mp4

.

vlc --start-time=1800 *.mp4

.

omxplayer --pos 00:30:00 *.mp4

.

c2play --time 00:30:00.00 *.mp4

.

mpv --start=30:00 *.mp4
user1133275
  • 5,488
  • 1
  • 19
  • 37
  • What is the `-f "(137/136)+(141/140)"` format option for `youtube-dl` doing? Could you elaborate on that part? – jjdb May 31 '17 at 06:07
  • @jjdb the man/help page will tell you all about -f but but basically its selecting the mp4 format from the youtube API. ( see "Comparison of YouTube media encoding options " https://en.wikipedia.org/wiki/YouTube#Quality_and_formats ) – user1133275 May 31 '17 at 20:35
  • Still, the code is cryptic to me. And also: As far as I understand it, your proposal essentially involves a download that has to be removed later. So it is not actually a streaming solution, is it? – jjdb Jun 02 '17 at 05:26
  • @jjdb clearly my answer offers both options, obviously if streaming is unreliable a more stable cache can be used and can be scripted to automatically remove the file when done. – user1133275 Jun 02 '17 at 20:10
  • Well, it is not really a streaming solution, as I have to wait for the whole video to be downloaded in order to be able to play it correctly: with `mpv`, audio does not work properly. – jjdb Jun 02 '17 at 21:34
  • Usually you can play a file that is beeing downloaded separately (this is a "hand made" cache) – bew Jun 04 '17 at 10:11
4

You can use --start=MM:SS to start your video at MM minutes SS seconds.

For example:

mpv --start=45:00 'https://www.youtube.com/watch?v=<video-id>'

Will start the video at 45 minutes.

bew
  • 246
  • 1
  • 2
  • I've tried the command, but my connection is lousy at the moment, so it didn't work. I'll try later again. So far it works fine for say 1 minute into the video, but 20 or so is too much already. `[cache] Cache is not responding - slow/stuck network connection?` is the error message – jjdb May 31 '17 at 17:47
  • In this case you might want to first download the video with a tool like [youtube-dl](https://github.com/rg3/youtube-dl/) for example, then play it with `mpv` at the wanted location. – bew May 31 '17 at 18:07
  • Do you know of another way to increase the cache size, or to improve cache handling? – jjdb Jun 02 '17 at 05:24
  • 1
    You can change the cache size with `--cache` and some other options (see the man page) – bew Jun 04 '17 at 10:14