简体   繁体   中英

Change camera resolution if I have width and height in iOS

I need to change live video resolution with the width and height inputted by user. Sorry for my question but I have never done it before.

Please help.

You can change video resolution by using AVMutableVideoComposition and AVAssetExportSession .

First create object of AVMutableVideoComposition shown below.

AVMutableVideoComposition* videoComposition = [AVMutableVideoComposition videoComposition];
videoComposition.frameDuration = CMTimeMake(1, 30);
videoComposition.renderSize = CGSizeMake(YOUR_WIDTH, YOUR_HEIGHT);

Then, create object of AVAssetExportSession ,

exporter = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
exporter.videoComposition = videoComposition;

And write completionBlock for exporter.

Hope this helps.

If you are using OpenTok, you can use a custom video capturer that is mostly identical to the one found in this sample . The only difference is that you would need to additionally write code to scale the image from the CVPixelBuffer (called imageBuffer ) to the size which your user is setting.

One way technique to scale the image would be to use the CoreImage APIs as shown here: https://stackoverflow.com/a/8494304/305340

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM