Stream Youtube with mpv starting at an arbitrary point later in the video
Solution 1
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.
Solution 2
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
Related videos on Youtube
jjdb
Updated on September 18, 2022Comments
-
jjdb almost 2 years
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 about 7 yearsYes, Tumbleweed badge!!
-
-
jjdb about 7 yearsWhat is the
-f "(137/136)+(141/140)"
format option foryoutube-dl
doing? Could you elaborate on that part? -
jjdb about 7 yearsI'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 -
bew about 7 yearsIn 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. -
user1133275 about 7 years@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 )
-
jjdb about 7 yearsDo you know of another way to increase the cache size, or to improve cache handling?
-
jjdb about 7 yearsStill, 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?
-
user1133275 about 7 years@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.
-
jjdb about 7 yearsWell, 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. -
bew about 7 yearsUsually you can play a file that is beeing downloaded separately (this is a "hand made" cache)
-
bew about 7 yearsYou can change the cache size with
--cache
and some other options (see the man page)