I am trying to create a properly formatted video file for use in Apple HTTP Live Streaming. Here is the code that creates the file:
AVCaptureDeviceInput *newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:nil];
AVCaptureDeviceInput *newAudioInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self audioDevice] error:nil];
AVCaptureSession *newCaptureSession = [[AVCaptureSession alloc] init];
newCaptureSession.sessionPreset = AVCaptureSessionPresetMedium;
self.session = newCaptureSession;
if ([newCaptureSession canAddInput:newVideoInput]) {
[newCaptureSession addInput:newVideoInput];
}
if ([newCaptureSession canAddInput:newAudioInput]) {
[newCaptureSession addInput:newAudioInput];
}
AVCaptureMovieFileOutput *aMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([self.session canAddOutput:aMovieFileOutput])
[self.session addOutput:aMovieFileOutput];
aMovieFileOutput.maxRecordedDuration = CMTimeMakeWithSeconds(10.f, 1);
AVCaptureConnection *videoConnection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
if ([videoConnection isVideoOrientationSupported])
[videoConnection setVideoOrientation:[self calculateVideoOrientation]];
[aMovieFileOutput startRecordingToOutputFileURL:[self nextOutputURL] recordingDelegate:self];
[self nextOutputURL]returns valid NSURL, the file is successfully saved to disk, and I can open and view the file in VLC and QuickTime. The video format in VLC is "avc1", which I find the same as H.264 . The QuickTime video format is H.264. The file extension is, of course, .ts.
It seems that I am doing everything right, but when I try to check my HTTP stream with mediastreamvalidator, I get the following error:
http:
ERROR: (-12971) failed to parse segment as either an MPEG-2 TS or an ES
Does anyone know what I can do wrong?
kubi source
share