HOWTO Setup MythExport for iPod¶
MythExport is a daemon for exporting and transcoding recordings from MythTV. It can be used as a replacement for myth2ipod, and (unlike myth2ipod) is still actively supported and maintained. This is a HOWTO guide to getting it working with R6.
Don't let the length of the instructions below faze you. The install is actually fairly straightforward. I assume no prior knowledge of myth2ipod and just a basic familiarity of Linux and MythTV. Most of the length is due to the stuff to copy/paste, plus my natural longwindedness. Smile
A bit of background: I used myth2ipod quite a bit but since moving to R6 have been unable to get it to work. While researching problems with it in R5.5, I discovered MythExport as an alternative, but could never get it to work due to dependency problems. Then I managed to solve my myth2ipod issue so I left it. However, after failing to fix new myth2ipod problems in R6, on a total whim of frustration I typed in "pacman -S mythexport", fully expecting it to say "package not found". To my utter amazement, it did not, and instead asked me to confirm the install!! (A big THANK YOU to whoever (cecil?) decided to include this!)
After the stun wore I proceeded to try to get MythExport to work. Alas, it was not a simple matter, as R6's setup does not match what MythExport expects. Indeed, my first two cracks at it quickly turned into failure, and for a while I went back to trying to fix myth2ipod, without success. Eventually I tried again to fix MythExport and this time managed to get it working. Third time's the charm I guess!
NOTE: All file operations (creates, executes, etc.) should be done while logged in as mythtv, unless otherwise noted.
1. First, install the package along with two additional dependencies that are not in the PKGBUILD:
sudo pacman -S mythexport perl-proc-daemon perl-proc-pid-file
2. Create some required directories and adjust the permissions on one of them:
sudo mkdir -p /etc/mythtv/mythexport /var/run/mythtv
sudo chown -R mythtv:mythtv /etc/mythtv
3. Normally, MythExport setup is done via a web interface, but I have been unable to get this to work under R6, which uses lighttpd and not Apache as MythExport seems to expect. The good news is we can do without it, but it'd be nice to get this working, if someone with more lighttpd experience can help?
4. Create a configuration file called /etc/mythtv/mythexport/mythexport_settings.cfg using your favourite text editor. Here is mine (which I stole from the forum thread mentioned later), which should work for all non-touch iPods (if you have an iPhone or iPod Touch you may need a different configuration):
dir=/myth/ipodfeed
[ipod]
removeCommercials=0
extension=
codec=mpeg4
sizeY=240
sizeX=320
aspect=4:3
videoBR=600000
threads=
device=ipod
podcastName=MythTV
deletePeriod=
audioBR=192000
ffmpegArgs=-y -acodec libfaac -ab 192000 -vcodec mpeg4 -b 600000 -mbd 2 -flags +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -s 320x240 -deinterlace -aspect 4:3
audioChannels=
deinterlace=1
5. Unfortunately, the MythExport script has a lot of hardcoded values that have not been kept consistent, so we must create a symlink to the configuration file to ensure the daemon can always find it:
ln /etc/mythtv/mythexport/mythexport_settings.cfg /etc/mythtv/mythexport/mythexport.cfg
6. To use the cgi that generates the actual RSS feed, edit /etc/lighttpd/lighttpd.conf and insert the lines below. I don't think it matters where so for consistency I put mine just below a similar-looking entry for pdf files that is roughly 130 lines in:
$HTTP["url"] =~ "/mythexport/" {
cgi.assign = ( ".cgi" => "/usr/bin/perl" )
}
7. As root, follow these steps to create the service scripts:
A. Create a new service directory: mkdir /etc/sv/mythexport
B. Create a script /etc/sv/mythexport/run with the following content:
#!/bin/bash /usr/bin/mythexport-daemon PID=`pidof -o %PPID -x /usr/bin/mythexport-daemon` # Wait until daemon dies, else runit can't supervise us while [ "`pidof -o %PPID -x /usr/bin/mythexport-daemon`" == "$PID" ]; do sleep 2; done;
C. Create a script called /etc/sv/mythexport/finish with the following content:
#!/bin/bash #runit only knows about the run script wrapper, so kill the daemon ourselves kill `pidof -o %PPID -x /usr/bin/mythexport-daemon` >/dev/null 2>&1
D. Make the scripts executable:
chmod 755 /etc/sv/mythexport/*
E. Add the service: add_service.sh mythexport
8. Run mythtv-setup (Alt+S), select General, and go to the screen that lets you edit the job commands. Change the command for the Encode For iPod job to:
mythexport_addjob starttime=%STARTTIME% chanid=%CHANID% config=ipod
9. The location MythExport expects you to use is /myth/archive. If this is acceptable, change the dir setting at the start of your mythexport.cfg. However, if, like me, you prefer a separate directory for your iPod files, you instead need to change the web symlink, and ensure your dir setting matches. In my config I used existing the ipodfeed folder:
sudo rm /usr/share/mythtv/mythexport/video
sudo ln -s /myth/ipodfeed /usr/share/mythtv/mythexport/video
10. Create a link to config.xml where MythExport expects to find it:ln -s /home/mythtv/.mythtv/config.xml /srv/http/.mythtv/config.xml
(Note: you may need to create the directory first mkdir /srv/http/.mythtv/
)
That should be it for the install. To verify the service is running, run ps -ef | grep mythexport and look for the runsv line and the daemon itself. If everything is working, you can now export via the usual job on any recording, using either mythfrontend or MythWeb.
MythExport will log to /var/log/mythtv/mythexport.log. If you need to troubleshoot, stop the service (sv stop mythexport) and then manually run the daemon in debug mode: sudo mythexport-daemon --debug
You can also run the mythexport_addjob script by hand if you have the recording's starttime and chanid.
Note that the daemon waits a bit between polling the job database, so when you add a job processing may not start right away. If you have to do troubleshooting, you can avoid this by adding the job BEFORE rerunning the script, so it will be picked up immediately.
The RSS feed of exported programs can be accessed from this URL, which you can enter into iTunes under Advanced->Subscribe to Podcast: [code]http://localhost/mythexport/mythexportRSS.cgi[/code]
Lastly, once you are sure everything is working be sure to reboot to test that the daemon properly auto-starts!
DISCLAIMER: I run R6 with the new (testing) mythtv 0.22 packages installed. In theory it should work exactly the same if you have the normal 0.21 installation though.
References:
- https://help.ubuntu.com/community/MythExport - MythExport Documentation (for Ubuntu)
- http://ohioloco.ubuntuforums.org/showthread.php?t=1087955 - A very long but useful Ubuntu forum thread on MythExport that may assist in troubleshooting some problems.