📜 ⬆️ ⬇️

Watching movies on android devices from a home server

Hello, dear habrachiteli.

I have a modest hand-made home server:

All this works under Ubuntu and has approximately the following config: Intel Core Quad, 4Gb of memory and RAID 5 of 4 2TB disks.
Content from this server take home computers (samba), media player (samba), televisions (DLNA). And everything did not give me the peace of mind to watch the newly released TV series, and even some films, on the phone, lying in bed to sleep, so to speak, coming. A laptop is inconvenient due to its size and the danger of dropping from a bed at the time of an unexpected sleep. I rummaged through many forums, programs, etc., but did not find a solution.

The solution came to mind is quite obvious and simple - you need to transcode the video on the server and give the stream in a format understandable to the player.
I chose the player - MX Video Pleer
Video format - flv
Transcode video will be - mencoder

Install apache

There are no problems with this:
>apt-get install apache2 php5

Install mencoder

First we add the medibuntu repository:
>sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list www.medibuntu.org/sources.list.d$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
And install the mencoder package:
>apt-get install mencoder

And some code

1st page - index.php, file browser.
At the beginning of the file we set the base path for the search. It looks like this in the browser:

')
2nd page - video converter.
Takes the path passed to the URL, runs mencoder through popen and gives the result to the player.
Conversion options are selected experimentally. I picked up for my desire.

And one more subtle point - when requesting with parameters, no player on the phone wanted to play video, so I had to use the rewrite engine from Apache.

Results

With minimal effort, I got the desired result:
Disadvantages:

I do not pretend to be genius and, which is quite likely, looking at the code you say that I am an idiot. But someone this experience may be useful.
Sources for review are available here .

Source: https://habr.com/ru/post/128896/


All Articles