6

How to record video with both front and back camera at a time in iOS with swift. That is while recording video from iPhone with front camera I want to open back camera and record video. That means finally in one video file I just want to cover both sides

rani
  • 593
  • 3
  • 10
  • 28

5 Answers5

6

With iOS 13, it is now possible to simultaneously capture video natively on both front and back cameras on an iPhone with the A12 chip or later, or an iPad with the A12X chip or later.

Check out the new AVCaptureMultiCamSession class.

AVCaptureMultiCamSession

A capture session that supports simultaneous capture from multiple inputs of the same media type.


Your question is a little unclear though. If instead of simultaneously recording both cameras, you're looking to switch between cameras during the recording, you can utilise this functionality and "merge" the shots at the timestamp where the user switches between the front and back cameras. On older devices, the only way to do that is to stop and restart the recording in a different camera.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
XW_
  • 472
  • 1
  • 5
  • 11
5

According to AVFoundation Programming Guide provided by Apple:

Media capture does not support simultaneous capture of both the front-facing and back-facing cameras on iOS devices.

Bugs
  • 4,491
  • 9
  • 32
  • 41
ABHILASH P
  • 105
  • 1
  • 10
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – Filnor Mar 06 '18 at 13:57
4

I don't think it's could record both camera at one time in IOS. You could check AVCaptureDeviceInput class.

This is how I catch the video from session queue

AVCaptureDevice *videoDevice = [iSKITACamViewController deviceWithMediaType:AVMediaTypeVideo preferringPosition:preferredPosition];

AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput 
deviceInputWithDevice:videoDevice error:nil];

[[self session] beginConfiguration];
Alex Cheng
  • 829
  • 8
  • 20
2

I think you can not access both cameras at a time, means if you are recording with the front camera you don't access the back camera and vice versa. You can check this link.

Community
  • 1
  • 1
Paddy
  • 766
  • 5
  • 16
1

Once upon a time I was experimenting with two different connections, one to the front and one to the back. One of them would always freeze up on me.

I used this to help get me started, https://github.com/alex-chan/AVCamSwift Maybe you can figure something out but I am not sure that it's possible.

Fred Faust
  • 6,696
  • 4
  • 32
  • 55