HOWTO Setup MythExport for iPod

Version 2 (turpie, 12/09/2010 12:00 pm)

1 1
h1. HOWTO Setup MythExport for iPod
2 1
3 1
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.
4 1
5 1
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
6 1
7 1
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!)
8 1
9 1
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!
10 1
11 1
NOTE: All file operations (creates, executes, etc.) should be done while logged in as mythtv, unless otherwise noted.
12 1
13 2 turpie
1. First, install the package along with two additional dependencies that are not in the PKGBUILD:
14 1
15 2 turpie
@sudo pacman -S mythexport perl-proc-daemon perl-proc-pid-file
16 1
17 2 turpie
2. Create some required directories and adjust the permissions on one of them:
18 2 turpie
19 2 turpie
@sudo mkdir -p /etc/mythtv/mythexport /var/run/mythtv
20 2 turpie
@sudo chown -R mythtv:mythtv /etc/mythtv
21 2 turpie
22 2 turpie
 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?
23 2 turpie
 
24 2 turpie
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):
25 2 turpie
26 1
      dir=/myth/ipodfeed
27 1
28 1
      [ipod]
29 1
      removeCommercials=0
30 1
      extension=
31 1
      codec=mpeg4
32 1
      sizeY=240
33 1
      sizeX=320
34 1
      aspect=4:3
35 1
      videoBR=600000
36 1
      threads=
37 1
      device=ipod
38 1
      podcastName=MythTV
39 1
      deletePeriod=
40 1
      audioBR=192000
41 1
      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
42 1
      audioChannels=
43 1
      deinterlace=1
44 1
45 2 turpie
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:
46 1
47 2 turpie
@ln /etc/mythtv/mythexport/mythexport_settings.cfg /etc/mythtv/mythexport/mythexport.cfg
48 2 turpie
49 2 turpie
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:
50 2 turpie
51 1
      $HTTP["url"] =~ "/mythexport/" {
52 1
        cgi.assign = ( ".cgi" => "/usr/bin/perl" )
53 1
      }
54 1
55 2 turpie
7. As root, follow these steps to create the service scripts:
56 2 turpie
     A. Create a new service directory: mkdir /etc/sv/mythexport
57 2 turpie
58 2 turpie
     B. Create a script /etc/sv/mythexport/run with the following content:
59 2 turpie
60 1
            #!/bin/bash
61 1
            /usr/bin/mythexport-daemon
62 1
            PID=`pidof -o %PPID -x /usr/bin/mythexport-daemon`
63 1
            # Wait until daemon dies, else runit can't supervise us
64 1
            while [ "`pidof -o %PPID -x /usr/bin/mythexport-daemon`" == "$PID" ];
65 1
              do sleep 2;
66 1
            done;
67 1
68 2 turpie
     C. Create a script called /etc/sv/mythexport/finish with the following content:
69 2 turpie
70 1
            #!/bin/bash
71 1
            #runit only knows about the run script wrapper, so kill the daemon ourselves
72 1
            kill `pidof -o %PPID -x /usr/bin/mythexport-daemon` >/dev/null 2>&1
73 1
74 2 turpie
     D. Make the scripts executable: @chmod 755 /etc/sv/mythexport/*
75 2 turpie
     E. Add the service: @add_service.sh mythexport
76 1
77 2 turpie
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:
78 1
79 2 turpie
@mythexport_addjob starttime=%STARTTIME% chanid=%CHANID% config=ipod
80 1
81 2 turpie
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:
82 2 turpie
83 2 turpie
@sudo rm /usr/share/mythtv/mythexport/video
84 2 turpie
@sudo ln -s /myth/ipodfeed /usr/share/mythtv/mythexport/video
85 2 turpie
86 2 turpie
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
87 1
88 1
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.
89 1
90 1
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: [code]sudo mythexport-daemon --debug[/code]You can also run the mythexport_addjob script by hand if you have the recording's starttime and chanid.
91 1
92 1
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.
93 1
94 1
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]
95 1
Lastly, once you are sure everything is working be sure to reboot to test that the daemon properly auto-starts!
96 1
97 1
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.
98 1
99 1
References:
100 1
101 1
    * https://help.ubuntu.com/community/MythExport - MythExport Documentation (for Ubuntu)
102 1
    * 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.