PHPMotion iPhone Template and Converter

So I've built an iPhone template for PHPMotion which is based on iWebkit and I figured it was time it made it's debut.  I wrote queries into iWebkit so that it presents the contents of PHPMotion's database to the user in a form that makes iPhones, iPads and Androids happy.  You can see a sample of my full site as well as the mobile  site.

The key to this template is getting PHPMotion to convert the files to mp4 so that the iphone is happy with that.  To do that i wrote a conversion script that is to be run in a cron job (mine is set to every 10 mins).  So that it converts the videos that have been uploaded in the past 10 minutes to the iphone friendly mp4 format.

NOTEFor this to work your ffmpeg binary has to be compiled with --enable-libfaac.  I am working on a how to that will show you how to recompile ffmpeg (see helpful links below), until then you are on your own.  To test if your ffmpeg binary will work, open up an ssh session to your server, and run the command ffmpeg.  You should see something like this:

# ffmpeg
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --incdir=/usr/include --enable-libamr-nb --enable-libamr-wb --enable-libdirac --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-x11grab

If you don't see the --enable-libfaac, then you are out of luck and will have to recompile ffmpeg.  Below are basic instructions on how to get this working on your site.

Download PHPMotion Iphone Template

I offer up this template and converter script to you free, I'll do my best to help you get it installed but can't make any guarantees. If it works for you and you want to show some love I've provided a donate button below... no pressure, but I do love love... ;)

Install instructions:

  • download template package (see link above)
  • unpack and copy to a directory inside phpmotion.  (I chose "ip")
    • so when you go to http://yoursite.com/ip you will see the new iphone template.
    • edit ip/inc/main.inc.php
      • enter your database name, database user, and database password in the variables.

main.inc.php$database="your_db_name";    // this is the db that phpmotion is installed in
$db_user ="your_db_user"; // this is your databse user
$db_pass ="your_db_password"; // this is your database password

  • copy vid_script/converter to your uploads directory and configure the variables inside the script
    • Make sure to chmod a+x converter (otherwise it won't run)
  • setup cron to run every 10 mins

Insert into crontab0,10,20,30,40,50 * * * * /path/to/public_html/uploads/converter

  • insert redirects into phpmotions pages to redirect people who are visiting on their iphone/ipad/android phones. (see examples below)

this is what a redirect should look like for the iphone:

Insert into play.php // added to redirect iphones to video content
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($browser == true) { header("Location: http://yoursite.com/ip/vidview.php?vidid=$vid"); }

Insert into album_view.php // added to redirect iphones to photo content
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($browser == true) { header("Location: http://yoursite.com/ip/picview.php?imgid=$image_id"); }

Note: make sure to change the yourstie.com in the urls above with your site.

 

Helpful links:

Support Forum

Need Help?

Visit the Support Forum