Thursday, February 25, 2010

iPhone ActiveSync on Gmail, with Custom From: Address

I finally figured out how to get my iPhone to use ActiveSync for Gmail, while still allowing me to use a custom reply-to address. Your mileage may vary, but here you go.

NOTE: This procedure worked for me, but may not work for you. Backup your iPhone before trying it!

(Outside the scope of this document, you must already have 2 accounts setup on your iPhone: (1) An IMAP account that is downloading email from gmail.com, and (2) an ActiveSync account that you're using to sync up Contacts and Calendars. And you must have your vanity reply-to address already registered within your Gmail account. For the purpose of this article, I'll say my vanity address is me@mydomain.com.)

So, with the above as our starting point.

  1. Go into iPhone Settings, then click "Mail/Contacts/Calendars."

  2. Click on the "Fetch New Data" option.

  3. Scroll down and click on "Advanced."

  4. Set your IMAP account to "Manual."

  5. Set your ActiveSync account to "Push."

  6. Back out 2 screens so that you're on the "Mail/Contacts/Calendars" settings area.

  7. Click on your ActiveSync account, and then turn Mail ON. (Calendar and Contacts are probably already ON.)

  8. Click the "Account Info" button at the top.

  9. Change the "Email" field to be your vanity reply-to address, e.g. me@mydomain.com.

  10. Back out 2 screens, to the "Mail/Contacts/Calendars" screen.

  11. Click on your IMAP account.

  12. Underneath "IMAP Account Information," there should be a field named "Address." Edit that field to use that same vanity address, e.g. me@mydomain.com.

  13. Below that are 3 fields for "Incoming Mail Server." Erase the text in each of those 3 fields. (We do this so that your phone won't ever try downloading mail via IMAP.)

  14. Now back out to the main screen (the home screen).

  15. Start the Mail app, and once you're in the inbox, click the back button, and then once more until you see your 2 accounts shown.

  16. Click the ActiveSync account, and then click "Inbox."
Now you should be in your ActiveSync inbox, and it will download your email.

If you start a new message, or reply to an existing message, it should use your me@mydomain.com vanity address as the From: address. The gmail.com address is still exposed in the "hidden" headers, like Return-Path, but there's not much you can do about that.

NOTE: This worked for me, but may not work for you. Backup your iPhone before trying!

Friday, February 5, 2010

iPhone Video Orientation (Tallscreen/Vertical Video)

We have been working with Encoding.com recently to get "tallscreen" (vertically-oriented viewing mode) support working on incoming iPhone videos. Encoding.com now finally supports these videos, but you will need to recognize things correctly on your end, or you won't like the results.

In short, you need to recognize that the video is vertically oriented, and if it is, you want to swap your output WIDTH and HEIGHT numbers in your encoding.com request. If you do that, encoding.com will do the rest.

To understand why, here is what I've learned about how iPhone video works...

The iPhone records video to disk the same way each time: as if you've turned the phone 90 degrees to the left, and put it in landscape mode. This is considered "0 degrees," and the video is recorded in this landscape mode, at 640 x 480 (4:3), no matter which way you have the phone oriented.

If you turn the phone to any of the other positions, it doesn't change the way it writes the bits on disk, it just records the "Rotation" flag according to the orientation the phone was in when the recording process started.

  • 0 degrees: landscape, turned on the phone's left side
  • 90 degrees: vertical/normal, with home button on bottom
  • 180 degrees: landscape, but turned on the phone's right side instead of left
  • 270 degrees: vertical/upside-down, with home button on top
All of Apple's recent video players (i.e. Quicktime) are aware of this rotation flag, and so you might never realize your video is being recorded the way it is until you try to view it on a player that doesn't support it, or encode the video with an encoder that doesn't recognize it. In one of these players or encoders, the video would look to be turned on it's side or upside down.

Encoding.com now supports this flag, and I have confirmed it recognizes it correctly in all 4 positions.

So the only thing you need to do is to recognize that if the rotation is 90 or 270, you need to flip the Width and Height numbers, that's it. Encoding.com does the rest.

So, for example, a user uploads a vertically-oriented video to you (either 90 or 270 degree rotation), recorded at the usual iPhone 640 x 480. You see that it's rotated, and your encoding.com request specifies that the output you want is now flipped, 480 x 640 (W x H). Encoding.com gets your source video, sees the rotation flag, and flips it properly while encoding -- and since you specified the proper output size, the video comes out as expected!

(If the video rotation is 180 degrees, you don't need to do anything. The W x H does not change, since it's still in landscape, and encoding.com will correctly flip the video 180 degrees when encoding it.)

Currently we are using the open source "MediaInfo" program to easily obtain information about an incoming video, and to find whether or not the "Rotation" flag has been set, and to what.