使用AVFoundation框架工作捕获视频.借助Apple文档http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/03_MediaCapture.html%23//apple_ref/doc/ UID/TP40010188-CH5-SW2
现在我做了以下事情
1.Created videoCaptureDevice
2.Created AVCaptureDeviceInput并设置videoCaptureDevice
3.Created AVCaptureVideoDataOutput和实现代表
4.Created AVCaptureSession-设定输入作为AVCaptureDeviceInput并设置输出作为AVCaptureVideoDataOutput
5.在AVCaptureVideoDataOutput委托方法中
-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
Run Code Online (Sandbox Code Playgroud)
我有CMSamplebuffer并转换成UIImage并测试使用打印UIImageview
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES];
Run Code Online (Sandbox Code Playgroud)
每件事情都很顺利........
我的问题是,我需要通过UDP套接字发送视频帧.尽管下面的一个是我试过的坏主意,UIImage到NSData和通过UDP Pocket发送.BUt得到了如此延迟的视频处理.由于UIImage NSDate导致了很多问题
所以请给我解决方案我的问题
1)任何方法将CMSampleBUffer或CVImageBuffer转换为NSData ??
2)像音频队列服务和视频队列存储UIImage和UIImage到NSDate和发送???
如果我骑在错误的算法背后请在写方向路径我
提前致谢
美好的一天,
我的应用是一个音乐播放应用程序.我<audio>用Javascript 控制-Tag.到目前为止没有任何问题,播放,暂停,下一个和上一个按钮正在工作.当我在iOS 5中待机时,音乐会继续播放,但自动下一首歌不起作用.当它不处于待机状态时,它可以工作.在iOS 6中,只需按下按钮,音乐就会淡出.
锁定屏幕上的播放/暂停按钮适用于iOS 5,但不适用于iOS 6.
我的故事板中有一个带有几个UIButton的视图控制器.其中一个激活子图层中显示的AVFoundation相机预览图层:
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.view.bounds;
[self.view.layer addSublayer:captureVideoPreviewLayer];
Run Code Online (Sandbox Code Playgroud)
这是正常工作,除了预览图层呈现在我的按钮之上,因此即使按钮仍然可点击,用户也无法看到它们.有没有一种简单的方法将子图层放在按钮下面?或者在图层中提升按钮的简单方法?非常感谢!
根本问题
在iOS中搜索时,我们的视频会缓冲很多.它比我们的网络播放器缓冲得更多,它可以在临时存储中保存已经观看的片段的副本.
期望的解决方案
在设备的磁盘上本地缓存视频片段.我们很好地缓存单一质量并且总是重播它.
拦截器
我们找不到在AVFoundation/AVPlayer中执行缓存的方法.
我们尝试过什么
使用AVPlayer拦截网络请求的两种方法.
不适用于HLS.您可以通过实现AVAssetResourceLoaderDelegate来加载m3u8文件,它允许您通过身份验证或解密响应,但无法加载.ts文件.这是我们尝试的代码:https: //gist.github.com/nathanhillyer/84e46152d7c4c88183b6
.ts文件请求.AVURLAsset实际上避免被截获.不知何故,网络请求只是没有被捕获.(不知道为什么)
avfoundation video-streaming http-live-streaming ios avplayer
我尝试了以下两种方法来附加UIImages pixelbuffer ASSETWriterInput.除了视频文件中没有数据外,一切看起来都不错.怎么了?
AVAssetWriterInputPixelBufferAdaptor * avAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:NULL];
[avAdaptor appendPixelBufferixelBuffer withPresentationTime:CMTimeMake(1, 10)];
Run Code Online (Sandbox Code Playgroud)
// Create sample buffer.
CMSampleBufferRef sampleBuffer = NULL;
result = CMSampleBufferCreateForImageBuffer(kCFAllocatorDef ault, pixelBuffer, true, NULL, NULL, videoInfo, &timing, &sampleBuffer);
// Ship out the frame.
NSParameterAssert(CMSampleBufferDataIsReady(sample Buffer));
NSParameterAssert([writerInput isReadyForMoreMediaData]);
BOOL success = [writerInput appendSampleBuffer:sampleBuffer];
Run Code Online (Sandbox Code Playgroud) 我正在使用Apple提供的AVCam代码从iPhone相机录制视频.
录制视频后,会将其保存到照片库中.
然后加载一个新视图,这里我需要有一个视频的图像缩略图.
我有一条视频路径:
file://localhost/private/var/mobile/Applications/ED45DEFC-ABF9-4A5E-9102-21680CC1448E/tmp/output.mov
Run Code Online (Sandbox Code Playgroud)
我似乎无法想象如何将视频的第一帧用作缩略图.
任何帮助将非常感谢,谢谢你的时间.
编辑
我最终使用了这个,我不确定为什么它将图像侧面返回?
- (UIImage*)loadImage {
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:vidURL options:nil];
AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
NSError *err = NULL;
CMTime time = CMTimeMake(1, 60);
CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
NSLog(@"err==%@, imageRef==%@", err, imgRef);
return [[UIImage alloc] initWithCGImage:imgRef];
}
Run Code Online (Sandbox Code Playgroud) 我正在使用iOS AVFoundation框架,我能够成功合并视频轨道,图像叠加和文本叠加.但是,我的输出文件不会保留原始源视频中的音频.
如何确保我的某个视频的音频源与我创建的新视频保持一致?
*使用此代码可以很好地说明如何创建视频(使用原始音频).在使用AVFoundation处理视频时,我需要单独包含音频轨道,这一点并不明显.希望这有助于其他人.
AVAssetTrack *videoTrack = nil;
AVAssetTrack *audioTrack = nil;
CMTime insertionPoint = kCMTimeZero;
if([[url tracksWithMediaType:AVMediaTypeVideo] count] != 0) {
videoTrack = [url tracksWithMediaType:AVMediaTypeVideo][0];
}
if([[url tracksWithMediaType:AVMediaTypeAudio] count] != 0) {
audioTrack = [url tracksWithMediaType:AVMediaTypeAudio][0];
}
// Insert the video and audio tracks from AVAsset
if (videoTrack != nil) {
AVMutableCompositionTrack *compositionVideoTrack = [videoComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [url duration]) ofTrack:videoTrack atTime:insertionPoint error:&error];
}
if (audioTrack != nil) {
AVMutableCompositionTrack *compositionAudioTrack = [videoComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, …Run Code Online (Sandbox Code Playgroud) 我使用AVAudioPlayer播放10秒的wav文件,它工作正常.现在我在第4秒停止wav然后从第1秒再次播放.
这是我试过的代码:
NSString *ahhhPath = [[NSBundle mainBundle] pathForResource:@"Ahhh" ofType:@"wav"];
AVAudioPlayer *ahhhhhSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:ahhhPath] error:NULL];
[ahhhhhSound stop];
[ahhhhhSound play];
Run Code Online (Sandbox Code Playgroud)
我得到的是,wav在第4秒停止但是当我再次运行[XXX play]时,wav继续播放第5秒而不是从头开始播放.
我怎么能这样做?任何帮助将不胜感激.
我正在寻找如何绘制声音幅度.
我找到了http://supermegaultragroovy.com/2009/10/06/drawing-waveforms/但我遇到了一些问题.如何获取表示音频的浮点值列表?
我正在尝试创建一个相机应用程序,它或多或少会像默认的相机应用程序.目前对我不起作用的东西是重点关注.我希望相机能够对焦并在触摸点上做任何事情,就像真正的相机应用程序一样.
这是我的viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
// Session
_session = [[AVCaptureSession alloc] init];
_session.sessionPreset = AVCaptureSessionPresetPhoto;
// Input
_videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
_videoInput = [AVCaptureDeviceInput deviceInputWithDevice:_videoDevice error:nil];
// Output
_frameOutput = [[AVCaptureVideoDataOutput alloc] init];
_frameOutput.videoSettings = [NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey];
[_frameOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
[_session addInput:_videoInput];
[_session addOutput:_frameOutput];
[_session startRunning];
};
Run Code Online (Sandbox Code Playgroud)
这里的方法应该让我的相机专注于点击.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[touches enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
UITouch *touch = obj;
CGPoint touchPoint = [touch locationInView:touch.view];
focusLayer.frame = CGRectMake((touchPoint.x-25), (touchPoint.y-25), 50, 50);
if ([_videoDevice isFocusPointOfInterestSupported]) …Run Code Online (Sandbox Code Playgroud) avfoundation ×10
ios ×8
video ×3
cocoa-touch ×2
audio ×1
avplayer ×1
calayer ×1
camera ×1
core-video ×1
export ×1
html5-audio ×1
image ×1
ios6 ×1
iphone ×1
objective-c ×1
uibutton ×1
uiwebview ×1
xcode ×1