카메라를 240FPS로 녹화하도록 설정하는 데 문제가있는 것 같지만 어떤 이유로 출력 파일이 30FPS에 불과합니다. 의 ViewController에 AVCameraFileOutput을 설정, 마지막으로AVFileCaptureOutput : 240fps로 녹화하지 않습니다.
class HFRCamera {
public:
HFRCamera();
AVCaptureDeviceInput *camera;
AVCaptureDeviceInput *microphone;
AVCaptureDevice *videoCam;
AVCaptureDevice *audioInput;
AVCaptureSession *capSession;
void start();
void config();
void stop();
};
HFRCamera::HFRCamera() {
// Set up capture session and add video camera and microphone
this->capSession = [[AVCaptureSession alloc] init];
this->videoCam = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
this->config();
}
void HFRCamera::start() {
[this->capSession startRunning];
}
void HFRCamera::stop() {
[this->capSession stopRunning];
}
void HFRCamera::config() {
const CGFloat desiredFPS = 240;
AVCaptureDeviceFormat *selectedFormat = nil;
AVFrameRateRange *frameRateRange = nil;
int32_t maxWidth = 0;
for (AVCaptureDeviceFormat *format in [this->videoCam formats]) {
for (AVFrameRateRange *range in format.videoSupportedFrameRateRanges) {
CMFormatDescriptionRef desc = format.formatDescription;
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(desc);
int32_t width = dimensions.width;
if (range.minFrameRate <= desiredFPS && desiredFPS <= range.maxFrameRate && width >= maxWidth) {
selectedFormat = format;
frameRateRange = range;
maxWidth = width;
}
}
}
if ([videoCam lockForConfiguration:nil]) {
std::cout << "HERE\n";
NSLog(@"selected format:%@", selectedFormat);
this->videoCam.activeFormat = selectedFormat;
this->videoCam.activeVideoMinFrameDuration = CMTimeMake(1, (int32_t)desiredFPS);
this->videoCam.activeVideoMaxFrameDuration = CMTimeMake(1, (int32_t)desiredFPS);
[this->videoCam unlockForConfiguration];
NSLog(@"%s AVCaptureDevice: %@", __PRETTY_FUNCTION__, selectedFormat);
}
if (this->videoCam) {
NSError *err;
this->camera = [AVCaptureDeviceInput deviceInputWithDevice:this->videoCam error:&err];
if (!err) {
if ([this->capSession canAddInput:this->camera])
[this->capSession addInput:this->camera];
else
NSLog(@"Could not add video input.");
} else
NSLog(@"Could not create video input");
} else {
NSLog(@"Could not create video capture device.");
}
this->audioInput = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
NSError *err = nil;
this->microphone = [AVCaptureDeviceInput deviceInputWithDevice:this->audioInput error:&err];
if (this->microphone)
[this->capSession addInput:this->microphone];
// Configure camera
[this->capSession setSessionPreset:AVCaptureSessionPresetHigh];
}
을 그리고 : 어디에서 잘못 가고
// Configure the movie file output
self.movieFile = [[AVCaptureMovieFileOutput alloc] init];
self.movieFile.minFreeDiskSpaceLimit = 1024 * 1024;
CMTime maxDuration = CMTimeMakeWithSeconds(60*60, 240); // 1 hour at 240 fps should be more than enough
self.movieFile.maxRecordedDuration = maxDuration;
if ([self.camera.capSession canAddOutput:self.movieFile])
[self.camera.capSession addOutput:self.movieFile];
여기
카메라를 설정하는 내 코드 (이 먼저 인스턴스화)입니까?EDIT : 결과 파일에서 ffprobe의 출력입니다.
Stream #0:0(und): Video: h264 (High) (avc1/0x31637661), yuv420p(tv, bt709), 1920x1080, 15166 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
그러나 아직이는 activeFormat 가정으로 무엇이다 : 세션 사전 설정 및 장치 형식 :
AVCaptureDevice: <AVCaptureDeviceFormat: 0x17401f780 'vide'/'420f' 1280x 720, { 6-240 fps}, fov:59.680, binned, supports vis, max zoom:65.50 (upscales @1.45), AF System:1, ISO:22.0-704.0, SS:0.000002-0.166667, supports wide color>
감사합니다. setSessionPreset 호출을 주석 처리했지만 여전히 30FPS의 파일 출력을 얻었습니다. 출력 형식에 대한 귀하의 의견은 240FPS라면 내 목적에 상관 없습니다. – NOP