Difference between revisions of "MythTV on Mac OS X"

From MythTV Official Wiki
Jump to: navigation, search
m (Automatic Backend Startup: fix wrong word)
m (Automatic Backend Startup: launchctl commands)
Line 169: Line 169:
 
</pre>
 
</pre>
  
Note that the path to the MythBackend application binary should be set to where you happen to keep it.  If you need to stop the process, you cannot just <code>kill</code> it.  Instead use <code>launchctl unload -w ~/Library/LaunchAgents/MythBackend.plist</code>.
+
Note that the path to the MythBackend application binary should be set to where you happen to keep it.  If you need to stop the process, you cannot just <code>kill</code> it.  Instead use
 +
launchctl unload -w ~/Library/LaunchAgents/MythBackend.plist
 +
and once you are ready to start it again type
 +
launchctl load -w ~/Library/LaunchAgents/MythBackend.plist
  
 
== Gotchas and Warnings ==
 
== Gotchas and Warnings ==

Revision as of 20:17, 16 November 2009

New users: before attempting to install MythTV for the first time, please familiarize yourself with the distinction between frontend and backend.


Installing pre-built MythFrontend binaries

Pre-built Downloads

Version Download
0.22-fixes
0.21-fixes
0.21
0.20.2
0.20-fixes
0.20
0.19-fixes
0.19
0.18.1-fixes
0.18.1
0.18
0.16
older

Nigel Pearson can also provide a 0.15 or 0.17 binary, if you really need one.

svn (nightly builds)


You're now ready to run mythfrontend! Find the MythFrontend.app icon and double click it to start mythfrontend. If it doesn't start, open a console window to see the mythfrontend output which may give you some clues as to what's wrong.

Installing MythTV Backend on Mac OS X using prebuilt binaries

Warning.png
The prebuilt MythBackend.app binaries from 0.21-fixes do not work on Snow Leopard as of 20090921 SVN Revision 21625. The status of 0.22 is unknown. It's recommended you wait to upgrade to Snow Leopard if you rely on MythBackend.app


Install Wget

The MythFillDatabase program (fetches schedule info) depends on wget which is not included in the default install of Mac OSX. It can be installed directly, via Fink or MacPorts, or by downloading and building it. MythTV-Setup.app also uses wget when trying to obtain the channel list so one must install wget before trying to use the backend.

Set Up MySQL

The MythTV backend relies on having a MySQL database available for storing information about upcoming and past recordings, channel setup, and the like.

Download and Install

Grab and install MySQL 5.0 for Mac OS X from the Mysql site.

Server Startup

After installation, the mysql server needs to be started. The MySQL distribution includes a Preference Pane for this, which is the easiest way to make MySQL start automatically. A more system-wide way would be to use launchd by setting up a plist in /System/Library/LaunchDaemons/. To start MySQL manually you can use /usr/local/bin/mysql/bin/mysqld. This may prompt an error message for lack of access to the directory. If it does type chmod oug+rwX directory to enable it, then start the database server again.

Initial Database Setup

Open Terminal. Type in the following and press enter:

cd /usr/local/mysql/bin/

Delete the anonymous mysql accounts by entering the following commands:

shell> ./mysql -u root
mysql> DROP USER '';

If you don't know your machine's hostname, look it up in the table produced by entering

mysql> SELECT Host, User FROM mysql.user;

Then, set passwords for root account by entering the below commands and substituting your desired password for newpwd and your backend machine's hostname for host_name.

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');


Finally, create the mythtv user and database in MySQL, substituting your desired password for that user where it says "mythtv-password":

CREATE DATABASE if not exists mythconverg;
GRANT ALL ON mythconverg.* TO mythtv@localhost IDENTIFIED BY "mythtv-password";
FLUSH PRIVILEGES;
GRANT CREATE TEMPORARY TABLES ON mythconverg.* TO mythtv@localhost IDENTIFIED BY "mythtv-password";
FLUSH PRIVILEGES;
ALTER DATABASE mythconverg DEFAULT CHARACTER SET latin1;

The above commands are equivalent to the setup script that runs automatically when you install MythTV on other *nix distributions.

Now download the backend (from one of the servers above).

