user258279
user258279

Reputation: 381

How to set preferredTransform in AV Foundation video file copy

I am using AVAssetReader and AVAssetWriter to transcode video from one file to another. AVAssetReaderTrackOutput was added to the AVAssetReader. Unfortunately, the single track's preferredTransform property was not copied from the input to the output, so a video recorded in portrait orientation is played back in landscape.

How can I set the preferredTransform property in the output file?

Upvotes: 1

Views: 3261

Answers (1)

user258279
user258279

Reputation: 381

I've just found my own answer: Set the transform property of the AVAssetWriterInput to the preferredTransform property of the input track, for example:-

assetWriterInput.transform = [[tracks objectAtIndex:0] preferredTransform];

Would have found this quicker in the doco if these two properties hadn't had different names for the same thing.

Upvotes: 6

Related Questions