Difference between revisions of "Play Recordings On Windows From MythWeb"

From MythTV Official Wiki
Jump to: navigation, search
(Introduction)
("setup" is a noun, not a verb.)
 
(43 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Category:HOWTO]]
 
 
 
==Introduction==
 
==Introduction==
Below are instructions on how users can browse the recordings via Mythweb on a Windows machine and with one click, have it play in [http://www.videolan.org/ VideoLan] (VLC).  Videos can also be played with one click from the MythWeb video listing, but it is necessary to modify code.
+
Below are instructions on how users can browse the recordings via Mythweb on a Windows machine and with one click, have it play in [http://www.videolan.org/ VideoLan] (VLC).
  
 
'''Notes'''
 
'''Notes'''
 
* These instructions will not work through a firewall or over a slow  < 5Mbps connection and assumes the computers are on the same LAN.
 
* These instructions will not work through a firewall or over a slow  < 5Mbps connection and assumes the computers are on the same LAN.
* It just uses VLC to play the files, not the VLC server to stream the recordings.
+
* It just uses VLC player to view the recordings, not the VLC server to stream the recordings.
* These instructions only work on MythTV 0.20 (or greater)
+
* These instructions only work on MythTV 0.21 (or greater).  If you want instructions that work on 0.20 or lower, then look at the [http://www.mythtv.org/wiki/index.php?title=Play_Recordings_On_Windows_From_MythWeb&oldid=30272 history] of this page.
* These instructions won't work for slave backends (because of limitations with MythWeb) but the recordings can be shared.
+
* These instructions work on Vista as well as XP.
 
* Assumes Fedora Core
 
* Assumes Fedora Core
 +
* Assumes latest version of Videolan, v0.9.6
 +
* Yes, you can use Windows Media Player, but it will not play the High-Def MPEG2 streams.
 +
* '''Requires Firefox''' (well, it doesn't really, the "file://" URLs will open in I.E. but darn if I can be bothered to make it use VLC by default.)
  
The instructions consist of three parts, first install and configure the necessary Windows applications, share the recordings directory via Samba, then modify Mythweb.
+
The instructions consist of three parts, first install and configure the necessary Windows applications, share the recordings directory via Samba, then modify a php file.
 
 
=== Other alternatives ===
 
[http://tapeworm.spurgeonwoods.com/ Tapeworm]
 
  
 
==Time to implement==
 
==Time to implement==
  
* 1/2 hour for recordings and assumes access to MYSQL and setting up Samba via command line
+
* 1 to 1-1/2 hour for recordings and ability to set up Samba via command line
* or an hour for both recordings and videos and familiarity with symbolic links, editing php files
 
==Installing Required Window Applications==
 
 
 
First get and install these two applications on your Windows machine:
 
* VideoLan (VLC) - http://www.videolan.org/
 
* The "MythTV Filters" or DSMyth - http://dsmyth.sourceforge.net/
 
 
 
Now, with DSMyth, under the Start Menu -> MythTV Filters, run the "Configuration" program. It will bring up a screen called "MythTV DirectShow filter settings" which has a sidebar that has three tabs "MySQL database", "File associations" and "Network".
 
  
* Note: The settings under "MySQL database" are not necessary for viewing recordings in Windows.
+
==Install Video Player==
  
[[Image:file_associations_with_DS_myth.jpg|thumb|100px|right|DSMyth Configuration]]Under the "File Associations" tab (as shown right), change the bottom "MythTV Urls:" to VLC by hitting "browse" finding the VLC executable or, if you installed it in the default directory, just paste in everything below:
+
===Videolan and Firefox Addon - Launchy===
 +
First get and install [http://www.videolan.org/ VideoLan] on your Windows machine.  Videolan is an open source video player that can handle all the MPEG codecs.
  
  "C:\Program Files\VideoLAN\VLC\vlc.exe" "%1"
+
Second, you will need to install the [https://addons.mozilla.org/en-US/firefox/addon/81 Launchy] add-on for Firefox. It should automatically add Videolan to your list of possible applications to send the link to. You can check by going under Firefox -> Tools -> Add-ons -> <under Launchy, click on "Options">
  
You can also place the same link in the two slots above, but it is not necessary. Then hit OK.
+
* '''Note:''' You can use other media players but VLC has much better seek hotkeys, i.e. try the forward/backward buttons on your mouse, CTRL-right arrow or ALT-right arrow!
  
* Note: You can use the pre-defined mplayer2.exe, but it really sucks because it can't seek with out crashing, takes a long time to come-up and VLC has much better seek hotkeys (try CTRL-right arrow or ALT-right arrow or the forward/backward buttons on your mouse!)
 
DSMyth is used as a bridge application, when "myth:\\" links are clicked in a browser, DSmyth takes it and passes it along to VLC.
 
  
 
==Configuring Linux Samba Shares==
 
==Configuring Linux Samba Shares==
  
On your MythTV backend we are going to add a Samba share which will allow any Windows machine on the network to see all the recordings in the recordings directory on a read-only basis. First make sure the Samba and Lisa daemons are running and will start automatically on bootup:
+
On your MythTV backend, we are going to add a Samba share which will allow any Windows machine on the network to see all the recordings in the recordings directory on a read-only basis. First make sure the Samba and Lisa daemons are running and will start automatically on bootup:
  
 
  # /sbin/chkconfig lisa on
 
  # /sbin/chkconfig lisa on
Line 48: Line 37:
 
  # /sbin/service smb start
 
  # /sbin/service smb start
  
Now, you could edit "/etc/exports" file and add a line to it like "/video/recordings/ *(r,async,all_squash)" (and restart samba) but it is easier to use the graphical interface of KDE.  From the start menu, go to Control Panel -> Internet & Network -> Samba Configuration. You can then click the "Administrator Mode", enter the Root password, and setup the "Base Settings", i.e. Workgroup, Netbios name (leave as default) and the description. Then click on "File Sharing" above in the sidebar and go into "Administrator Mode" again, and "Add" the directory that contains all the MythTV recordings, for example "/video/recordings". Set the share to "visible" but not "writable" to avoid having recordings deleted. The name of the share is used by windows, you could call it "recodings" or "MySMBShare".  
+
Now, you could edit "/etc/exports" file and add a line to it like "/video/recordings/ *(r,async,all_squash)" (and restart samba) but it is easier to use the graphical interface of KDE.  From the start menu, go to Control Panel -> Internet & Network -> Samba Configuration. You can then click the "Administrator Mode", enter the Root password, and setup the "Base Settings", i.e. Workgroup, Netbios name (leave as default) and the description. Then click on "File Sharing" above in the sidebar and go into "Administrator Mode" again, and "Add" the directory that contains all the MythTV recordings, for example "/video/recordings". Set the share to "visible" but not "writable" to avoid having recordings deleted. The name of the share is used by windows, you could call it "recordings".  
  
 +
* Note: To restart samba use "service smb restart"
 
* Note: If you can't see anything under the "Samba Configuration" or "File Sharing", check if the processes are running:
 
* Note: If you can't see anything under the "Samba Configuration" or "File Sharing", check if the processes are running:
 
  # ps -A | grep lisa
 
  # ps -A | grep lisa
Line 60: Line 50:
 
and replace "MyMythBackend" with whatever you want.   
 
and replace "MyMythBackend" with whatever you want.   
  
* Note: One of the benefits of having Samba running is that you can now access MythWeb with the hostname, for example http://MyMythBackend/mythweb
+
* Note: One of the benefits of having Samba running is that you can now access MythWeb with the hostname, for example http://MyMythBackend/mythweb but make sure the "nmb" service is running.
  
 
Now check if your Windows machine can see the recordings directory because there is little point in continuing if it can't. (Give it a few minutes, finding new shares can be slow as it discovers clients, figures out who is the master, etc.) One way to see the share is to enter the following in the Windows Explorer address bar:
 
Now check if your Windows machine can see the recordings directory because there is little point in continuing if it can't. (Give it a few minutes, finding new shares can be slow as it discovers clients, figures out who is the master, etc.) One way to see the share is to enter the following in the Windows Explorer address bar:
  
\\MyMythBackend\MySMBShare\
+
\\MyMythBackend\recordings\
  
replacing the host and share name with yours. Another way is to click on the Start Menu, click Run, and type that into the run command. ie \\192.168.1.123\\mythshare\
+
replacing the host and share name with yours. Another way is to click on the Start Menu, click Run, and type that into the run command. ie \\192.168.1.123\\recordings\
  
 
==Modifying Mythweb to View Recordings==
 
==Modifying Mythweb to View Recordings==
Line 72: Line 62:
 
The next step is to pass to VLC a URL from Mythweb that it can then use to play the recording off the samba share.
 
The next step is to pass to VLC a URL from Mythweb that it can then use to play the recording off the samba share.
  
This would have been dead easy through the MythWeb interface because you can modify the value needed under the MythWeb settings page (Click the icon next to the weather icon) -> "MythTV global defaults" -> "Video URL", but it doesn't work (as of v0.20).  Once you hit "Save" any required backward slashes "\" are replaced with "/" forward slashes which windows and VLC won't recognize.  In other words, what you need is something like:
+
The easiest way is to modify one file and at the prompt, first change to the includes directory, make a backup of the file, then edit it:
myth:\\MyMythBackend\recordings
+
 
but hitting save changes it to
+
<pre>
myth://MyMythBackend/recordings
+
# cd /var/www/html/mythweb/includes
 +
# cp utils.php utils.php.mybackup
 +
# nano utils.php
 +
</pre>
 +
 
 +
Then in the video_url function on about line 328, make the following modifications by changing the original code:
  
The only way is to modify the field directly in the database from a terminal window:
+
<pre>
# mysql -u root mythconverg
+
if (!$ext && $_SESSION['file_url_override']) {
(enter the password)
+
...
mysql> UPDATE `settings` SET `data` = 'myth:\\\\MyMythBackend/recordings/', `hostname` = NULL WHERE `value` = 'WebVideo_URL' AND `hostname` IS NULL LIMIT 1 ;
+
  // Which protocol should we use for downloads?
* Note the multiple backslashes are required, and yes there are forward and back slashes in there but VLC figures it out.
+
</pre>
 +
to this:
 +
<pre>
 +
if (!$ext) {
 +
    $pos1 = stripos($show->filename,"192.168.0.103");
 +
                      # Change this ^^^^^^^^^^^^^
 +
    $video_slave_url = "Mypath\\to\\my\\recordings\\on\\my\\slave\\backend";
 +
          # Change this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
    $video_master_url = "Mypath\\to\\my\\recordings\\on\\my\\master\\backend";
 +
          # Change this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
    if ($pos1 == "")
 +
            return 'file:\\\\'.$video_master_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
 +
    else
 +
            return 'file:\\\\'.$video_slave_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
 +
}
 +
  // Which protocol should we use for downloads?
 +
</pre>
  
Now if you go back into MythWeb settings page -> MythTV global defaults, you should see the value you modified directly.  If you hit the recordings page and hold you mouse over a thumbnail, you should see in the status bar a link like:
+
Here is how the code works:
 +
For each recording, it matches the IP address of your slave machine, in the example above, 192.168.0.103 and then it sets hard coded variables, first the network path to slave backend and then the path to the master.  If you look at the HTML of the recordings page, there is a large array at the beginning which this script uses.  That array contains the slave and master IP addresses in the .filename attribute.
  
myth:\\MyMythbackend/recordings/1043_20060919140000.mpg
+
Depending on if the IP address in the filename matches the back end IP address or not, it modifies the value returned to the calling function.
  
and if you click on it, it should bring up VLC and start playing the recording.
+
Of course, change the "video_slave_url" to point to your share you set up in previous steps and make sure to use double slashes.<br> 
 +
<b>Notes:</b>
 +
* This code modifies the direct download icon/link [[Image:Video sm.png]]
 +
* This code works for both slave and master backends
 +
* It only works for one slave back end, although it can be expanded easily.
 +
* It ignores the file_url_override switch in the database.
 +
* You don't need to change anything in your database because everything is hardcoded.
 +
 
 +
'''Reload the recordings page and then right click on [[Image:Video sm.png]] and using "Launchy" send the "file:\\Mythbackend\..." URL to Videolan''' - if it works, then backup your file:
 +
 
 +
<pre>
 +
#cp utils.php utils.php_modified
 +
</pre>
 +
===Upgrading===
 +
When the next update overwrites your modified file, diff the files to make sure no major changes have occurred, then copy your custom file back over the new one.  I have a little script I run after each upgrade that does everything for me:
 +
<pre>
 +
#!/bin/bash
 +
echo "---------------------> Now checking the diff of utils.php..."
 +
cd /var/www/html/mythweb/includes
 +
diff utils.php utils.php_modified
 +
read -p "Press any key to continue..."
 +
echo "---------------------> Now copying the old modified utils.php over the new one ..."
 +
cp utils.php_modified utils.php
 +
echo "---------------------> Finished!"
 +
</pre>
 +
It changes into the right directory, does the diff and then pauses while the user checks to see the only difference is the custom code.  If everything is ok, it then copies the old modified over the new utils.php.
  
 
===Troubleshooting===
 
===Troubleshooting===
Line 95: Line 132:
 
* Is the directory and file in the place you expect, i.e. \\MyMythbackend\recordings\<etc>
 
* Is the directory and file in the place you expect, i.e. \\MyMythbackend\recordings\<etc>
 
* Can you open that file over the share manually with VLC?
 
* Can you open that file over the share manually with VLC?
* Is the path being generated by MythWeb correct?
+
* Is the path being generated by MythWeb correctly?
  
 
==Modifying MythWeb to View Videos==
 
==Modifying MythWeb to View Videos==
  
If you have videos you want to view directly through MythWeb, you can also share it via samba and modify MythWeb to create the correct links, but it requires modifying two files (assuming you use the default skin):
+
TDB
First, modify
 
* /mythweb/modules/video/handler.php
 
  
Change the line at the very bottom which starts with:
+
==Other alternatives==
$this-url = root . implode (...)
+
See [[Play_Recordings_On_Windows]]
with
 
<nowiki>$this->url = root . preg_replace('#^'.$mythvideo_dir.'/?#', '', $this->filename);</nowiki>
 
  
Then modify
+
[[Category:HOWTO]]
* /mythweb/modules/video/tmpl/default/video.php
+
[[Category:Windows]]
around line 80, change both links from:
 
 
 
echo '<a href="'.$show->url.'"> (...)
 
 
 
and a few lines down:
 
<td><?php echo '<a href="'.$show->url.'"> (...)
 
 
 
to:
 
(...)href="myth:\\\\MyMythBackend\\videos'.$show->url.'"(...)
 
 
 
Then in your videos directory create a symbolic link called MythWeb back to the videos directory, i.e.
 
#cd /mymedia/videos
 
#ln -s /mymedia/videos mythweb
 
Now when you visit the video section of MythWeb, the link should be correct and bring up the movie in VLC when clicked on.  The link should look something like this:
 
myth:\\MyMythBackend\videos/mythweb/myfavoritemovie.avi
 
 
 
(I'm sure there is a way to modify handler.php to get rid of "mythweb", but it was simpler just to put in a symbolic link.)
 
 
 
===Troubleshooting===
 
* Again, make sure you can get to the video share directly first.
 
* Then make sure the URL you put in the video.php file is correct.
 
* Check the symbolic link, it's a bit of a hack.
 
 
 
== Modifying MythWEB to point at mapped drives ==
 
 
 
If you would like MythWEB to send a URL of a locally mapped drive to VLC, simply modify /mythweb/modules/tv/tmpl/default/recorded.php
 
 
 
Case:
 
* Remote recordings directory is mapped to a local drive letter, ie:(/mnt/share == Z:)
 
* VLC and video player is working correcly.
 
* You want to click on the shows thumbnail to play.
 
 
 
---
 
Fix:
 
 
 
Modify line 274 in /mythweb/modules/tv/tmpl/default/recorded.php from:
 
 
 
echo "<a href=\"$show->url\" name=\"$row\">"
 
 
 
To:
 
 
 
(replace '///Z:/' with the drive and path of choice)
 
 
 
echo "<a href=\"myth:///Z:/".basename($show->filename)."\" name=\"$row\">"
 
 
 
===Troubleshooting===
 
* Depending on your video player, it might not accept '/' in the URL.  Change to accepted path format of video player.
 
 
 
--[[User:Derenma|Derenma]] 02:56, 25 September 2006 (UTC)
 

Latest revision as of 14:34, 8 February 2012

Introduction

Below are instructions on how users can browse the recordings via Mythweb on a Windows machine and with one click, have it play in VideoLan (VLC).

Notes

  • These instructions will not work through a firewall or over a slow < 5Mbps connection and assumes the computers are on the same LAN.
  • It just uses VLC player to view the recordings, not the VLC server to stream the recordings.
  • These instructions only work on MythTV 0.21 (or greater). If you want instructions that work on 0.20 or lower, then look at the history of this page.
  • These instructions work on Vista as well as XP.
  • Assumes Fedora Core
  • Assumes latest version of Videolan, v0.9.6
  • Yes, you can use Windows Media Player, but it will not play the High-Def MPEG2 streams.
  • Requires Firefox (well, it doesn't really, the "file://" URLs will open in I.E. but darn if I can be bothered to make it use VLC by default.)

The instructions consist of three parts, first install and configure the necessary Windows applications, share the recordings directory via Samba, then modify a php file.

Time to implement

  • 1 to 1-1/2 hour for recordings and ability to set up Samba via command line

Install Video Player

Videolan and Firefox Addon - Launchy

First get and install VideoLan on your Windows machine. Videolan is an open source video player that can handle all the MPEG codecs.

Second, you will need to install the Launchy add-on for Firefox. It should automatically add Videolan to your list of possible applications to send the link to. You can check by going under Firefox -> Tools -> Add-ons -> <under Launchy, click on "Options">

  • Note: You can use other media players but VLC has much better seek hotkeys, i.e. try the forward/backward buttons on your mouse, CTRL-right arrow or ALT-right arrow!


Configuring Linux Samba Shares

On your MythTV backend, we are going to add a Samba share which will allow any Windows machine on the network to see all the recordings in the recordings directory on a read-only basis. First make sure the Samba and Lisa daemons are running and will start automatically on bootup:

# /sbin/chkconfig lisa on
# /sbin/service lisa start
# /sbin/chkconfig smb on
# /sbin/service smb start

Now, you could edit "/etc/exports" file and add a line to it like "/video/recordings/ *(r,async,all_squash)" (and restart samba) but it is easier to use the graphical interface of KDE. From the start menu, go to Control Panel -> Internet & Network -> Samba Configuration. You can then click the "Administrator Mode", enter the Root password, and setup the "Base Settings", i.e. Workgroup, Netbios name (leave as default) and the description. Then click on "File Sharing" above in the sidebar and go into "Administrator Mode" again, and "Add" the directory that contains all the MythTV recordings, for example "/video/recordings". Set the share to "visible" but not "writable" to avoid having recordings deleted. The name of the share is used by windows, you could call it "recordings".

  • Note: To restart samba use "service smb restart"
  • Note: If you can't see anything under the "Samba Configuration" or "File Sharing", check if the processes are running:
# ps -A | grep lisa
# ps -A | grep smb

You should also have set the hostname for the machine at this point by

# hostname MyMythBackend

and replace "MyMythBackend" with whatever you want.

  • Note: One of the benefits of having Samba running is that you can now access MythWeb with the hostname, for example http://MyMythBackend/mythweb but make sure the "nmb" service is running.

Now check if your Windows machine can see the recordings directory because there is little point in continuing if it can't. (Give it a few minutes, finding new shares can be slow as it discovers clients, figures out who is the master, etc.) One way to see the share is to enter the following in the Windows Explorer address bar:

\\MyMythBackend\recordings\

replacing the host and share name with yours. Another way is to click on the Start Menu, click Run, and type that into the run command. ie \\192.168.1.123\\recordings\

Modifying Mythweb to View Recordings

The next step is to pass to VLC a URL from Mythweb that it can then use to play the recording off the samba share.

The easiest way is to modify one file and at the prompt, first change to the includes directory, make a backup of the file, then edit it:

# cd /var/www/html/mythweb/includes
# cp utils.php utils.php.mybackup
# nano utils.php

Then in the video_url function on about line 328, make the following modifications by changing the original code:

if (!$ext && $_SESSION['file_url_override']) {
...
   // Which protocol should we use for downloads?

to this:

if (!$ext) {
    $pos1 = stripos($show->filename,"192.168.0.103");
                       # Change this ^^^^^^^^^^^^^ 
    $video_slave_url = "Mypath\\to\\my\\recordings\\on\\my\\slave\\backend";
          # Change this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    $video_master_url = "Mypath\\to\\my\\recordings\\on\\my\\master\\backend";
          # Change this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    if ($pos1 == "")
            return 'file:\\\\'.$video_master_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
    else
            return 'file:\\\\'.$video_slave_url.str_replace('%2F', '/', rawurlencode(basename($show->filename)));
}
   // Which protocol should we use for downloads?

Here is how the code works: For each recording, it matches the IP address of your slave machine, in the example above, 192.168.0.103 and then it sets hard coded variables, first the network path to slave backend and then the path to the master. If you look at the HTML of the recordings page, there is a large array at the beginning which this script uses. That array contains the slave and master IP addresses in the .filename attribute.

Depending on if the IP address in the filename matches the back end IP address or not, it modifies the value returned to the calling function.

Of course, change the "video_slave_url" to point to your share you set up in previous steps and make sure to use double slashes.
Notes:

  • This code modifies the direct download icon/link Video sm.png
  • This code works for both slave and master backends
  • It only works for one slave back end, although it can be expanded easily.
  • It ignores the file_url_override switch in the database.
  • You don't need to change anything in your database because everything is hardcoded.

Reload the recordings page and then right click on Video sm.png and using "Launchy" send the "file:\\Mythbackend\..." URL to Videolan - if it works, then backup your file:

 #cp utils.php utils.php_modified

Upgrading

When the next update overwrites your modified file, diff the files to make sure no major changes have occurred, then copy your custom file back over the new one. I have a little script I run after each upgrade that does everything for me:

#!/bin/bash
echo "---------------------> Now checking the diff of utils.php..."
cd /var/www/html/mythweb/includes
diff utils.php utils.php_modified
read -p "Press any key to continue..."
echo "---------------------> Now copying the old modified utils.php over the new one ..."
cp utils.php_modified utils.php
echo "---------------------> Finished!"

It changes into the right directory, does the diff and then pauses while the user checks to see the only difference is the custom code. If everything is ok, it then copies the old modified over the new utils.php.

Troubleshooting

There are lots of things that can go wrong and the best way to fix it is to track backwards.

  • Can you see the samba share on your windows machine?
  • Is the directory and file in the place you expect, i.e. \\MyMythbackend\recordings\<etc>
  • Can you open that file over the share manually with VLC?
  • Is the path being generated by MythWeb correctly?

Modifying MythWeb to View Videos

TDB

Other alternatives

See Play_Recordings_On_Windows