0

My app uses the UIImagePickerController to record a video, and I'm then uploading it to our Amazon server using ASIS3Request.

Whilst the video always plays in the correct orientation on the device, the orientation is wrong when viewed in some browsers.

Is there a way for me to manually set the orientation of the phone onto the image file when it's being taken? Or is the problem exclusively with the browsers (and if so, how can I fix that)?

Thank you. S.O. for president!

Duncan

theDuncs
  • 4,649
  • 4
  • 39
  • 63

1 Answers1

4

the iPhone sets the orientation in the exif data of the video. It will play back just fine in quicktime, but everywhere else has it rotated wrong.

There are two ways to solve it, rotate it on device, or up in the cloud. You can ask the video for it's preferred transform on the device and that will let you know what you need to rotate it.

   AVURLAsset * footageVideo = [AVURLAsset URLAssetWithURL:assetURL options:nil];
   AVAssetTrack * footageVideoTrack = [footageVideo compatibleTrackForCompositionTrack:videoTrack];

   CGAffineTransform t = footageVideoTrack.preferredTransform;

Once you have the transform you can use an AVExportSession to rotate the video, although this can take quite some time on device.

Randall
  • 14,691
  • 7
  • 40
  • 60
  • Thankd Randall. I'm going to check this out tomorrow, but to confirm, you're suggesting that I can't simply mark the orientation on the video (in the same way the iPhone does and that quicktime recognises) but instead I need to physically rotate the video frames so that they are at the standard orientation? – theDuncs Feb 08 '12 at 18:14