iPhone5sã ãã®ã¹ãã·ã£ã«ãªæ©è½ã¨ãã¦ãç§é120ã³ãã§ã®é«éæ®å½± ããããæ¨æºã«ã¡ã©ã¢ããªã§ã¯ãããå©ç¨ãã ã¹ãã¼ã¢ã¼ã·ã§ã³åç»æ®å½±æ©è½ ãå¯è½ã¨ãªã£ã¦ãã¾ãã
ããã«é¡ããæ©è½ãAVFoundationã§å®è£
ã§ããªãããã£ã¦ã¿ãã¨ããããã¾ããã£ãã®ã§ããã®æ¹æ³ãç´¹ä»ãã¾ãã
ã§ãããã®
ãµã³ãã«ã¢ããªãGitHubã«ã¢ãããã¦ããã¾ãã
- GitHub - shu223/SlowMotionVideoRecorder: 120/240 fps SLO-MO video recorder using AVFoundation. Including convenient wrapper class.
ã¹ã¯ã·ã§ä¸é¨ã«ããããã«ã ããã©ã«ã / 60fps / 120fps ãåãæ¿ããããããã«ãªã£ã¦ãã¾ãã
ãã®ã¢ããªã使ã£ã¦æ®ã£ããã®ããã¡ã *1ã
120fps Slow-Motion video recorded using AVFoundation.
ï¼ä¸ç¤ãã¹ãã¼ã¢ã¼ã·ã§ã³ã«ãã¦ãã¾ã *2ãï¼
å®è£ æ¹æ³
ããã¨è¤éãªå¦çã«ãªã£ãã®ã§ãAVFoundationé¢é£ã®å¦çãå ¨é¨ã©ããããã¯ã©ã¹ãã¤ããã¾ããã
ãã®ã©ããã¼ã¯ã©ã¹ãAVCaptureManagerãã使ãã¨ãä¸è¨ã®ããã«3è¡ã§å®è£ ã§ãã¾ãã
1. åæå
self.captureManager = [[AVCaptureManager alloc] initWithPreviewView:self.view];
2. é²ç»éå§
[self.captureManager startRecording];
3. é²ç»åæ¢
[self.captureManager stopRecording];
åæ¢ããã¨ãã«æ®å½±ããåç»ãä¿åãããã¨ãã¯ããªã²ã¼ãã¡ã½ããã使ç¨ãã¾ãããã®ãããã¯ãµã³ãã«ããåç
§ãã ããã
ã¾ãä»ã¯ãã®ãµã³ãã«ã®ç¨éããèæ
®ããã¦ãªãAPIã«ãªã£ã¦ããã®ã§ãããこれから動画処理とかは積極的にやっていくã®ã§ãéææ¡å¼µãã¦ããæåã§ãã
ã©ããã¼ã使ããªãå®è£
大é¨åã¯AVCaptureãã§åç»æ®å½±ããå ´åã®ä¸è¬çãªå¦çã§ã120fpså®è£ ãªãã§ã¯ã®ãã¤ã³ã㯠AVCaptureManager ã®æ¬¡ã®é¨åã«éç´ããã¦ãã¾ãã
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; AVCaptureDeviceFormat *selectedFormat = nil; int32_t maxWidth = 0; AVFrameRateRange *frameRateRange = nil; for (AVCaptureDeviceFormat *format in [videoDevice 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 (selectedFormat) { if ([videoDevice lockForConfiguration:nil]) { NSLog(@"selected format:%@", selectedFormat); videoDevice.activeFormat = selectedFormat; videoDevice.activeVideoMinFrameDuration = CMTimeMake(1, (int32_t)desiredFPS); videoDevice.activeVideoMaxFrameDuration = CMTimeMake(1, (int32_t)desiredFPS); [videoDevice unlockForConfiguration]; } }
å¦çã®å
容ã¨ãã¦ã¯ã
- AVCaptureDevice ã® formats ããããã£ãã使ç¨å¯è½ãªãã©ã¼ãããã®ãªã¹ããåå¾
- ãã®ä¸ããææã®fpsãæºãããã®ãæ¢ç´¢
- åãfpsãªãå¹ ããã大ããæ¹ãã¨ã
- è¦ã¤ããã° AVCaptureDevice ã® activeFormat ããããã£ã«ã»ãããã
ã¨ãããã¨ãè¡ã£ã¦ãã¾ãã
Special Thanks!!
@hkato193 ããã«Twitterã§è«¸ã æãã¦ããã ãã¾ããããããã¨ããããã¾ããï¼
ã¤ã³ãã¬ã¹ã¸ã£ãã³
売ãä¸ãã©ã³ãã³ã°: 2,641
é¢é£
- http://d.hatena.ne.jp/shu223/20121125/1353877706
- http://d.hatena.ne.jp/shu223/20121202/1354436478
- http://d.hatena.ne.jp/shu223/20121001/1354384097
- http://d.hatena.ne.jp/shu223/20121203/1356509154
- http://d.hatena.ne.jp/shu223/20130221/1361394373
- http://d.hatena.ne.jp/shu223/20131213/1386908558
AVFoundationã使ãã¬ã·ãã¯ãä¸è¨æ¸ç±ã«ãããã¤ãæ¸ããã®ã§ãããããããã°ã
http://d.hatena.ne.jp/shu223/20130528/1369714635