Rotate AVAssetWriter's output 180 deg about the x-axis
Asked Answered
A

2

7

I'm creating a Quicktime movie file using AVAssetWriter. Currently the output video is "upside down". In theory I can correct this by rotating the video 180 degrees about the horizontal axis (essentially "flipping" the video). What's the best way to do this?

Currently I'm trying to assign a CGAffineTransform to myAVAssetWriterInput.transform. Perhaps CGAffineTransformMake(a, b, c, d, tx, ty) will allow me to specify the correct affine transformation matrix?

Neither the Apple docs nor wikipedia gives a clear explanation on how an affine transformation matrix works. And there might be a better way all together.

Adjoint answered 20/11, 2011 at 17:35 Comment(0)
B
21
myAVAssetWriterInput.transform = CGAffineTransformMakeRotation(M_PI);

if you want to rotate the video 180 degrees around z-axis, or

myAVAssetWriterInput.transform = CGAffineTransformMakeScale(1, -1);

if you want to reflect in x-axis

Bonbon answered 21/11, 2011 at 12:43 Comment(0)
M
0

[AVAssetTrack preferredTransform] will return the right CGAffineTransform.

You can assign this CGAffineTransform to writeInput.

Muscovite answered 16/11, 2018 at 9:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.