How to Play YouTube Videos in VLC

đź“… April 28, 2016
yt03Are you having trouble playing YouTube videos in VLC?

Whether it be the Flash Player or the HTML5 player, there are times when YouTube’s browser player is less than adequate, such as no full screen or excessive stuttering. An external player usually plays videos instantly and with improved motion smoothness.

Also, maybe it is just me, but something seems broken or unreliable lately when attempting to play YouTube videos in VLC (VideoLAN Client).

It used to be that you could simply copy and paste the YouTube video URL into VLC or almost any other media player, and the player would play the video without hassle. There were even browser plugins facilitating the process. Now, VLC is giving me MRL errors.

Sometimes it works, sometimes it does not. Regardless, there are times when an external player, such as VLC, may be preferred. Can we still use VLC for YouTube videos?

Yes!

While this how-to uses Firefox and VLC on Linux Mint 17.3 Cinnamon as an example, it should work with other browsers and Linux distributions.

The Issue

Sometimes, if you try to play a YouTube video in VLC, you will see an error message regarding an “unable to open MRL” issue. This means VLC cannot properly parse the YouTube URL. Other times, VLC will stay blank.

VLC is not alone. Other media players might have issues and refuse to play the video.

Update July 2016: VLC 2.2.2 in Linux Mint 18 plays YouTube videos by copying and pasting the link into VLC, so this article might not be necessary for Linux Mint 18.

Certainly, there are ways to obtain the playback URL. One example is the YouTube Video Info site that shows detailed information about the audio and video streams available for a given YouTube video.

a

Information for Big Buck Bunny. Copy and paste a YouTube video URL to see its stream information. The URL is the playback URL that will play directly in a browser. If 1080p, 2K, 4K, and 8K streams are available, they will be listed too.

This requires work, and there are other ways to obtain the stream URLs. We want to configure a simple “open with VLC” option.

Step 1. Set Up VLC

Download youtube.lua.

Update November 20, 2016: This site for youtube.lua has been offline, but a search for youtube.lua should return mirrors.

This is a VLC plugin written in Lua that enables the proper parsing of YouTube video URLs so they will play in VLC.

Step 2. Copy youtube.lua to VLC

VLC needs this plugin in its playlist directory. On Linux Mint 17.3, this is located at /usr/lib/vlc/lua/playlist.

sudo cp youtube.lua /usr/lib/vlc/lua/playlist

Copying to this location applies the plugin system-wide for all users. However, this location might vary by operating system and distribution, so double check. You should see that other Lua plugins are already present by default.

Step 3. Test if the VLC Plugin Works

Close VLC (if open) and reopen it. Find a video you like on YouTube and copy and paste its URL into VLC (“Open Network Stream”). VLC should play the video. If not, then these instructions might be obsolete since YouTube has been known to change its URL format from time to time, making certain plugins unusable.

a

If youtube.lua was installed to the correct directory (and if it is still compatible with YouTube), then VLC will stream a YouTube video. Shown here is Big Buck Bunny playing in VLC 2.1.6. This video is streaming from YouTube. The moment a connection is made, it starts playing like any other streaming video.

Step 4. Install a Browser Plugin for Easier Playback

Now that VLC is set up to play YouTube videos, let’s add a browser plugin so we only need to click a video to make it play in VLC instead of copying and pasting the URL.

There are many Firefox plugins that accomplish this, so experiment with what works best for you. To get started, two plugins are VLC YouTube Shortcut and Open With.

a

VLC YouTube Shortcut allows you to configure shortcuts to play a video in an external VLC player. (Not an embedded VLC player.) Be sure to configure the path to the VLC executable before use. It is not automatically detected.

Simply middle-click (the mouse wheel button) on a YouTube link (except for the embedded YouTube player), and it plays in VLC. How easy is that?

a

VLC YouTube Shortcut adds two new items to the context menu. Right-click and choose to either play immediately in VLC, or queue it up in VLC’s playlist. VLC then plays the videos one after another. You can also drag and drop links into an open VLC window for playback.

a

Open With allows you to open the current web page in various programs. Simply add VLC to the list, and VLC will appear in a context menu. The YouTube link will open in VLC. Open With also displays an icon in the status bar (if enabled) for easier use.

Avoid Double Playback

Depending upon your browser configuration, you might notice that the YouTube video will play in both the browser and VLC simultaneously. Let’s prevent that.

We need to install a browser plugin that prevents YouTube videos from auto-playing in the browser. This way, they play in VLC only when you tell them to start. One plugin (for HTML5 playback) is StopTubeHTML5.

There are two types of browser YouTube players: Flash and HTML5. You might need plugins for both in order to suppress playback since the HTML5 suppression still allows Flash videos to play. For example, StopTubeHTML5 will prevent HTML5 videos from playing, but not Flash videos using the Flash player. (At least as of the time of this writing.)

There are myriads of browser plugins available, so experiment with what you need.

Extra Notes

So what can we expect with VLC playback?

  • No ads! Videos play without ads. Go straight to the video and start watching.
  • No annoying popup annotations. Some YouTube posters go overboard with constant bombardment of text boxes that pop up while the video is playing. Ug. These do not appear in VLC. As you might expect, there is a browser plugin that suppresses annotations when videos are played within the browser.
  • Only 720p and lower. YouTube uses DASH to play 1080p and higher videos. With the technique shown in this article, you will be limited to 720p video resolution. Yes, you can play 1080p, 2K, 4K, and 8K YouTube videos with audio in VLC as synchronous streams, but this requires more effort if performed manually. The aim here is to provide a simple “click to play” how-to.
  • Playlists work. This might depend (in part) upon the browser plugin you choose to use, but you can open a YouTube playlist in VLC and VLC will play the entire playlist.
  • Nothing is guaranteed. YouTube has changed formats and access to its videos in the past, so expect some things to break over time. It is a cat and mouse game, after all.

What Else?

While you are at it, I would recommend cleaning up the YouTube page itself to make it appear more pleasing while browsing. Install a comment blocker that eliminates those ridiculously inane comments (not all comment blockers work with YouTube comments) and Stylish to customize the YouTube page style to your liking. Other various plugins will block the extra clutter, such as buttons and ads. Preventing JavaScript from running is another good idea.

Conclusion

The key is to add the youtube.lua plugin to VLC so it will properly parse the latest YouTube video URLs. Once that is done and VLC plays the video, then the rest is browser customization. Other video players will require their own tweaking.

If you are having trouble playing YouTube videos in your browser for whatever reason and find a need to use an external video player for playback, then these ideas might help.

Have fun!

 

 

 

,

  1. Leave a comment

Leave a comment