My favorites | Sign in
Project Logo
                
Search
for
Updated Oct 16, 2009 by chris.carey
Labels: Featured
InstallationGuide  
Installation Guide.

MythTV for iPhone

Copyright 2008 Chris Carey (http://chriscarey.com). This program is distributed under the terms of the GNU General Public License

Introduction

This software is not a native iPhone app. It is a web application which is installed on your MythTV server. You access the software by using your iPhone web browser and hitting a URL on your MythTV server.

Apache Setup

You need to set up a /recordings/ Alias for watching videos.

In your apache conf file add:

Alias /recordings /var/lib/mythtv/recordings

You must restart apache for the settings to take effect

Dependency Install

Transcoding Setup

Follow this guide below which is the same one I'm using:

http://mythtv.org/wiki/Streaming_to_iPod_touch_or_iPhone

Two changes I made to the mythipod.sh script to make it work:

1) %DIR%/%FILE% should be %DIR% %FILE% (no slash) 2) change libfaac to aac on the last line

YOU MUST HAVE THIS WORKING BEFORE MYTHTV FOR IPHONE WILL WORK! Transcoding is a huge part of this process. For the most part, you are on your own here. You need to get it to the point that the mp4 files are being generated automatically on your MythTV.

You need to set up a "User Job" in MythTV. Mine is called "Convert to iPod". You can initiate this User Job from within MythFrontend, or MythWeb, or soon from within MythTV for iPhone. There is also a setting in Settings->TV->General where you can tell the MythTV to run "User Job #1" every time a show records. You may want this selected.

Getting transcoding working correctly is probably the toughest part of the install.

After upgrading my Ubuntu, I had to install Medibuntu to get the transcoding working. If you run Ubuntu, you probably need to do the same: http://chriscarey.com/wordpress/?p=26

Set up Smarty Directories

Follow the section SETUP SMARTY DIRECTORIES in the quick start guide http://www.smarty.net/quick_start.php

Install Smarty Templates in smarty templates folder

Install files in the web app folder on your mythtv box

Customize i_settings.php

You must edit this file with correct paths and options

All Done!!


Comment by sdavilla, Apr 05, 2008
Comment by sdavilla, Apr 24, 2008

change

/usr/local/bin/mythipod.sh %DIR%

to

/usr/local/bin/mythipod.sh "%DIR%" "%FILE%"

and revert the changes to mythipod.sh. Both params will be passed now.

Comment by chris.carey, Apr 24, 2008

Thanks! I'll update this guide as soon as editing is re-enabled by google.

Comment by sdavilla, Apr 28, 2008

I hear your pain, I'm doing wiki updates via svn myself on my project

Comment by evan.alter, May 11, 2008

Has anyone had any luck converting HD shows? I convert them but they don't seem to play on the iphone.

Comment by fayoeu, May 17, 2008

I don't understand what you mean by "applications folder" on the iphone or where?

Comment by ted.rathkopf, May 20, 2008

OK. I got it working and it's very cool. I had to tweak the code a bit so it would handle .nuv file. And it needs to be fixed so the cron job won't delete the .mp4 if a .mpg is transcoded to a .nuv after the .mp4 is created.

Comment by yvon.vodounon, Jul 25, 2008

Hi Chris, I really like this app, thank's for the nice job. I would like to have the button 'Convert' to work, but it doesn't in my config. Can you give me some advice.

Regards.

Yvon

Comment by nick.e.see, Aug 16, 2008

anyone else experiencing a problem with safari not properly displaying (or even loading) main.tpl? everything properly works, but i can tell the template is not getting loaded. i've verified the references in i_settings.php and index.php. the paths seem to be correct. i just picked up my iphone 3g yesterday, but i don't it's an issue with that since my mythbuntu box is sending preformatted code.

Comment by nick.e.see, Aug 16, 2008

update to myself: after tail -F my apache error log, i found errors about files that do not exist. i noticed that the files/directories that were mentioned in the error log were the same files/directories i ommitted to copy after setting up the Smarty Templates folders. i'm sure other users have wisely assumed to copy the entire directory contents to /var/www/{mythiphonepath}, but i literally only copied the files the instructions listed. i should have been savvier and copied everything over, like a good little user. anyhow, if anyone else runs in to this, here's the fix. good luck. and great work with this app!

Comment by tim.debaillie, Aug 21, 2008

This is pretty cool. However it doesn't support multiple recording directories? I have three different disks that I store my recordings on and I figured I wouldn't setup LVM because mythtv doesn't need it anymore.

Any help is appreciated.

Comment by paulsmith288, Sep 01, 2008

The new version of mythweb has flash streaming. AFAIK these files are not generated by any user jobs on the myth backend. They are created on the fly.

Is this possible for an apple iphone? I dont want to transcode everything if I only watch 1% of it on my iphone/

Comment by BryanRSmith, Sep 01, 2008

This is very cool. Thanks for the great work. I had to change a few things to get it working.

1) the line in index.php that calls the transcode script didn't work for me. There was a line right above it that slightly different, but commented out. I had to uncomment that line & comment out the original.

2) By default, livetv recordings are shown in the list as well. If you don't want this you can change the sql query on line 44 of i_functions.php to

"SELECT * FROM recorded WHERE recgroup <> 'LiveTV' ORDER BY starttime DESC;"

If you use a recording group other than 'LiveTV', change it accordingly.

