Apple의 HTTP 실시간 스트리밍에서 사용할 올바른 형식의 비디오 파일을 만들려고합니다. 여기에 파일을 생성하는 코드입니다 :AVFoundation을 사용하여 MPEG-2 전송 스트림 만들기
// Init the device inputs
AVCaptureDeviceInput *newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:nil];
AVCaptureDeviceInput *newAudioInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self audioDevice] error:nil];
// Create session
AVCaptureSession *newCaptureSession = [[AVCaptureSession alloc] init];
newCaptureSession.sessionPreset = AVCaptureSessionPresetMedium;
self.session = newCaptureSession;
// Add inputs and output to the capture session
if ([newCaptureSession canAddInput:newVideoInput]) {
[newCaptureSession addInput:newVideoInput];
}
if ([newCaptureSession canAddInput:newAudioInput]) {
[newCaptureSession addInput:newAudioInput];
}
// Setup the output
AVCaptureMovieFileOutput *aMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([self.session canAddOutput:aMovieFileOutput])
[self.session addOutput:aMovieFileOutput];
aMovieFileOutput.maxRecordedDuration = CMTimeMakeWithSeconds(10.f, 1);
// Begin recording
AVCaptureConnection *videoConnection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
if ([videoConnection isVideoOrientationSupported])
[videoConnection setVideoOrientation:[self calculateVideoOrientation]];
[aMovieFileOutput startRecordingToOutputFileURL:[self nextOutputURL] recordingDelegate:self];
[self nextOutputURL]
반환하는 유효한 NSURL
이 파일이 성공적으로 디스크에 저장되고 나는 열고 VLC 및 QuickTime에서 파일을 볼 수 있습니다. VLC에서 보았을 때의 비디오 포맷은 'avc1'이고, 나는 the same as H.264입니다. QuickTime에서 보았던 비디오 포맷은 H.264입니다. 파일의 확장자는 물론 .ts입니다.
내가 제대로 최선을 다하고있어 나타납니다, 아직 내가 시도하고 mediastreamvalidator
내 HTTP 라이브 스트림을 검증 할 때, 나는 다음과 같은 오류 얻을 : 내가 잘못
http://imac.local.:2020/fileSequence000.ts:
ERROR: (-12971) failed to parse segment as either an MPEG-2 TS or an ES
누구나 알고있는 일을 할 수있다?