rshendershot / MythRokuPlayer

mythtv front end for Roku player
tbd
8 stars 2 forks source link

MythRokuPlayer2 provides a framework to easily emit xml schema compatible with the original private channel (http://forums.roku.com/viewtopic.php?f=28&t=33704#p214457) for access to MythTV Videos and Recordings as well as additional services (eg. Weather info) which are easily integrated using the class system.

This software is provided AS-IS without warranty or liability, either expressed or implied.

PREREQUISITS -functioning mythtv backend and mythweb -ffmpeg or alternates mythffmpeg,handbrakecli (for converting recordings to H.264 format) -Mythtv video are stored in H.264 format (mp4) -web user (eg. apache) permission to delete recordings -php-gd -php-xml -php-pdo -PHP ActiveRecord, in a php included location (see http://www.phpactiverecord.org, and Testing below) -$MythBackendPort (default 6544) is open to the webserver process so that myth backend services can be called.

INSTALLATION There are two parts to the MythRokuPlayer2: The Brightscript UI code which is the Roku channel, and the PHP code which handles requests from the Roku. Initial installation then requires placing mythroku and its files in your mythweb directory. The mythroku directory can be a symlink to MythRokuPlayer/mythroku so you can extract a zip or clone the code right in your mythweb directory.

[mythweb]$ git clone https://github.com/rshendershot/MythRokuPlayer.git
[mythweb]$ ln -s MythRokuPlayer/mythroku

To finish the install, adjust your installation to your environment as in the following steps:

1) You can use the private MythRokuPlayer channel, but if you wish to customize the player User Interface BrighScript code then you must "side-load" a development version.

If you use the private channel (http://owner.roku.com/Account/ChannelCode/?code=YWWMH) 
then you can skip to #2

you can set up your Roku box in developer mode to install the dev channel.
Use remote and enter Home 3x, Up 2x, Right, Left, Right, Left, Right
Note: permission denied failure may occur if SD microcard is present. Remove it.

Make note of the IP and the password (firmware asof 5.2) that you set!

add the following to your .bashrc file "ROKU_DEV_TARGET=roku.ip" 
Where roku.ip is the ip address of your Roku player.

for Roku box with 5.2 or later firmware a side-load requires authentication.
add ROKU_DEV_PASSWORD=roku.passwd to your environment

2) you need to modify mythweb to enable streaming of mp4 files. modify /usr/share/mythtv/mythweb/includes/utils.php by adding the following around line 247

   case 'mp4' : return "$url.mp4";

and in the following file /usr/share/mythtv/mythweb/modules/stream/stream_raw.pl add an additonal elseif in the file type section

    elsif ($basename =~ /\.mp4$/) {
        $type = 'video/mp4';
        $suffix = '.mp4';
    }

if you are using authentication to protect your mythweb (best practice)
you need to add the following to your mythweb.conf file (near the top)

<LocationMatch .*/mythroku*>
        Allow from 192.168.1.0
    </LocationMatch>

3) add the mythroku directory to your mythweb directory and change the permission to that of your webserver. Give write permissions to mythroku/cache.

Ensure that the .htaccess file is in that directory as well. 
The .htaccess file in the mythroku directory simply has:

   RewriteEngine off

This is to stop mythweb adding its templates to the xml data.

You need to edit the settings.php file with your local parameters for example
ip or url of your webserver.

Your web server process (apache, www-data, etc.) will need write permissions within
your Recordings storage area.  Mythtv owns the recording and its MP4, as well as 
preview (PNG) files, but the web server is the process that deletes all of that. 

4) convert recordings from mpg to mp4 create a user job in mythtv (mythbackend setup-> general-> Job Queue) add the following to a job command

/pathtomythweb/mythroku/rokuencode.sh "%DIR%" "%FILE%"

to make it a default job run after every recording. In your mythconverge->setting
set the AutoRunUserJob1 (or whichever job you set it to) data = 1

This will automatically encode a recording to mp4 format which can then be
streamed by roku.  It will also update mythconverg.recorded.basename with MP4 extension
(the player ignores other filetypes).  Note that mythweb and mythtv frontend will thereafter
use the MP4 not the original.  

5) Testing Using either a command line or your browser, load the testing file php mythtv_all_xml.php or the initial file that the Roku player uses php mythtv.php (in a browser just point to your webserver/mythweb/mythroku/theFile.php and view source)

mythtv.php provides the initial categories and mythtv_all_xml.php gets a listing
of the recordings and videos that would be sent to the Roku.      

You can get a human-readable form of the sd/hd Img or  streamUrl by adding it as a 
parameter.  
    php mythtv_all_xml.php [img url || stream url]

You can also enter img or stream url from the XML directly into your web browser 
and monitor your web server error log as there is additional logging information.

A simple shortcut to installing PHP-ActiveRecord is to extract the latest daily 
directly in your mythroku directory.  Rename php-activerecord_yyyymmdd to php-activerecord
if necessary so that you have

    mythweb/mythroku/php-activerecord/ActiveRecord.php    

6) The player if you have modified the UI code, sideload install MythRokuPlayer to your roku: in the MythRokuPlayer directory (containing this read me) simply type

       make && make install

Or install the original private channel;

On the Roku you should have a MythTV (original) or MythTV 2 channel (sideloaded)
channel.  Start it and point it to your web server and its path to mythroku

eg. http//192.168.1.10/mythweb/mythroku

7) Debuging (only if you've sideloaded as in #6)

telnet $ROKU_DEV_TARGET 8085

will give you any output from the player for debug

You may need to comment out the following line
bind-address = 127.0.0.1 in /etc/my.cnf to allow access to mysql

Good luck and happy streaming.