2013-07-06 2 views
2

Я разрабатываю приложение для подключения ip-камеры и получаю поток. Я не знаю, как конвертировать поток в видео. Я проанализировал, а затем я попробовал библиотеку FFMPEG. Но я не получил правильный url для ios с FFMPEG. Можете ли вы предложить руководство для реализации.Потоковое видео с ipCamera в iphone

Теперь я интегрирую ffmpeg, когда я интегрировал, я получил ошибку при открытии функции avformat_find_stream_info(). Я использовал увеличение или меньшее значение pFormatCtx-> max_analyze_duration. Но для этого нет решения.

[MJPEG @ 0x8b85000] max_analyze_duration 1000 достигается при 40000 [MJPEG @ 0x8b85000] Оценка длительности от битрейта, это может быть неточной

Pls помочь, как решить эту проблему.

ответ

0

Посмотрите на пример «AVCam» от Apple.
Он делает именно это и с большим количеством встроенных комментариев.

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]; 
    } 
} 
+2

Это касается удаленной камеры (IP-камеры?) Источника? Я думаю, это то, что искал оригинальный плакат и я. – huggie

+0

Кто-нибудь пробовал это решение? –