iPhones are rather picky about supporting non-Quicktime video files… as a result my EdiMax IC-7000PTn ip security camera’s motion notification emails weren’t viewable on the device… instead; I’d have to try and remember the external url to the camera and view live. After spending a weekend in Atlantic City for my Mom’s 60th b’day… and getting these useless notifications; I decided to do something about it.
At first; I tried to hack the security camera’s firmware… To complicated with to much risk; as EdiMax doesn’t provide sourcecode for the device… and none seems to have spend a large amount of time on this specific model.
Since I have my IP camera set to dump security motion files onto my LG NAS via FTP, I figured I might as well use the ARM cpu to convert these files using ffmpeg 0.11 and the x264 library to convert the files to a iPhone friendly format. It was a trick to install the x264 library; so please see this post for notes on how I did it. I have root /ssh access to the NAS; unsure if the stock firmware has this so see this post for pointers to the firmware I used. The NAS should have the other prerequisites already installed, but in-case I’ll try to list them all here:
I’ve decided to release the conversion script to the Interwebs via the MIT License for anyone to use. I’d appreciate a talkback/”thank you comment” below if you’ve used it. You can download the script here:
iPhone BASH script
The script is fairly well commented so you should be able to modify it as needed. For the most part; the implementation specific variables are near the top of the script. The Must Change are as follows:
Variable |
Description/Usage |
sourcelocation |
Location of the source videos to convert; typically a “dropbox” ftp-ed in from your camera |
backlocation |
Backup location of the videos after conversion.
original files are saved for later review |
sourceext |
file extention for the source videos.
Used to detect new files from “old”. |
conversionext |
file extention for the converted videos.
Almost always “mp4” as to be compatible with iPhone. |
extcamurl |
External URL for your IP camera.
Can Specify :port in url for non-80 applications.
Typically a dynamic dns service. |
intcamurl |
Internal URL for your IP camera.
Can Specify :port in url for non-80 applications.
Used when your inside your home’s network. |
Other interesting variables – change may be required |
ffmpeg |
FileSystem location for the ffmpeg binary.
Use which ffmpeg to find it. |
ffopts |
holds ffmpeg commandline options for trans-coding to iPhone format.
Could theoreticly be used to trans-code to other smartphone formats. |
qtf |
FileSystem location for the qt-faststart binary.
Used to reverse Quicktime(iPhone) metadata so video is played immediately instead of downloading.
Use which qt-faststart to find it. |
uue |
FileSystem location for the uuencode binary.
Used to base64 encode the video files for MIME attachment.
Use which uuencode to find it. |
verbose |
Set to 0 to keep emails near 1screen on iPhone. |
MAILTO |
if non-root or non LG NAS; you may need to hard code this to the destination email address to send the notification to |
SMTP_AUTH |
if non-root or non LG NAS; you may need to hard code this ON for smtp authorization |
SMTP_USER |
if non-root or non LG NAS; you may need to hard code this a username for smtp authorization
This var is near the end of script |
SMTP_PASS |
if non-root or non LG NAS; you may need to hard code this a password for smtp authorization
This var is near the end of script |
sourceage |
number of days the converted files will remain in sourcelocation |
backage |
number of days the orginal files will remain in backlocation |
The script is designed to be run as root via crontab. The Author runs it every minute during daylight hours- this may change when/if he gets additional cameras with night vision. The current version of the script is designed to ensure no other encodings are running – ie more than one instance of iPhone.sh via job control (pgrep). The original video files are backed up to a specific folder and the script makes sure that directory exists.
When sending email using sSMTP; the script will timeout after 90seconds and kill the sSMTP app. You may want to increase this time if you have long videos or a slow Internet connection.
That’s about it… of course, YMMV – but this works very well on my systems and iPhone4. I can get multiple video attachments in a single email; each viewable on my iPhone from the email message.
As an example; here’s a screenshot of the email received on an iPhone4:
V1.1 improvements include a “backup” retiring system thanks to MikeS (a reporter at Hackaday.com) and Hackaday commenter gerphy. Their input included the find commands with some extra sauce to include variables for sourceage and backage.
Feedback is welcome – but all comments are screened by myself to prevent comment “spam”.