Launch MythTV-Setup.app and go through the configuration steps. Follow the instructions (it will tell you to run MythFillDatabase.app once you've setup your capture card).

You're done! Watch and record TV using MythFrontend.app.


Automatic Backend Startup

One way to start the backend is to make it a Login Item for the DVR user using the Accounts section of the control panel. However, MythBackend is really a daemon, and it is nice to control it as such. The approved way to automatically start processes in OSX is to use launchd. Placing the following property list in ~/Library/LaunchAgents/MythBackend.plist of the relevant user account will cause MythBackend to be started whenever that user logs in, and restarted if killed or crashed.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>MythBackend</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/MythBackend/MythBackend.app/Contents/MacOS/MythBackend</string>
		<string>-l</string>
		<string>/var/log/MythBackend</string>
	</array>
</dict>
</plist>

Note that the path to the MythBackend application binary should be set to where you happen to keep it. If you need to stop the process, you cannot just kill it. Instead use

launchctl unload -w ~/Library/LaunchAgents/MythBackend.plist

and once you are ready to start it again type

launchctl load -w ~/Library/LaunchAgents/MythBackend.plist

Gotchas and Warnings

Limited Tuners

As of v0.21, the Mac OS X backend does not support the majority of tuners listed as being supported by the (Linux) version of MythTV. The following tuners are known to work using the Mac version of Myth backend: HDHomeRun. Recording via firewire from set top boxes such as the Motorola 6412 or Motorola DCT 6200 is also known to work. Plans (if any) for additional support are unknown.


Dolby AC3 Sound

(As of mythtv 22-fixes-20091115) You cannot yet use AC3 passthrough of Dolby digital audio, due to the bug discussed in #5552. Do not turn on this option in your setup.

Channel Scan

(As of mythtv 21-fixes-20090215) Multicore machines are likely to run afoul of bug #5832, crashing setup while trying to perform a scan for channels. While on some operating systems one can use the taskset command to restrict to a single core, OSX lacks any equivalent. The problem is claimed to be fixed in the "mythtv-channel-scan" branch of SVN, but as of this writing no prebuilt backend binaries are available for this branch. The best workaround is presently to set up a temporary backend on Linux, scan channels, and then copy the channel and dtv-multiplex tables back to the Mac using mysqldump. (Not everyone runs into this problem)

Firewire Recording

(As of mythtv 0.21-fixes-20090316) There is one important note if trying to record via FireWire on an Intel Mac. The MythBackend cannot get a LAM lock signal when recording TV via FireWire. The solution is to check the "Open with Rosetta" checkbox on the Get Info panel of MythBackend.app. See this post for information.

Because of this, it's important to open MythBackend.app from the Finder and not from a Terminal window because it won't open with Rosetta. There must be some PPC-specific FireWire code in there.

This method had successfully been used to record HD over FireWire on a Intel Mac Mini (Macmini3,1) on a Motorola DCT 6200 cable box.

Building MythFrontend yourself

Building Automatically

The easiest way to build MythTV from source is to download the packager script. Either http://svn.mythtv.org/svn/branches/release-0-22-fixes/mythtv/contrib/OSX/osx-packager.pl or http://svn.mythtv.org/svn/trunk/packaging/OSX/build/osx-packager.pl. This script just needs XCode and an internet connection - it downloads and builds all the dependencies, and if you are lucky gives you several double-clickable applications.

Building Manually

Sadly, the packager script doesn't always work. Maybe one of the downloadable dependencies has been outdated, and someone needs to try building against a newer one. Maybe the MythTV source code has changed and broken Mac builds. Look on the Myth_on_Mac_-_Build_status page for hints about this.

To get current information about what the build process should look like, you can always inspect the packaging script. Obviously if the script is failing then there will be at least one part of it that needs a tweak, but the remainder of the script should save you a lot of time.

The rest of this guide is meant for those who would like to try out the latest MythTV code on Mac OS X, but are having trouble setting up the development environment. Many folks have had trouble figuring out which dependencies and versions are necessary, so this will help you get to a known working configuration. If you like to copy-and-paste commands, you'll love this guide.



Important.png Note: To use a handbuilt OS X version, it may be easier to start with a Linux machine running a recent SVN version of MythTV to act as a backend. If you've never installed MythTV, you can first set up Linux version such as MythBuntu, and only look at the OS X version once everything's working properly there. That said, don't be discouraged; many people use a OS X with FireWire STBs, IPTV, and the HD Home Run.

If you just want to watch TV on your Mac, and you aren't planning to do development, you're better off using a prebuilt binary.

These instructions also assume that you're doing a completely clean reinstallation on your machine. If you don't start from scratch, some of the instructions may not be correct for your setup. If you're really having problems, back up your data and try these instructions again, doing a clean re-install of OS X as directed below.

Install OS X

The first step is to get a computer running Mac OS X. To watch TV at acceptable speeds, you'll want at least an 800 MHz G4 or better. For HDTV nearly any Intel-based Mac released from 2008 onwards will suffice.

If you're starting from scratch, install Mac OS X 10.3 (Panther) or later on your future Myth box. Do a clean installation, not an upgrade -- I recommend the "Erase and Install" option to be sure you won't have problems from earlier data on your drive. For underpowered systems, when you're offered the chance to Customize the installation, turn off all the options except "BSD Subsystem". (The option "Essential System Software" cannot be turned off, so you will have two checked items total.)

Continue with the installation and restart. Go through the setup and registration screens as normal. Once you reach the Finder, run Software Update and get any OS updates. Apply the updates and restart when directed by Software Update.

Not all software updates can be installed in one step, so you should run Software Update again after installing updates. QuickTime is used for MythVideo, so it is recommended to update that. Install any updates and restart; keep repeating this pattern until no updates remain.

Underpowered systems may also wish to disable Spotlight indexing to avoid intermittent performance drops.

Install OS X Developer Tools

You've got the latest and greatest OS, but the tools for compiling software are installed separately. Visit the Apple Developer Connection website and log in. If you don't have an ADC account, you can create a free one. This gives you access to Apple developer tools, prerelease software, and other useful items.

Once you've logged in, click on "Download Software" and then "Developer Tools". Download the latest "Xcode Tools" software. Install the software by opening "Xcode Tools.mpkg" from the "Xcode Tools" disk image. You can do an Easy Install, the defaults are fine for building MythTV.

To checkout MythTV from Subversion source tree the Subversion Binary Subversion Client and Server for Mac OS X is required. Download and install the application. Subversion will be installed in /usr/local/bin.

Set up your environment

That's it for the graphical Mac stuff. From here on out, we'll be working in Terminal. If you're a Unix geek, things should look a lot more familiar. If you aren't comfortable with Terminal, this probably isn't the best place to start; I suggest you learn a bit more about Unix before attempting to go further.

From a new Terminal window, start by setting up some useful environment variables in your profile. Create a .bash_profile in your favorite text editor:

# vi .bash_profile

Add the following to the new file and save it:

Script.png .bash_profile

export SRCDIR=$HOME/src
export QTDIR=$SRCDIR/qt-mac-free-3.3.8
export DYLD_LIBRARY_PATH=/usr/local/lib:$QTDIR/lib
export PATH=$PATH:/usr/local/bin:$QTDIR/bin

Next, load these variables into your current session, and create SRCDIR where you'll be downloading and compiling.

. .bash_profile
mkdir $SRCDIR
cd $SRCDIR

Optional: if you'd like to be able to run mythfrontend by double-clicking its icon from the Dock or the Finder, you'll have to set the DYLD_LIBRARY_PATH environment variable for the graphical environment. (Your .bash_profile</nowiki> only affects what you do in Terminal.) To enable this, create the file

Script.png ~/.MacOSX/environment.plist

mkdir ~/.MacOSX
vi ~/.MacOSX/environment.plist
Add the following to the new file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/[[Property List]]-1.0.dtd">
<plist version="1.0">
<dict>
        <key>DYLD_LIBRARY_PATH</key>
        <string>/usr/local/lib:/Users/username/src/qt-mac-free-3.3.8/lib</string>
</dict>
</plist>

Replace username above with your user name. Note that we set the same directories as in the .bash_profile, except that the other environment variables have been expanded into full paths.

Free Type

Free Type is the first of several dependencies you will have to install for MythTV. First download and unpack the source code:
curl http://download.savannah.gnu.org/releases/freetype/freetype-2.1.10.tar.gz | tar -xz
cd freetype-2.1.10
Next, configure and make the source. These instructions use shared libraries for building MythTV, and include flags to turn on prebinding (a run-time optimization that launches programs faster), so they differ from the generic defaults provided by the project's install instructions. If you follow the commands here exactly, you should be OK.
./configure --disable-static
make LDFLAGS="-no-undefined -Wl,-prebind,-seg1addr,0xC0000000 -lz"
sudo make install

When sudo asks for a password, enter your Mac login password. You'll get used to doing this a lot over the course of this guide.

Free Type is installed, so we return to SRCDIR in preparation for the next step.
cd ..

Freetype can also be installed via Fink or Portage OS X. See Fink And Portage for more information.

LAME

The process here is the same as Free Type, so I won't repeat the same explanations. Just use these commands:
curl http://superb-west.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz | tar -xz
cd lame-3.97
./configure --disable-static --disable-frontend
make LDFLAGS="-no-undefined -Wl,-prebind,-seg1addr,0xC1000000"
sudo make install
cd ..

LAME can also be installed via Fink or Portage OS X. See Fink And Portage for more information.

MySQL

Important.png Note: MySQL removes older versions of their software from their servers after a while. If mysql-5.0.87.tar.gz disappears, go to the server here and find the latest mysql-5.0.XX.tar.gz. Change the version number in the instructions below and mysql should build fine.


Again, there's nothing too complicated. You only need the client library from MySQL, so these commands turn off a lot of the parts that the installation offers.
curl http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/mysql-5.0.87.tar.gz | tar -zx
cd mysql-5.0.87
./configure --disable-static --without-debug \
  --without-server --without-geometry \
  --without-extra-tools --without-docs \
  --without-man --without-bench
make LDFLAGS="-no-undefined -Wl,-prebind,-seg1addr,0xC2000000"
sudo make install
cd ..

Qt

(Qt is an application framework from Trolltech while QuickTime is a media suite from Apple)

Installing Qt is a bit more complicated, so we'll take this one more slowly. First get the source code:
curl ftp://ftp.trolltech.no/qt/source/qt-mac-opensource-src-4.4.3.tar.gz | tar -xz
cd qt-mac-free-4.4.3


Make sure you update Quicktime completely, including the Quicktime SDK, using Software Update.


Next, configure the installation. Qt takes a long time to build, so we turn off everything that's not absolutely necessary.


Important.png Note: the command below turns off all window styles except "Windows"; this style looks best with MythTV, in my opinion, so I don't build the others. You may want to remove some of the -no-style-blah flags and try out other styles on your system.


./configure -release -fast -qt-sql-mysql \
    -no-exceptions -no-accessibility -no-stl \
    -no-sql-sqlite -no-sql-odbc -system-zlib -no-libtiff \
    -no-libmng -nomake examples -nomake demos \
    -no-nis -no-cups -no-qdbus -no-framework' \
  -I/usr/local/include/mysql \
  -L/usr/local/lib/mysql

The configure step takes a while, but don't go get that cup of coffee right away; you will have to accept the GNU General Public License before it gets going. Type yes when it prompts you, then you can take a break.

The make process requires a bit of explanation. Qt needs the -single-module< flag to build correctly with our MySQL installation; the first line adds this to the compile instructions. We only build the sub-src target, as we only need the Qt library; this skips the documentation, examples, and a hundred other things that aren't necessary for working with MythTV.
echo 'QMAKE_LFLAGS_SHLIB += -single_module' >> src/qt.pro
make sub-src

We're now finished with Qt, and with all of the dependencies in fact.

cd ..


Alternatively to compiling Qt yourself, you can grab a precompiled package from http://naranja.umh.es/~atg/

Backend Setup

Make sure you set your backend to listen on some other IP address than 127.0.0.1 (which is the default). Run
 mythtvsetup

on your backend mythtv installation and put your not-127.0.0.1 IP adress in the database parameters; 192.168.1.x perhaps, whatever your network interface runs on and more importantly what IP address you set mysql to listen on.

You'll also need to allow connections to the mySQL server on your backend machine over your network.

 mysql> grant all on mythconverg.* to mythtv@"10.0.1.%" identified by "mythtv";

MythTV

NOTE: If you decide to run ./configure and not use the osx-packager.pl, you MUST use the --disable-distcc flag or else your configure step will fail with some endianness check message.

Finally, we're ready for MythTV itself. Download the main MythTV source:
svn co http://svn.mythtv.org/svn/branches/release-0-20-fixes/mythtv
Now we configure and make MythTV itself. Assuming that nothing is broken in the SVN tree (which happens sometimes for the Mac build), the defaults should work fine:
cd mythtv
sudo ./configure --disable-distcc
make
sudo make install

If you look at your config.err file and see that the endian test failed, just use the osx-packager.pl script in the contrib directory to build MythTV.

Presuming you're in the mythtv directory already, simply type:
cd contrib
perl osx-packager.pl

It may still fail using GCC 4.x but should work if you change your GCC modules to 3.3.3-7. It will take a while to complete. Basically, it re-installs everything you have installed to this point.
source: mythtv-user list


If you're missing qmake, return to the qt-mac-free-3.3.8 directory from the previous installation and install it from there:

cd ../qt-mac-free-3.3.8
cd qmake
sudo make install
You must launch the frontend from the command line, as launching it through the Finder will not work properly (unless you completed the Optional section of step 3). Run the frontend with this command:
/usr/local/bin/mythfrontend.app/Contents/MacOS/mythfrontend

You'll be prompted for the MySQL connection parameters when it starts up. Enter the hostname for your Linux backend, and change any of the other parameters as appropriate. (This part is not Mac-specific and depends on your backend setup.) You should see the main menu for the frontend after it successfully connects to the MySQL server.

When you update to the latest CVS, you should do a clean rebuild to prevent problems:
make distclean
cvs -z6 update -dP
./configure
qmake mythtv.pro
make
sudo make install

Tips and Tricks

Playback Settings

In the setup screens, explore the "TV Settings" -> "Playback" options. You'll find two pages of Mac-specific settings there. If your machine isn't fast enough, you can choose to drop frames here. If you have cycles to spare, you'll find fun settings like video in the Dock, on the Desktop, or in a floating (and optionally translucent) window.

Remote Control

Apple Remote

The standard keys work as expected: Directional keys generate arrow keys, Play/Pause: Enter, Menu: Escape. Holding down keys will generate alternate inputs: Hold Play/Pause: P (play/pause playback), Hold Menu: M (Menu in playback), Hold Left/Right: Home/End. The Apple Remote will not work properly on versions of Snow Leopard prior to 10.6.2 (#7112).

Other Infrared Remotes

See Keyspan Express Remote.

Bluetooth Control

If you want to try controlling MythTV via Bluetooth, Brad came up with a 'Salling Clicker' action http://members.shaw.ca/dignon/MythTV%20Remote%20Suite%20v1_1.cgz

Computer To Computer Network Control

If you want to try controlling MythTV from another Mac (perhaps by a PowerBook from the couch), Generally Helpful Software has released an early beta of a remote control application, Remote Remote GH for MythTV http://web.mac.com/grhowes/iWeb/Generally%20Helpful%20Software/Remote%20Remote%20GH.html

Another Mac OS X network remote control is available at http://ignasiak.googlepages.com/mythremote

MythGrowl Notifications

There is an application for Mac OS X called 'MythGrowl' that generates Growl notifications when your MythTV backend starts or finishes a recording. Not part of Mythfrontend but worth a mention. It can be downloaded at http://mythgrowl.sourceforge.net/

Performance Tweaks for Underpowered Systems

To improve playback performance try new 'Use libmpeg2' setting (on the first page of Setup, Settings, TV Settings, Playback. Running TV playback in a smaller window can also improve performance, as can customising your backend recording settings. (e.g. Smaller capture from analog cards, 44.1KHz audio is a better match to some Macs than 48KHz)



For more information

Mailing Lists

If you have problems with this guide, the mythtv-users mailing list is the best place to start. Check the searchable archive to see if your problem has already been discussed. Also, you can check the mythtv-dev list to see if it's a problem with CVS; if you can't compile MythTV, you may just have to wait a few days and try again.

When posting to the -users list, mention this guide and put "OS X" in the subject line. If you don't do those two steps, your humble guide author (Jeremiah Morris) may miss or ignore your message.

External Links

Mac Mini frontend and backend

Mini usage report

Wiki

For MythTV on Mac OS X on Intel machines, there is also also Myth on Mac x86. (However, that page is very out of date in many respects.)

Help Improve This Page

Finally, remember that this is a Wiki. If you find an inaccuracy, or have advice that may be helpful to others, improve this guide by adding your information!