2

我正在为连接网络摄像机开发应用程序并获取流。我不知道如何将流转换为视频。我已经分析过了,然后我尝试了 FFMPEG 库。但是我没有使用 FFMPEG 获得正确的 ios 网址。你能建议实施指南吗?

现在我正在集成 ffmpeg,当我集成时打开 avformat_find_stream_info() 函数时出现错误。我使用增加或减少pFormatCtx->max_analyze_duration 的值。但对此没有解决方案。

[mjpeg @ 0x8b85000] max_analyze_duration 1000 达到 40000 [mjpeg @ 0x8b85000] 从比特率估计持续时间,这可能不准确

请帮助如何解决这个问题。

4

1 回答 1

0

查看 Apple 的“AVCam”示例。
它正是这样做的,并且有很多内联注释。

https://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html

这是一个小代码片段,它将为您指明正确的方向:

首先创建一个 AVCaptureSession...

            // Init the device inputs
AVCaptureDeviceInput *newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:nil];
AVCaptureDeviceInput *newAudioInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self audioDevice] error:nil];


// Setup the still image file output
AVCaptureStillImageOutput *newStillImageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
                                AVVideoCodecJPEG, AVVideoCodecKey,
                                nil];
[newStillImageOutput setOutputSettings:outputSettings];
[outputSettings release];


// Create session (use default AVCaptureSessionPresetHigh)
AVCaptureSession *newCaptureSession = [[AVCaptureSession alloc] init];  

创建视频文件输出

AVCaptureMovieFileOutput *aMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([aSession canAddOutput:aMovieFileOutput])
[aSession addOutput:aMovieFileOutput];

保存文件:

-(void)recorder:(AVCamRecorder *)recorder recordingDidFinishToOutputFileURL:(NSURL *)outputFileURL error:(NSError *)error
{
    if ([[self recorder] recordsAudio] && ![[self recorder] recordsVideo]) {
        // If the file was created on a device that doesn't support video recording, it can't be saved to the assets 
        // library. Instead, save it in the app's Documents directory, whence it can be copied from the device via
        // iTunes file sharing.
        [self copyFileToDocuments:outputFileURL];

        if ([[UIDevice currentDevice] isMultitaskingSupported]) {
            [[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
        }       

        if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {
            [[self delegate] captureManagerRecordingFinished:self];
        }
    }
    else {  
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeVideoAtPathToSavedPhotosAlbum:outputFileURL
                                    completionBlock:^(NSURL *assetURL, NSError *error) {
                                        if (error) {
                                            if ([[self delegate] respondsToSelector:@selector(captureManager:didFailWithError:)]) {
                                                [[self delegate] captureManager:self didFailWithError:error];
                                            }                                           
                                        }

                                        if ([[UIDevice currentDevice] isMultitaskingSupported]) {
                                            [[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
                                        }

                                        if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {
                                            [[self delegate] captureManagerRecordingFinished:self];
                                        }
                                    }];
        [library release];
    }
}
于 2013-07-06T07:55:46.403 回答