I' trying to capture video by AVAssetWriter
and AVCaptureOutput
You can find sample project here.
The video should be in portrait mode with any resolution. The main problem that it should be in portrait mode.
I'm trying to set different setting, but in the end, video is rotated and scaled to size (1920x1080) on iPhone SE.
Is it possible to control this resolution? Or at least orientation?
Video resolution is determined by the
AVCaptureSession
sessionPreset
. You're setting that to medium, so you're getting the resolution that comes with that. If you want a different resolution, pass a different session preset, or useAVCaptureDevice
to set a specific capture format. (For a good overview of capture session presets vs device formats, go back to this WWDC13 video.)Per this Apple Developer Q&A, you need to set an orientation on the capture connection after you start the capture session in order to get "physically" rotated frame buffers (at a capture performance cost), or set the
transform
property on your asset writer (so that buffers are recorded in the sensor's native orientation, but clients display it in your intended orientation).