Building a home media streaming server. Part 2: The streaming server

Now that I got my TV hook up to the laptop and the PC working as the media server serving those FullHD x264 film over the air. I can simply install  on it and got top notch home media experience,  just look at this beautiful picture, it sure speak more than thousands word:

However, the problem with those massive HEVC(x265)10bit high bitrate film remain. My laptop simply can’t open those files. I will have to transcode those file and stream it to the laptop. In short, my work station will have to be Youtube, or something like this:

The survey

I tried to build a streaming server but to no avail. First is making a trip to the guide: https://wiki.archlinux.org/index.php/Streaming_media

That link provide quite a few streaming software available on  arch that can stream over DLNA/UPnP protocol. Now as far as I’m concerned, DLNA is meant to stream to media player device that doesn’t have full capacitiy of a laptop computer and thus the server has to transcode the file to a more easier to read format and that’s exactly my use case. Looking on the list of streamer sever software, some catch the eye:

  1. ReadyMedia, formerly known as minidlna, this is a simple and no fussy solution, just like it’s name suggest. You edit the config file, start the server and the media appear on your client, just that.
  2. Gerbera, formerly known as MediaTomb. I did try this server to a horrible experience. It was so buggy and the config file was so so complex that I find no way to make it work and abandon the streaming stuff all together. But with it’s code fork  and make into gerbera, maybe thing will be a bit better
  3. Emby. This software is new and it has a beautiful website for an opensource app. I don’t like the fact that it was coded in C# though but if it work good I can make a pass for that.
  4. Plex. This is a closed-source solution so I was deterred to try it last time. It requires you to registered a free account to get token to access your own media collection. It has an option to make stream your data over the internet, but, for a closed-source solution that sound more scary than cool. But if you don’t concerned about closed-source, Plex has a really good reputation of working find and looking beautiful.

So, how can a tech savvier choose his favourite streaming server among those? He tried them all on 🙂

ReadyMedia

This software is a resurrection of MiniDLNA, and as its name suggests, this software is lightweight and simple to use. Archwiki already got a pretty decent article on this piece: https://wiki.archlinux.org/index.php/ReadyMedia. However, since I also need transcoding feature, I have to install patched version from bitbucket. Arch’s AUR ease up the installation a bit https://aur.archlinux.org/packages/readymedia-transcode-git/ but the old source code won’t compile with the shinny and new ImageMagick version 7.

A little hack is required, and I left a comment in arch’s aur page (linked above). After the minidlna server is up and running, any media player that support dlna protocol can see and open file from my homePC. Kodi con do it but I setting kodi is story for part 3 of this series, one can test if dlna server is up by using the quick and easy vlc :

Just open VLC, then go to View -> Playlist (Ctrl + L) and select Universial Plug 'n' Play under Local Network section.

Your sever will be listed on the right side and you can browse it by  folders of just get a list of every media file that the server understand.

# list of video containers that needs to be transcoded
# possible values can be obtained by running "ffmpeg -formats"
# The format in which the settings should be written is the same
# as the format used for the "transcode_audio_codecs".
transcode_video_containers=
# list of video codecs that needs to be transcoded
# possible values can be obtained by running "ffmpeg -codecs"
# The format in which the settings should be written is the same
# as the format used for the "transcode_audio_codecs".
transcode_video_codecs=vp8/theora/flv/flv1/svq3/hevc
# full path to the transcoder that is used for video transcoding
# for details, see comments on transcode_audio_transcoder
transcode_video_transcoder=/opt/transcode_video-hq

 

You can either specify the containers (the extensions) you want to transcode or the codecs that will be transcode, or both. Since my laptop only struggle with x265 (HEVC) file, I simply add hevc at the end of the line transcode_video_codecs.

transcode_video_transcoder specify the wrapper script to call a program at your choosing that will be used to actually perform the transcoding. The example script that come with ReadyMedia is easy enough to grasp:

#!/bin/sh

SOURCE=$1
STARTPOSITION=$2
DURATION=$3

ffmpeg -ss $STARTPOSITION -t $DURATION -i "$SOURCE" -loglevel quiet -threads auto -async 2 -vcodec mpeg4 -f mpegts pipe:1 -scodec copy 

 

