Pages

June 7, 2014

Playing streaming Flash videos without Adobe Flash on Linux

Adobe Flash is still the norm for watching streaming videos on the Internet. There has been a great adoption of HTML5-based videos on YouTube; around 90% of the channels I subscribe to play just fine on my Ubuntu 14.04 LTS, Mozilla Firefox (without Flash plug-in) setup. But still, there are those 10% that don't (the includes you, NBA channel!).

The plug-in is installable via the flashplugin-installer package in Ubuntu 14.04 LTS. But since Adobe abandoned Linux some time ago, then I decided to shun Adobe from my Linux set-ups. In this post, I show how I watch YouTube videos on my Linux box.

The MPV video player

The mpv video player is my preference for watching videos. It's a fork of the infamous mplayer which I previously used prior to mpv. I like it because I launch it from the command line and its keyboard controls are pretty handy.

Honestly, it was at the time of writing this post that I discovered I can play YouTube videos using it. Simply issuing a mpv https://www.youtube.com/watch?v=s0m3v1d30-id command will pop-up a window for the video. The default video quality chosen is, I think, the highest setting. In the video I tried, it was in 720p. But since I live in a country where Internet is fucking expensive but shitty slow, loading the 720p video takes time. I can't seem to find a way to choose the video quality for the playback. I'm too lazy to read all of the content of the manpages and searching the web gives me a shitload of suggestions to convert from video this to that so I didn't bother to investigate further.

If you do know how to choose the quality and would like to share it, leave it in the comments section below.

The `livestreamer` Python package

I previously posted about a nifty tool for Python development, called virtualenv and it comes in handy when using livestreamer. If, like me, you don't like to muck-up your local Python environment, then virtualenv is the way to go.

So, I created a virtual environment for where I can install livestreamer. With said environment activated, one can install the package by:

    (livestreamer)$ pip install livestreamer

With livestreamer installed, we can now fetch the available streams for the YouTube video with the command:

    (livestreamer)$ livestreamer https://www.youtube.com/watch?v=wh4tY0uW4n7

The output should be something like in the picture below.

Results may vary for the video you want to play but if you are familiar with YouTube video quality, then most likely the 360p quality is an option. Also, livestreamer makes it easy to select the best, and worst, video quality for playback by using the best, or worst, option to the command. best picks the top quality video and I'm pretty sure you've figured out what worst is for.

Knowing now the available streams, we can go ahead and play the video.

    (livestreamer)$ livestreamer https://www.youtube.com/watch?v=wh4tY0uW4n7
    ...
    Available streams: 144p (worst), 240p, 360p, 720p (best)
    (livestreamer)$ livestreamer -p mpv https://www.youtube.com/watch?v=wh4tY0uW4n7 360p

In the command above, take note that I specified the player with the -p option. By default, livestreamer will use VLC media player, but I don't have that on my system so I use MPV. Then at the tail of the command, I choose the 360p quality because of my piss-poor Internet connection.

And the MPV video player should play the YouTube video at the quality I have specified.

Conclusion

You really don't need to go through all these hoops. Most people would just install the Flash plug-in. I just like to explore and find alternative ways of doing it. I am aware that VLC is also capable of playing streaming videos, so just experiment with it.

I have not tested other streaming sites so I will not comment about it here. As always, thanks for reading and happy Linux-ing!

No comments:

Post a Comment