How I fixed Youtube for myself


kuru

Who the heck is Stephan Kramer?
Joined
Oct 8, 2008
Messages
3,383
Location
the mockracy
Updated method using mpv/quvi
note: old mvp using quvi won't work with playlists. I'll look for a workaround once I'm suitably annoyed.

Youtube puts quite some strain on older machines. Running it in firefox makes things even worse. Whether you're using HTML5 or Flashplayer makes no noticeable difference.
My elderly laptop - 2x 1.5GHz, 2GB Ram, old HD - frequently slows down to a crawl with 480p YT running in the background. It sometimes even locks up completely... unbearable. Here's how I fixed that for me and why.

Apps like smtube or minitube are light on ressources and certainly an alternative. But I want playlist support and need my subscriptions. smtube does not deliver and I had trouble building minitube. And the official Debian 8 repo has old versions which can't connect at all.

The most powerful and convenient solution I could find is VLC in combination with the YT website for managing subscriptions and browsing. I want to rightclick a video in Firefox, copy link to clipboard, and start VLC with a shortcut, passing the URL.


1) Add playlist support to VLC Player by installing an add-on from
http://addons.videolan.org/content/show.php/?content=149909
On Linux drop the .lua file in /usr/lib/vlc/lua/playlist/

2) Install xclip from e.g. Debian repository or start at
https://sourceforge.net/projects/xclip/
xclip is a nice tool that can read from or write to the X clipboard

3) create a shell script e.g. play-url-in-vlc.sh containing
Code:
#!/bin/sh
vlc "$(xclip -o)" --one-instance &
'xclip -o' will output the clipboard content
$(...) makes it so the output of the command contained therein can be used as argument for another
the quotes help avoiding special characters - GET variables in URLs are separated by '&'

Add any vlc arguments you might want, mine reads
Code:
vlc "$(xclip -o)" --no-qt-video-autoresize --preferred-resolution 480 --autoscale --video-on-top --one-instance &

4) create a second shell script e.g. add-url-in-vlc.sh containing
Code:
#!/bin/sh
vlc "$(xclip -o)" --one-instance --playlist-enqueue &

play-url-in-vlc.sh will immediately start playing the URL passed to it
add-url-in-vlc.sh will append the given URL to the playlist
Put those where you deem it proper, I shoved them in .scripts in my user's home folder

5) In e.g. XFCE Open Applications Menu -> Settings -> Keyboard -> Application Shortcuts -> Add
Enter the command
Code:
sh /PATH/TO/SCRIPT/play-url-in-vlc.sh
Hit 'next' and put a key combo; I used Alt + W

6) Repeat #5 for add-url-in-vlc.sh and assign another shortcut, e.g. Alt + Q

In order to watch, right-click any youtube video link and 'copy link location', hit your key combo and Bob's your uncle.

There is one downside - VLC will always start at the beginning of a playlist. That's probably due to how the playlist plugin works. Could be fixable. An option to this end would be removing the playlist plugin and using the second script to build your own list.

Figuring this out was an enjoyable experience. At the very least I'll be able to find this info again, maybe it even helps somebody else.

Update 2017-02-09
There are some videos that won't play, causing VLC to throw an error 'could not open your MRL'. This is fixed by copying the updated youtube plugin to your /usr/lib/vlc/lua/playlist folder. Grab the file and rename it to youtube.lua. Copy to playlist folder. The old youtube.luac can be deleted.
 

Attachments

  • vlc.png
    vlc.png
    192 KB · Views: 447
Last edited:
I believe your setup should be able to play 720p as well.
 
There's also the YouTube plugin for Kodi, but since the makers of Kodi are cucks and ended support for Windows XP and under, you probably can't even run it at all on an older machine.
 
kuru is not running Windows.
btw: How does not supporting an OS that doesn't get any security updates for almost three years now make the developers of another software anything?
 
kuru is not running Windows.
btw: How does not supporting an OS that doesn't get any security updates for almost three years now make the developers of another software anything?
Ah, wasn't aware. But I felt XP support was forcibly cut off regardless of it being really old, heck I still use 98SE for certain things. Only workaround is to run an android emulator and run the android port of Kodi, however that plays laggier than going on the website.
I'm sure there's a easy way to compile the source on XP anyway.
Ok I'm getting offtopic now...
 
Thank you for this. I have a thinkpad X31 running Debian that also struggles with Youtube. Could be worth it on more recent laptops as well to save battery life.
 
I've been using you-get to play youtube videos in mplayer (-p mplayer) for a year or so now, and it enabled me to play 720p videos on my EeePC901 just fine. It did just break the other day - not sure yet if it's a you-get change, python change or a youtube change that broke it, and I just tried watching a video in the browser.

It used to need a couple of urls enabling in noscript, and 480p videos would generally play fairly smoothly. Now I had to enable a good five or six urls until it would finally play, and even then it would be in fits and starts (though audio would generally play unheeded, just video stuck on the same frame for 30 seconds and upwards).

Once I've reported this you-get break properly, I'll have to see if I can get this approach to work. Thanks!
 
Yeah, I just use my feedreader to keep me up to date with my youtube 'subscriptions'. I don't have a youtube account though, so that's just going to the particular user's video tab and grabbing the rss link there.

In other news, I just tested the you-get github prerelease repo, and youtube is still working there, so I'm sticking with that for my needs.
 
It seems VLC can't stream YT at resolutions lower than 720p any more. Setting preferred resolution to different values did nothing.
 
I found quite similar way, but used SMPlayer, so on my 2x2GHz Turion the CPU usage is much smaller (in FF it's 100% all time). The playing is implemented using "Youtube 2 player" add-on. It gives a menu item for playing video in external program and SMPlayer is configured there.
However, I use Palemoon instead of Firefox, so I'm not sure about this add-on compatibility.
 
smplayer/smtube doesn't play YT for me, weird.

Still, VLC plays just fine, but resolution is locked to 720p which is just a tad too much for my connection. Two months ago setting a lower res was no problem, 480, 360, 240, 144 were all available.
Network buffering is really bad on VLC and does nothing to compensate for the maybe 10% bandwidth I'm lacking.

I've changed nothing on the system, haven't been using it at all. So I suspect some change on Youtube's side.

My new internet can't arrive soon enough. It's been 33 days since I've ordered it. Thanks, telekom and vodafone.
 
You can use mpv (with youtube-dl installed) instead of vlc. There's also mpv firefox plugin I guess. Some browsers also have feature that lets you run scripts on site with URL as argument so you don't have to use clipboard.
 
my mpv installation still uses quvi instead of youtube-dl. Couldn't get dependencies resolved for mpv's latest version and didn't want to fiddle with more scripts to make ytdl work with the old mpv. But quvi works just as well.

I ended up with this CL to select 360p and have it play fullscreen on the 2nd monitor with 5 secs of cache
Code:
mpv --title="mpv" --cache-secs=5 --geometry="1025:0" --fullscreen -quvi-format=fmt43_360p "$(xclip -o)"
edit: added --title="mpv" to have a consistent window title for devilspie2, see below

I also want the playback window to be fixed to the visible workspace.
Code:
apt-get install devilspie2
mkdir ~/.config/devilspie2
touch ~/.config/devilspie2/devilspie2.lua
and put this in devilspie2.lua
Code:
if (get_application_name()=="mpv") then
    pin_window();
end
 
Last edited:
Back
Top