I'm uploading videos to a web server after choosing the video using the UIImagePickerController. However, videos shot with the camera in landscapeRight orientation are inverted on the server. I want to use AVFoundation to rotate the video before uploading. I've figured out how to get the size and preferredRotation of the video using AVAsset. Now I need to apply an affine transform to the video before uploading.
Here's an example of the size and transform from a landscapeRight video:
2011-01-07 20:07:30.024 MySecretApp[1442:307] size.width = 1280.000000 size.height = 720.000000 2011-01-07 20:07:30.027 MySecretApp[1442:307] txf.a = -1.000000 txf.b = 0.000000 txf.c = 0.000000 txf.d = -1.000000 txf.tx = 1280.000000 txf.ty = 720.000000
How would I transform the video to undo the inversion? I assume that I'd have to export the results to a new file and upload that to the webserver. I'll also have to do a similar conversion to videos shot in portrait to rotate them from landscape so that they are orientated correctly on the server.
Thanks
How about using ffmpeg, which can be included as a library linked into your iPhone app?
Here's a duplicate question with the ffmpeg solution detailed.
来源:https://stackoverflow.com/questions/7896742/how-do-i-rotate-a-video-from-uiimagepickercontroller-before-uploading-to-a-webse