簡體   English   中英

在iPhone中使用ipCamera進行視頻流傳輸

[英]Video streaming with ipCamera in iphone

我正在開發用於連接網絡攝像機的應用程序並獲取流。 我不知道如何將流轉換為視頻。 經過分析,然后嘗試了FFMPEG庫。 但是我沒有使用FFMPEG為ios獲取正確的URL。 您能提出實施指南嗎?

現在我正在集成ffmpeg,當我集成時,打開avformat_find_stream_info()函數時出現錯誤。 我使用增加或減少pFormatCtx-> max_analyze_duration的值。 但是對此沒有解決方案。

[mjpeg @ 0x8b85000] max_analyze_duration 1000在40000達到[mjpeg @ 0x8b85000]根據比特率估算持續時間,這可能不准確

請幫助解決此問題。

看一下蘋果公司的“ 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];
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM