7

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.

1
  • 1
    Yes, Tumbleweed badge!! Commented May 19, 2017 at 11:15

3 Answers 3

5
+50

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.

5
  • 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 Commented May 31, 2017 at 17:47
  • In this case you might want to first download the video with a tool like youtube-dl for example, then play it with mpv at the wanted location. Commented May 31, 2017 at 18:07
  • Do you know of another way to increase the cache size, or to improve cache handling? Commented Jun 2, 2017 at 5:24
  • 1
    You can change the cache size with --cache and some other options (see the man page) Commented Jun 4, 2017 at 10:14
  • If the video is a stream a starting time has no meaning (and I still get the error) Commented Mar 7 at 15:49
4

With youtube-dl you can download the file entirely, to avoid the issue in the first place.

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

Play the file 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
6
  • What is the -f "(137/136)+(141/140)" format option for youtube-dl doing? Could you elaborate on that part? Commented May 31, 2017 at 6: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 " en.wikipedia.org/wiki/YouTube#Quality_and_formats ) Commented May 31, 2017 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? Commented Jun 2, 2017 at 5: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. Commented Jun 2, 2017 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. Commented Jun 2, 2017 at 21:34
0

Get yt-dlp, and in mpv.conf, use ytdl=yes. That will make mpv use yt-dlp instead of its own implementations to handle streams, which may be more reliable.

It may help to use cache=yes; demuxer-max-bytes=X where X is some value in MiB between 64-512 (or more); and demuxer-readahead-secs=S where S is 5-60 (or more) secs.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.