That script take 3 arguments then call ffmpeg to perform the transcoding. The output will be put into standard pipe and then stream to the client.

However, I soon run into a big problem: I CANNOT SEEK

Yeah, no matter how much I tweak ffmpeg argument and ReadyMedia setting, seeking doesn’t seem to work. The seek button on client won’t work, some client even won’t report movie run time. Now that is impossible to use, I can bare with no subtitle or some film, but the most important of watching film at home is that you can forward and backward to the scene you love the most, with no seeking, the experience is nothing more than and old TV.

I did try  but even though it works much better and bug free then the old MediaTomb, I couldn’t find any improvement on transcoding and seeking. In fact, the old transcoding guide for MediaTomb flat out says that seeking is IMPOSSIBLE.

 

(sidenote: old like to mediatomb website seem dead but the old guide is available in google search’s cache). The only improvement over ReadyMedia that Gerbera can bring to the table is a web interface to do the configuration. That’s it. No improvement in transcoding than I can found. So my search for the solution continue into the realm of proprietary software.

Plex and Embry

The thing I found out when tried on  is that their reputations are well deserved. Installation is easy, configuration is easy and everything just work. After install the server package onto my HomePC, I can access the MY Plex homepage from the local network via the default port 32400. And Man, it was beautiful. Just hover your mouse on the LIBRARY section then click the Plus (+) icon, one will be greeted with the dialog to add a new library.

First, we choose Library type, then browse to  a folder on the disk where the media file is stored. Now just like Kodi, if you choose either Films or TV Programmes, Plex will automatically pull all metadata for those movie and TV shows from imdb, and it will show ONLY the file it recognize as Films or TV Programmes respectively. It’s mean some clip that one really mean to hide won’t show up on the plex library, hooray!

About the transcoding, well, I must say it’s not quite as easy as the rest. Plex support transcoding out of the box but the option to transcoding 4K resolution only “automatically” appear if I really watching the video on a 4K window

Therefore, I cannot test it out on my laptop alone without plugging it into the TV, and that’s inconvenience. And even though the transcoding work, I can enjoy the movie without those massive frame dropping, it put a huge strain on both client and server. Even without the need to decoding, putting all the pixel at that massive bitrate on the screen is back breaking work for my laptop

 

With CPU jumping between 70% to 90% utilizing across all 2 core, 4 threads, all I can do is enjoy the movie because the laptop hardly response to anything else.

On the server side thing is also pushed to the very edge. My homePC is not equipped with streaming oriented hardware and just decode those HEVC codec alone already put 60% CPU usage on it. Having to re-encode those pixel and transport it over the network and the CPU usage jump to 80-90%.

And the strain on network is also enormous. I’m not a professional in setting up high speed network so my WiFi can only push out about 28Mbps, barely enough for some 4K movie, some other will suffer from stuttering play back. That’s a little bit disappointing at first, I didn’t think a home WIFi network with me as the only primary user would be insufficient for 4K playback. But since a HTPC with dedicate wired Ethernet connection was in plan, I guess I have to bare with the stuttering for now.

Emby

Emby is the closest thing to Plex. Unlike Plex, it employs a Free/Open source version along side a “Premiere” version. The Free/Open source part provide enough features and usability for me. It automatically recognize files in your chosen folder and pull all metadata from the internet. Emby provide native app for a barrage of Mobile and TV devices but I haven’t the need for any of them yet.

For PC platform emby provide just the web application and it’s seem good enough, though the interface is not as glamorous as Plex’s.

The playback however is not as smooth. Due to the lack of a PC client app, Emby have to transcode almost every single mkv file or mine to suitable codec for web playaback. And the transcoding process is just Monstrosity. The CPU usage on my HomePC quickly jump to 100% and keep staying there, the whole system become lagging and even then I suffer stuttering playback. It seem like my system was just not strong enough for Emby and by the time I have money to upgrade it I won’t need emby anymore so that was the end of my Emby experience.

The conclusion

So, at the moment, whenever I want to enjoy a 4K movie, I fire up plexmediaserver on my HomePC and Plex Client on my laptop then hookup the laptop to TV and voila. It’s not perfect but at least I decent.

The next part of this series will deal with how I equip my laptop to double as a poor-man-HTPC, include both software and hardware modification needed.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.