{"id":282771,"date":"2016-12-20T14:40:04","date_gmt":"2016-12-20T11:40:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282771"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282771","title":{"rendered":"Custom Video Recorder \u0434\u043b\u044f iOS \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1b5\/9bc\/499\/1b59bc4994c84620b2fa3bd4a6132fb7.jpg\"\/><br \/>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u041a\u0430\u043c\u0435\u0440\u0430 \u0434\u043b\u044f iPhone \/ iPad \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0443. \u0412 \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u0441\u044a\u0435\u043c\u043a\u0438 \u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 (\u0421\u0442\u0430\u0440\u0442 \/ \u0421\u0442\u043e\u043f). \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e UIImagePickerController\u2019\u0430 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f AVFoundation framework, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u043d\u043a\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043a\u0430\u043c\u0435\u0440\u044b, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438, \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e \u0444\u0430\u0439\u043b\u0430. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0440\u0430\u0437\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0438\u0434\u0435\u043e \u0432 \u0442\u043e\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043c\u043d\u0435 \u0432\u0435\u0441\u0442\u0438 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0443:   <\/p>\n<pre><code>AVCaptureSession  \/\/ \u0441\u0435\u0441\u0441\u0438\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e \u0441 \u043a\u0430\u043c\u0435\u0440\u044b<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f:  <\/p>\n<pre><code>AVCaptureVideoPreviewLayer  \/\/ \u0441\u043b\u043e\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0441 \u043a\u0430\u043c\u0435\u0440\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 AVCaptureDevice  \/\/ \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e \/ \u0430\u0443\u0434\u0438\u043e AVCaptureDeviceInput  \/\/ \u0432\u0445\u043e\u0434 \u0432\u0438\u0434\u0435\u043e \/ \u0430\u0443\u0434\u0438\u043e \u0434\u043b\u044f AVCaptureSession AVCaptureMovieFileOutput  \/\/ \u0432\u044b\u0445\u043e\u0434 AVCaptureSession \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e \u0432 \u0444\u0430\u0439\u043b<\/code><\/pre>\n<p>  \u0414\u0438\u0437\u0430\u0439\u043d \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 xib \u0444\u0430\u0439\u043b\u0435 \u0438\u043b\u0438 storyboard\u2019\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Autolayout \u0438 Constraints \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0430\u043d\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u043d\u043e\u043f\u043a\u0438 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 (\u043b\u0435\u0432\u043e\u043c\u0443 \u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u043e\u043c\u0443 \u043a\u0440\u0430\u044e). \u0423 \u043d\u0430\u0448\u0435\u0433\u043e VideoRecorderController\u2018\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:  <\/p>\n<ol>\n<li><b>\u0413\u043e\u0442\u043e\u0432 \u043a \u0441\u044a\u0435\u043c\u043a\u0435:<\/b> AVCaptureSession \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430, \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0438\u0434\u0435\u043e \u0441 \u043a\u0430\u043c\u0435\u0440\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0435 \u0438\u0434\u0435\u0442. <br \/>  \u041d\u0430 \u043d\u0438\u0436\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 Cancel \u2014 \u043e\u0442\u043c\u0435\u043d\u0430 \u0441\u044a\u0435\u043c\u043a\u0438, \u0442\u0430\u043a\u0436\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 Start \u2014 \u043d\u0430\u0447\u0430\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u043d\u043e\u043f\u043a\u0430 Use Video \u0441\u043a\u0440\u044b\u0442\u0430. <br \/>  \u041d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u2013 00:00. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Cancel \u0443 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 -(void)videoRecorderDidCancelRecordingVideo. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Start \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c.<\/li>\n<li><b>\u0418\u0434\u0435\u0442 \u0441\u044a\u0435\u043c\u043a\u0430:<\/b>AVCaptureSession \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430, \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0438\u0434\u0435\u043e \u0441 \u043a\u0430\u043c\u0435\u0440\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0435\u043e \u0432 \u0444\u0430\u0439\u043b. <br \/>  \u041d\u0430 \u043d\u0438\u0436\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043d\u043e\u043f\u043a\u0438 Start \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0430 Stop \u2014 \u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u043d\u043e\u043f\u043a\u0430 Cancel \u0441\u043a\u0440\u044b\u0442\u0430, \u043a\u043d\u043e\u043f\u043a\u0430 Use Video \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u0440\u044b\u0442\u0430. <br \/>  \u041d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u2013 00:22. <br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Stop \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c.<\/li>\n<li><b>\u0421\u044a\u0435\u043c\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430:<\/b> AVCaptureSession \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043a\u0430\u0434\u0440 \u043e\u0442\u0441\u043d\u044f\u0442\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e, \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0435\u043e \u0432 \u0444\u0430\u0439\u043b \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u041f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0430 Play Video. <br \/>  \u041d\u0430 \u043d\u0438\u0436\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043d\u043e\u043f\u043a\u0438 Cancel \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0430 Retake \u2013 \u043f\u0435\u0440\u0435\u0441\u043d\u044f\u0442\u044c \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0430 Use Video, \u043a\u043d\u043e\u043f\u043a\u0430 Start \u0441\u043a\u0440\u044b\u0442\u0430. <br \/>  \u041d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u2013 00:25.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Play Video \u043d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043e\u0442\u0441\u043d\u044f\u0442\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e AVPlayer. <br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Retake \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u0436\u0438\u043c. <br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Use Video \u0443 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 -(void)videoRecorderDidFinishRecording VideoWithOutputURL:(NSURL *)outputURL. <\/li>\n<\/ol>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b &#8212; \u044d\u043a\u0440\u0430\u043d\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<table>\n<tr>\n<td><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/728\/7da\/e72\/7287dae720ce417194a13f2a79102230.PNG\"\/><\/td>\n<td><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/046\/139\/7c7\/0461397c7e344e30a3bc0fa1b903b3c3.PNG\"\/><\/td>\n<td><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5f1\/a34\/2c3\/5f1a342c329e41f7b3c802c321d6d71f.PNG\"\/><\/td>\n<\/tr>\n<\/table>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043c\u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u043c\u0435\u043d\u044b \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0444\u0430\u0439\u043b \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 VideoRecorderController.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#import &lt;UIKit\/UIKit.h&gt; #import &lt;Foundation\/Foundation.h&gt; #import &lt;CoreMedia\/CoreMedia.h&gt; #import &lt;AVFoundation\/AVFoundation.h&gt; #import &lt;AudioToolbox\/AudioToolbox.h&gt; #import &lt;AVKit\/AVKit.h&gt;  @protocol VideoRecorderDelegate &lt;NSObject&gt; \/\/ \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 - (void)videoRecorderDidFinishRecordingVideoWithOutputPath:(NSString *)outputPath; \/\/ \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u043e\u0442\u043c\u0435\u043d\u0435 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438  - (void)videoRecorderDidCancelRecordingVideo; @end  @interface VideoRecorderController : UIViewController @property (nonatomic, retain) NSString *outputPath;\t\t\/\/ \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 @property (nonatomic, assign) id&lt;VideoRecorderDelegate&gt; delegate; @end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 VideoRecorderController.m \u044f \u0437\u0430\u0434\u0430\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435:   <\/p>\n<ul>\n<li>\u0441\u0435\u0441\u0441\u0438\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e AVCaptureSession <\/li>\n<li>\u0444\u0430\u0439\u043b \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434\u0430 AVCaptureMovieFileOutput <\/li>\n<li>\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e \u0432\u0445\u043e\u0434\u0430 AVCaptureDeviceInput <\/li>\n<li>\u0441\u043b\u043e\u0439 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 AVCaptureVideoPreviewLayer<\/li>\n<li>\u0442\u0430\u0439\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 <\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0430\u0439\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 VideoRecorderController.m &#8212; \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#import &quot;VideoRecorderController.h&quot;  #define TOTAL_RECORDING_TIME    60*20\t\/\/ \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445\t #define FRAMES_PER_SECOND       30\t\t\/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 #define FREE_DISK_SPACE_LIMIT   1024 * 1024\t\/\/ \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 (\u0431\u0430\u0439\u0442) #define MAX_VIDEO_FILE_SIZE     160 * 1024 * 1024\t\/\/ \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e\u0444\u0430\u0439\u043b\u0430 (\u0431\u0430\u0439\u0442) #define CAPTURE_SESSION_PRESET  AVCaptureSessionPreset352x288 \/\/ \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438  #define BeginVideoRecording     1117\t\/\/ \u0437\u0432\u0443\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e #define EndVideoRecording       1118\t\/\/ \u0437\u0432\u0443\u043a \u043a\u043e\u043d\u0446\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e  @interface VideoRecorderController () &lt;AVCaptureFileOutputRecordingDelegate&gt; {     BOOL WeAreRecording;\t\/\/ \u0444\u043b\u0430\u0433, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u0434\u0435\u0442 \u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0435\u043e          AVCaptureSession *CaptureSession;\t\t     AVCaptureMovieFileOutput *MovieFileOutput;\t     AVCaptureDeviceInput *VideoInputDevice;\t }  \/\/ \u042d\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 @property (retain) IBOutlet UILabel *timeLabel; \t\/\/ \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 @property (retain) IBOutlet UIButton *startButton; \t\/\/ \u043a\u043d\u043e\u043f\u043a\u0430 Start \/ Stop @property (retain) IBOutlet UIImageView *circleImage;  \/\/ \u043a\u0440\u0443\u0436\u043e\u043a \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043d\u043e\u043f\u043a\u0438 Start @property (retain) IBOutlet UIButton *cancelButton;      \/\/ \u043a\u043d\u043e\u043f\u043a\u0430 Cancel @property (retain) IBOutlet UIButton *useVideoButton; \/\/ \u043a\u043d\u043e\u043f\u043a\u0430 Use Video @property (retain) IBOutlet UIView *bottomView;\t       \/\/ \u043d\u0438\u0436\u043d\u044f\u044f \u043f\u0430\u043d\u0435\u043b\u044c @property (retain) IBOutlet UIButton *playVideoButton; \/\/ \u043a\u043d\u043e\u043f\u043a\u0430 Play Video  - (IBAction)startStopButtonPressed:(id)sender;\t \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Start \/ Stop - (IBAction)cancel:(id)sender;\t\t\t \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438  Cancel - (IBAction)useVideo:(id)sender;\t\t\t\/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438  Use Video - (IBAction)playVideo:(id)sender;\t\t\t\/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438  Play Video  @property (retain) AVCaptureVideoPreviewLayer *PreviewLayer;  \/\/ \u0442\u0430\u0439\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 @property (retain) NSTimer *videoTimer; @property (assign) NSTimeInterval elapsedTime;  @end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043c\u0435\u0442\u043e\u0434 viewDidLoad, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:  <\/p>\n<ul>\n<li>\u0437\u0430\u0434\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 outputPath \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c<\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0444\u043e\u043d UIApplicationDidEnterBackgroundNotification<\/li>\n<li>\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e AVCaptureSession <\/li>\n<li>\u043d\u0430\u0439\u0442\u0438 \u0432\u0438\u0434\u0435\u043e\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e AVCaptureDevice \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e \u0432\u0445\u043e\u0434\u0430 AVCaptureDeviceInput <\/li>\n<li>\u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e \u0432\u0445\u043e\u0434\u0430, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c<br \/>  \u043c\u0435\u0442\u043e\u0434 [CaptureSession beginConfiguration]<\/li>\n<li>\u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0435\u0441\u0441\u0438\u044e AVCaptureSession<\/li>\n<li>\u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u0438\u0434\u0435\u043e \u0432\u0445\u043e\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 [CaptureSession commitConfiguration] <\/li>\n<li>\u043d\u0430\u0439\u0442\u0438 \u0430\u0443\u0434\u0438\u043e\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e AVCaptureDevice, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0430\u0443\u0434\u0438\u043e \u0432\u0445\u043e\u0434\u0430 AVCaptureDeviceInput \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u0441\u0435\u0441\u0441\u0438\u044e AVCaptureSession<\/li>\n<li>\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043b\u043e\u0439 AVCaptureVideoPreviewLayer, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432\u0438\u0434\u0435\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u043a \u0441\u0435\u0441\u0441\u0438\u0438 AVCaptureSession, \u0440\u0430\u0441\u0442\u044f\u043d\u0443\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0439, \u043d\u0430 \u0432\u0435\u0441\u044c \u044d\u043a\u0440\u0430\u043d \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0439 (\u043a\u0440\u0430\u044f \u043a\u0430\u0434\u0440\u0430 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d)<\/li>\n<li>\u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u043b\u043e\u044f AVCaptureVideoPreviewLayer \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0439 \u043d\u0430 \u0437\u0430\u0434\u043d\u0438\u0439 \u043f\u043b\u0430\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u0435\u0440\u0445 \u043d\u0435\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0438\u0441\u044c \u0432\u0441\u0435 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438 \u043a\u043d\u043e\u043f\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/li>\n<li>\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b AVCaptureMovieFileOutput<\/li>\n<li>\u0437\u0430\u0434\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0432\u0438\u0434\u0435\u043e \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445<\/li>\n<li>\u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0432\u0438\u0434\u0435\u043e \u0432 \u0431\u0430\u0439\u0442\u0430\u0445<\/li>\n<li>\u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445<\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b \u0432 \u0441\u0435\u0441\u0441\u0438\u044e AVCaptureSession <\/li>\n<li>\u0437\u0430\u0434\u0430\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e \u0434\u043b\u044f \u0441\u0435\u0441\u0441\u0438\u0438 AVCaptureSession <\/li>\n<li>\u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434\u0430 AVCaptureMovieFileOutput \u0438 \u0441\u043b\u043e\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0432\u0438\u0434\u0435\u043e AVCaptureVideoPreviewLayer<\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0438\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u044c, \u043e\u043d\u0430 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u0438\u0442\u0441\u044f. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043c\u0435\u0442\u043e\u0434 viewWillAppear, \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e AVCaptureSession, \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432\u0438\u0434\u0435\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u044d\u0442\u043e\u0442 \u044d\u043a\u0440\u0430\u043d \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0432\u0438\u0434\u0435\u043e, \u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c AVCaptureSession \u2014 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u043d\u0435\u0442 \u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0430\u0439\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 VideoRecorderController.m &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 View Controller&#39;\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>@implementation VideoRecorderController  - (void)viewDidLoad {     [super viewDidLoad];     self.outputPath = [[NSString alloc] initWithFormat:@&quot;%@%@&quot;, NSTemporaryDirectory(), @&quot;output.mov&quot;];     [self deleteVideoFile];     [[NSNotificationCenter defaultCenter] addObserver: self                                              selector: @selector(applicationDidEnterBackground:)                                                  name: UIApplicationDidEnterBackgroundNotification                                                object: nil];     CaptureSession = [[AVCaptureSession alloc] init];     AVCaptureDevice *VideoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];     if (VideoDevice) {         NSError *error = nil;         VideoInputDevice = [AVCaptureDeviceInput deviceInputWithDevice:VideoDevice error:&error];         if (!error) {             [CaptureSession beginConfiguration];             if ([CaptureSession canAddInput:VideoInputDevice]) {                  [CaptureSession addInput:VideoInputDevice];             }             [CaptureSession commitConfiguration];         }     }     AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];     NSError *error = nil;     AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error];     if (audioInput) {         [CaptureSession addInput:audioInput];     }     [self setPreviewLayer:[[AVCaptureVideoPreviewLayer alloc] initWithSession:CaptureSession]];     [self.PreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];     [self setupLayoutInRect:[[[self view] layer] bounds]];     UIView *CameraView = [[UIView alloc] init];     [[self view] addSubview:CameraView];     [self.view sendSubviewToBack:CameraView];     [[CameraView layer] addSublayer:self.PreviewLayer];     MovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];     CMTime maxDuration = CMTimeMakeWithSeconds(TOTAL_RECORDING_TIME, FRAMES_PER_SECOND);     MovieFileOutput.maxRecordedDuration = maxDuration;     MovieFileOutput.maxRecordedFileSize = MAX_VIDEO_FILE_SIZE;     MovieFileOutput.minFreeDiskSpaceLimit = FREE_DISK_SPACE_LIMIT;     if ([CaptureSession canAddOutput:MovieFileOutput]) {         [CaptureSession addOutput:MovieFileOutput];     }     if ([CaptureSession canSetSessionPreset:CAPTURE_SESSION_PRESET]) {         [CaptureSession setSessionPreset:CAPTURE_SESSION_PRESET];     }     [self cameraSetOutputProperties]; }  - (void)applicationDidEnterBackground:(UIApplication *)application {     if (WeAreRecording) {         [self stopRecording];     } }  - (void)viewWillAppear:(BOOL)animated {     [super viewWillAppear:animated];     if (![[NSFileManager defaultManager] fileExistsAtPath:self.outputPath]) {         WeAreRecording = NO;         [CaptureSession startRunning];     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u044d\u043a\u0440\u0430\u043d\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0441\u0435\u0441\u0441\u0438\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430, \u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0435\u0449\u0435 \u043d\u0435 \u0438\u0434\u0435\u0442. \u041f\u0435\u0440\u0435\u0434 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u044d\u043a\u0440\u0430\u043d\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043d\u0430\u0434\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434\u0430 AVCaptureMovieFileOutput \u0438 \u0441\u043b\u043e\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0432\u0438\u0434\u0435\u043e AVCaptureVideoPreviewLayer.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0430\u0439\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 VideoRecorderController.m &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>- (BOOL)shouldAutorotate {     return (CaptureSession.isRunning && !WeAreRecording); }  - (UIInterfaceOrientationMask)supportedInterfaceOrientations {     return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortraitUpsideDown); }  - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id&lt;UIViewControllerTransitionCoordinator&gt;)coordinator {     [self setupLayoutInRect:CGRectMake(0, 0, size.width, size.height)];     [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];     [coordinator animateAlongsideTransition:^(id&lt;UIViewControllerTransitionCoordinatorContext&gt; context) {       } completion:^(id&lt;UIViewControllerTransitionCoordinatorContext&gt; context) {         [self cameraSetOutputProperties];     }]; }  \/\/ \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u0438 \u0441\u043b\u043e\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \/\/ \u041e\u043d \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d viewWillTransitionToSize, \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 iOS 7 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0438\u0445 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {     [self setupLayoutInRect:[[[self view] layer] bounds]];     [self cameraSetOutputProperties]; }  \/\/ \u041f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u043b\u043e\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 - (void)setupLayoutInRect:(CGRect)layoutRect {     [self.PreviewLayer setBounds:layoutRect];     [self.PreviewLayer setPosition:CGPointMake(CGRectGetMidX(layoutRect),  CGRectGetMidY(layoutRect))]; }  \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0434\u0435\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u0438 \u0441\u043b\u043e\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 - (void)cameraSetOutputProperties {     AVCaptureConnection *videoConnection = nil;     for ( AVCaptureConnection *connection in [MovieFileOutput connections] ) {         for ( AVCaptureInputPort *port in [connection inputPorts] ) {             if ( [[port mediaType] isEqual:AVMediaTypeVideo] ) {                 videoConnection = connection;             }         }     }          if ([videoConnection isVideoOrientationSupported]) {         if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {             self.PreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortrait;             [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];         }         else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) {             self.PreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;             [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortraitUpsideDown];         }         else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {             self.PreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;             [videoConnection setVideoOrientation:AVCaptureVideoOrientationLandscapeLeft];         }         else {             self.PreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;             [videoConnection setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 Start \/ Stop \u043d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0435\u0449\u0435 \u043d\u0435 \u0438\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u0436\u0435 \u0438\u0434\u0435\u0442, \u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0435\u043d\u0430. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 Cancel \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 videoRecorderDidCancelRecordingVideo. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 Retake \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0439\u043c\u0435\u0440, \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0430 Use Video, \u0437\u0430\u043d\u043e\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0441\u0441\u0438\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 Use Video \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 videoRecorderDidFinishRecordingVideoWithOutputPath, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0432\u0438\u0434\u0435\u043e \u0444\u0430\u0439\u043b\u0443. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 Play Video \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437 \u043e\u0442\u0441\u043d\u044f\u0442\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f AVPlayer. \u041a\u043e\u0433\u0434\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u0439\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438. \u041c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0434\u0435\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u0434\u043e\u0441\u0442\u0438\u0433 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e. \u0412 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0430\u0439\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 VideoRecorderController.m &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043a\u043d\u043e\u043f\u043e\u043a, \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 AVCaptureFileOutputRecordingDelegate<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>- (IBAction)startStopButtonPressed:(id)sender {     if (!WeAreRecording) {         [self startRecording];     }     else {         [self stopRecording];     } }   - (IBAction)cancel:(id)sender {     if ([CaptureSession isRunning]) {         if (self.delegate) {             [self.delegate videoRecorderDidCancelRecordingVideo];         }     }     else {         self.circleImage.hidden = NO;         self.startButton.hidden = NO;         self.useVideoButton.hidden = YES;         [self.cancelButton setTitle:@&quot;Cancel&quot; forState:UIControlStateNormal];         self.timeLabel.text = @&quot;00:00&quot;;         self.elapsedTime = 0;         [CaptureSession startRunning];     } }  - (IBAction)useVideo:(id)sender {     if (self.delegate) {         [self.delegate videoRecorderDidFinishRecordingVideoWithOutputPath:self.outputPath];     } }  - (IBAction)playVideo:(id)sender {     if ([[NSFileManager defaultManager] fileExistsAtPath:self.outputPath]) {         NSURL *outputFileURL = [[NSURL alloc] initFileURLWithPath:self.outputPath];         AVPlayer *player = [AVPlayer playerWithURL:outputFileURL];         AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];         [self presentViewController:controller animated:YES completion:nil];         controller.player = player;         controller.allowsPictureInPicturePlayback = NO;         [player play];     } }  \/\/ \u042d\u0442\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e - (void)startRecording {     \/\/ \u041f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c \u0437\u0432\u0443\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e     AudioServicesPlaySystemSound(BeginVideoRecording);     WeAreRecording = YES;     [self.cancelButton setHidden:YES];     [self.bottomView setHidden:YES];     [self.startButton setImage:[UIImage imageNamed:@&quot;StopVideo&quot;] forState:UIControlStateNormal];     self.timeLabel.text = @&quot;00:00&quot;;     self.elapsedTime = 0;     self.videoTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTime) userInfo:nil repeats:YES];          \/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u043d\u043e\u0432\u043e\u0439     [self deleteVideoFile];          \/\/ \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438     NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:self.outputPath];     [MovieFileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self]; }  - (void)deleteVideoFile {     NSFileManager *fileManager = [NSFileManager defaultManager];     if ([fileManager fileExistsAtPath:self.outputPath]) {         NSError *error = nil;         if ([fileManager removeItemAtPath:self.outputPath error:&error] == NO) {             \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0448\u0438\u0431\u043a\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430         }     } }  \/\/ \u042d\u0442\u043e \u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e - (void)stopRecording {     \/\/ \u041f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c \u0437\u0432\u0443\u043a \u043a\u043e\u043d\u0446\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e     AudioServicesPlaySystemSound(EndVideoRecording);     WeAreRecording = NO;     [CaptureSession stopRunning];     self.circleImage.hidden = YES;     self.startButton.hidden = YES;     [self.cancelButton setTitle:@&quot;Retake&quot; forState:UIControlStateNormal];     [self.cancelButton setHidden:NO];     [self.bottomView setHidden:NO];     [self.startButton setImage:[UIImage imageNamed:@&quot;StartVideo&quot;] forState:UIControlStateNormal];     \/\/ \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438     [self.videoTimer invalidate];     self.videoTimer = nil;          \/\/ \u0417\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438     [MovieFileOutput stopRecording]; }  - (void)updateTime {     self.elapsedTime += self.videoTimer.timeInterval;     NSInteger seconds = (NSInteger)self.elapsedTime % 60;     NSInteger minutes = ((NSInteger)self.elapsedTime \/ 60) % 60;     self.timeLabel.text = [NSString stringWithFormat:@&quot;%02ld:%02ld&quot;, (long)minutes, (long)seconds]; }  - (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL       fromConnections:(NSArray *)connections                 error:(NSError *)error {     if (WeAreRecording) {         [self stopRecording];     }          BOOL RecordedSuccessfully = YES;     if ([error code] != noErr) {         \/\/ \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043d\u043e \u0444\u0430\u0439\u043b \u0431\u044b\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d,         \/\/ \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e         id value = [[error userInfo] objectForKey:AVErrorRecordingSuccessfullyFinishedKey];         if (value != nil) {             RecordedSuccessfully = [value boolValue];         }     }     if (RecordedSuccessfully) {         \/\/ \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0430 Use Video         self.useVideoButton.hidden = NO;     } }  - (void)viewDidUnload {     [super viewDidUnload];     CaptureSession = nil;     MovieFileOutput = nil;     VideoInputDevice = nil; } @end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>   <a href=\"https:\/\/github.com\/ValentinStrazdin\/VideoRecorder\">\u0417\u0434\u0435\u0441\u044c<\/a> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<br \/>  \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438:  <\/p>\n<ul>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/uikit\/uiimagepickercontroller\">UIImagePickerController<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\">AVFoundation<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avcapturesession\">AVCaptureSession<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avcapturedevice\">AVCaptureDevice<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avcapturedeviceinput\">AVCaptureDeviceInput<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avcapturemoviefileoutput\">AVCaptureMovieFileOutput<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avcapturevideopreviewlayer\">AVCaptureVideoPreviewLayer<\/a><\/li>\n<li> <a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avcapturesession\/1669314-video_input_presets\">\u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a Video Input Presets<\/a><\/li>\n<\/ul>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/316862\/\"> https:\/\/habrahabr.ru\/post\/316862\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1b5\/9bc\/499\/1b59bc4994c84620b2fa3bd4a6132fb7.jpg\"\/><br \/>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u041a\u0430\u043c\u0435\u0440\u0430 \u0434\u043b\u044f iPhone \/ iPad \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0443. \u0412 \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u0438\u0434\u0435\u043e\u0441\u044a\u0435\u043c\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u0441\u044a\u0435\u043c\u043a\u0438 \u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 (\u0421\u0442\u0430\u0440\u0442 \/ \u0421\u0442\u043e\u043f). \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e UIImagePickerController\u2019\u0430 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f AVFoundation framework, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u043d\u043a\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043a\u0430\u043c\u0435\u0440\u044b, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u0435\u043e, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438, \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e \u0444\u0430\u0439\u043b\u0430. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0440\u0430\u0437\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0438\u0434\u0435\u043e \u0432 \u0442\u043e\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-282771","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=282771"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282771\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}