问题标签 [avcapturesession]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
4955 浏览

iphone - captureOutput:didOutputSampleBuffer:fromConnection 性能问题

AVCaptureSessionPhoto用来让用户拍摄高分辨率照片。拍照时,我使用该captureOutput:didOutputSampleBuffer:fromConnection:方法在拍摄时检索缩略图。然而,尽管我尝试在委托方法中做最少的工作,但应用程序变得有点滞后(我之所以这么说是因为它仍然可用)。此外,iPhone 往往会发热。

有什么方法可以减少 iPhone 的工作量吗?

AVCaptureVideoDataOutput通过执行以下操作来设置:

这是我的captureOutput:didOutputSampleBuffer:fromConnection(和辅助imageRefFromSampleBuffer方法):

0 投票
1 回答
1400 浏览

iphone - 接到来电时,录制的视频已损坏,并且 AVFoundation 方法出现错误

我有一个视频录制应用程序。一切正常。除非在录音时接到电话。

当接到电话时,我尝试结束录制,但是,我写给 AVAssetWriter 的任何调用都被拒绝。audioWriterInputappendSampleBuffer返回不,appendPixelBuffer错误输出。我尝试调用 avAssetWriterfinishWriting但返回AVAssetWriterStatusFailed.

没有任何效果,我的视频已损坏,因为一旦接到电话,似乎不允许我完成录制会话的常用方法。

接到电话时,我可以听什么来正确结束录音会话?我目前唯一能做的就是监听applicationWillResignActive并停止一切,但这会阻止在用户收到短信等时进行录制,这将使我的应用程序与原生相机应用程序的工作方式不同。

0 投票
1 回答
1041 浏览

iphone - 录制视频时,如何设置视频的变换(人像、风景等)?

我应该使用 AVCaptureConnection 的 videoOrientation 属性,还是设置 videoWriterInput 的 transform 属性,或者其他什么?

0 投票
1 回答
1094 浏览

iphone - UIlabel 在 AVCaptureSession Delegate 中没有得到更新

我正在学习目标 c 并做一个示例应用程序来从 iPhone 摄像头获取视频源。我能够从相机获取信息并将其显示在屏幕上。此外,我试图从委托方法内的视频中为每一帧更新屏幕中的一些 UILabel。但是标签值并不总是更新。这是我正在使用的代码

本节将初始化捕获

为每个视频帧调用此方法。

我试图在这个方法中打印 UILabel 但它并不总是打印出来。标签文本的更改有很多延迟。

有人可以帮忙吗?谢谢。

0 投票
1 回答
388 浏览

iphone - Saving file to disk while running AVCaptureVideoPreviewLayer and CMMotionManager

Good day, hope someone can help me up with this situation:

I working on an iPhone app that takes series of images, assisted by gyroscope. So both AVCamCaptureManager and CMMotionManager sessions are running at the same time.

after taking a still image, i am: - processing the image in a background thread (which works fine without affecting anything) - then saving processed image data to disk

The issue: both AVCamCaptureManager and CMMotionManager sessions freeze for less then 1/2 second, right after initiating writeToFile function.

Does anyone have any experience with such scenario? Thanks for your time! :)

0 投票
3 回答
1379 浏览

iphone - 向 AVCaptureSession 添加音频输入会停止 AVPlayer

我正在开发一个音乐应用程序,其中通过使用 AVPLayer 播放的 m4v 视频文件显示乐谱,并使用 AVCaptureSession 来预览和记录演奏者的视频和音频与乐谱一起播放。

不幸的是,虽然 AVCaptureVideoPreviewLayer 在显示乐谱的同时显示实时视频,但当我尝试向 AVCaptureSession 添加音频输入时,AVPlayer 会暂停。

我曾尝试对预览层和录音使用单独的 AVCaptureSession,但这似乎没什么区别。

我是在尝试做不可能的事情,还是有办法同时播放视频/音频和录制视频/音频。

据我所知,Skype 和 Facetime 做的事情相似(尽管不完全相同)。

0 投票
2 回答
4036 浏览

iphone - 在将它们发送到 AVAssetWriter 之前将它们保存在内存中

我需要在内存中保存一些来自 captureSession 的视频帧,并在发生“某些事情”时将它们写入文件。

此解决方案类似,我使用此代码将框架放入 NSMutableArray:

这要写入视频文件:

但是 imgBuf 参考有问题。有什么建议么?提前致谢。

0 投票
1 回答
1952 浏览

iphone - Why rotate Image in OpenCV without rotation code?

I am taking photo using AVCaptureStillImageOutput, AVCaptureSession, AVCaptureVideoPreviewLayer and display it in UIImageView. Its work properly.

But, After display image in UIImage. I am detecting faces using OpenCV from that displayed image.

It detect, but it returns the rotated image. I am not use any code for rotate the image. Its automatically rotate the image.

I want to stop rotating.

Here is my code.

Here is the Screen shots

1) Image for before calling face detection method Image before face detection method called

2) Image for after calling face detection method Image after face detection method called

0 投票
1 回答
1053 浏览

iphone - 如何获得 AVCapture 时间码?

我正在开发一个使用 AVFoundation 框架的视频捕获应用程序,基于 Apple 的AVCam示例。我想实现设置最大视频长度的功能,并在达到此限制时自动停止捕获(类似于UIImagePickerController.videoMaximumDuration)。

我假设我需要在捕获记录时注册一些通知,并检查此回调中的时间戳。我查看了 AV Foundation Programming Guide 并进行了一些谷歌搜索,但我找不到一种方法来检索 AVCaptureSession、AVCaptureMovieFileOutput 或 AVCaptureSomethingElse 的经过时间。

任何见解都会有所帮助。谢谢!

0 投票
3 回答
4344 浏览

iphone - 将照片保存到相机胶卷时,AVCaptureMovieFileOutput 导致方向错误

我对 captureStillImageAsynchronouslyFromConnection 有一个奇怪的问题。如果我在镜像视频时使用 jpegStillImageNSDataRepresentation 保存图像,则相机胶卷中的图像顺时针旋转 90 度。但是,如果没有镜像,则方向很好。我会发布代码,其他人有这个问题/知道修复吗?

更新:刚刚进行了一些测试,高度和宽度(640x480)很好,反映了设备的方向。当我在纵向拍照时,它会报告 UIImageOrientationLeft,而在镜像时,会报告 UIImageOrientationLeftMirrored。

更新 2:当我在相机胶卷中查看保存的照片时,图像的预览方向正确,在照片之间滑动时图像也是如此,但当照片完全加载时,它会旋转 90 度。这可能是相机胶卷问题吗?(我在 4.3.3)