3) I was having a problem where clicking a show in the list would always display the details for the first show in the list. This was happening because I transcode my recordings, so all my files are .nuv. getShows() in i_functions.php was trying to obtain the file name by stripping '.mpg' & adding '.mp4', but this gave a screwy file name since my files don't contain '.mpg'. To fix this, change line 54 to

$file_noext = substr($row['basename'],0,strrpos($row['basename'],'.'));

Which will strip any file name, not just .mpg.

Hope this helps anyone running into the same problems =)

Comment by kingmo...@gmail.com, Sep 05, 2008

Mine takes an awful long time to load. It loads 4mb of data, 56 requests with most of them being the preview images for shows.

I modified the main.tpl into showing a non-existant image instead - now it loads 20KB of data and is much much faster.

Comment by wayne.veilleux, Oct 10, 2008

Great job Chris !

I also had to commented out the line that transcode to mp4 in index.php to make it work. Everything is working except that I can't see any mp4 file (already transcode) on the iPhone Safari web interface. Am I alone with this problem :( I had a look the ../smarty/templates_c/%%4545E45E3B9C7%%main.tpl.php that seems to be create from the http session but I'm not a php expert coder... All the transcode mp4 file has 644 rights and are own by root. Is there a way to see debug information from smarty ? because I have nothing from apache . Thanks for any clue.

Comment by mike.isbeorn, Oct 10, 2008

Fixed line 29 in the main.tpl file. It had a hard coded ip address of 10.1.1.20 in the link that takes you back to the home page after hitting the "convert" button.

<a href="http://10.1.1.20/mythiphone/" target="_self">Click here to refresh the video list</a>

<a href="http://{$app_url_root}/mythiphone/" target="_self">Click here to refresh the video list</a>
Comment by laconia, Oct 13, 2008

I am unable to get the transcoding working properly (not an issue with mythtv for iphone). With the ffmpeg shipped with Debian Etch, audio always way ahead of video (sync issues), with newest SVN checkout of ffmpeg, x.264, newest yasm and xvid, some video is perfect, some video has audio that is just completely wrong. I had to use faac with the new ffmpeg. Anyway, still working on getting it right. I always transcode OTA vestigal side band streams encoded to mpeg2video, yuv420p, 1920x1080 1:1 DAR 16:9?, 14569 kb/s, 29.97 tb(r) and Stream #0.10x34?(eng): Audio: ac3, 48000 Hz, 5:1, s16, 384 kb/s

Comment by laconia, Feb 20, 2009

I got this figured out, so I thought I would share this with anyone transcoding mpeg2ts (over the air high definition) to something that the iphone 3G can play from a streaming server such as apache. Here is my ffmpeg line:

ffmpeg -i "${directory}/${file}" -async 3 -r 29.97 -acodec libfaac -ar ${rate} -ab ${abitrate} -ac 2 -s ${width}x${height} -vcodec mpeg4 -b ${vbitrate} -flags +aic+mv4 -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 512k -bufsize 2M -title "${file}" "${directory}/${file}.mp4"

The key here is to ensure the playback is at no more than 30 frames a second, or your iphone will play like 1 second and then stop...like it can't buffer the stream. Of course, when you do this, you will lose audio/video sync since you just yanked some frames out out the stream, so you need to use -async 3 to fix this; 3 works for me, but you may want to experiment. Also, I am using a recent SVN trunk compilation of ffmpeg with libfaac and xvid enabled in the compilation. This made a huge difference in whether ffmpeg could work with me on this TS file.

Comment by luc...@adminsparadise.com, Feb 26, 2009

How hard would it be to add streaming of movies as well?

Comment by LinuxRockz, Jun 26, 2009

Here is what works for me on Mythbuntu 9.04 for mpeg2ts (over the air high definition).

ffmpeg -i "${directory}/${file}" -r 29.97 -async 1 -vsync 1 -acodec libfaac -ab 128 -ar 44100 -ac 2 -s ${width}x${height} -vcodec mpeg4 -b ${vbitrate} -flags +aic+mv4 -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 512k -bufsize 2M "${directory}/${file}.mp4"

Comment by luc...@agilitech.com, Aug 04, 2009

right now the Convert button doesn't work for me. The issue is that the mythipod.sh script is getting the following error Could not open '/storage/recordings/1011_20090804023000.mpg.mp4'

How do I setup the permissions in a secure way to let the apache user write to the /storage/recordings folder. Could I sudo and give it permissions to run the script?

Thanks

Comment by luc...@agilitech.com, Aug 05, 2009

I've got the mythtv for iphone working... Now for improving it. It looks like the 3.0 version of the iphone supports http streaming

This link goes over how to set up streaming http://www.ioncannon.net/programming/452/iphone-http-streaming-with-ffmpeg-and-an-open-source-segmenter/

I'll see if I can get it working.

I tried a streaming site on the web and loading the files is really quick, this would be slick.

Comment by wizgnome, Oct 28, 2009

I got this to work with mythbuntu 9.04 by first installing the unstripped ffmpeg libraries: sudo apt-get install ffmpeg libavcodec-unstripped-52

Changed the mythipod.sh script to use libfaac rather than to try and detect which to use and used the second ffmpeg command line in mythipod.sh

Changed the user job command to use the format in the first comment. /usr/local/bin/mythipod.sh "%DIR%" "%FILE"%

Used the commented out line in the transcode line in index.php

Changed the URL in main.tpl

Added www-data to the mythtv group in /etc/group


Sign in to add a comment
Hosted by Google Code