Fixed a hang that happened when trying to mux an unsupported track, and added better error reporting. Disabled some log messages.
This commit is contained in:
1 parent
3ed5ca860a
commit
c6b60dbd42
4 files changed
+42
-16
No files matched your search
@@ -61,7 +61,9 @@
|
||||
|
||||
- (void)analyzeSample:(MP42SampleBuffer *)sample {
|
||||
if (sample->attachments) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"Attachments found: %@", sample->attachments);
|
||||
#endif
|
||||
}
|
||||
|
||||
CFDictionaryRef trimStart = NULL, trimEnd = NULL;
|
||||
@@ -96,7 +98,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%llu, %llu, %llu, %llu", _count++, _delta, _currentTime, sample->timestamp);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -777,14 +777,6 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
||||
|
||||
// Setup the muxer
|
||||
noErr = [self.muxer setup:self.fileHandle error:outError];
|
||||
|
||||
if (!noErr) {
|
||||
self.muxer = nil;
|
||||
[self stopWriting];
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Start the muxer and wait
|
||||
[self.muxer work];
|
||||
self.muxer = nil;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
@protocol MP42Logging <NSObject>
|
||||
|
||||
@required
|
||||
- (void)writeToLog:(NSString *)string;
|
||||
@optional
|
||||
- (void)writeErrorToLog:(NSError *)error;
|
||||
|
||||
@end
|
||||
+35
-8
@@ -48,6 +48,7 @@
|
||||
{
|
||||
BOOL noErr = YES;
|
||||
_fileHandle = fileHandle;
|
||||
NSMutableArray *unsupportedTracks = [[NSMutableArray alloc] init];;
|
||||
|
||||
for (MP42Track *track in _workingTracks) {
|
||||
MP4TrackId dstTrackId = 0;
|
||||
@@ -58,17 +59,23 @@
|
||||
if (helper) {
|
||||
magicCookie = [helper->importer magicCookieForTrack:track];
|
||||
timeScale = [helper->importer timescaleForTrack:track];
|
||||
}
|
||||
else
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if([track isMemberOfClass:[MP42AudioTrack class]] && track.needConversion) {
|
||||
MP42AudioConverter *audioConverter = [[MP42AudioConverter alloc] initWithTrack:(MP42AudioTrack *)track
|
||||
andMixdownType:[(MP42AudioTrack *)track mixdownType]
|
||||
error:outError];
|
||||
|
||||
if (audioConverter == nil)
|
||||
if (audioConverter == nil) {
|
||||
noErr = NO;
|
||||
if (outError && *outError) {
|
||||
[_logger writeErrorToLog:*outError];
|
||||
}
|
||||
[unsupportedTracks addObject:track];
|
||||
continue;
|
||||
}
|
||||
|
||||
helper->converter = audioConverter;
|
||||
}
|
||||
@@ -76,8 +83,14 @@
|
||||
MP42BitmapSubConverter *subConverter = [[MP42BitmapSubConverter alloc] initWithTrack:(MP42SubtitleTrack *)track
|
||||
error:outError];
|
||||
|
||||
if (subConverter == nil)
|
||||
if (subConverter == nil) {
|
||||
noErr = NO;
|
||||
if (outError && *outError) {
|
||||
[_logger writeErrorToLog:*outError];
|
||||
}
|
||||
[unsupportedTracks addObject:track];
|
||||
continue;
|
||||
}
|
||||
|
||||
helper->converter = subConverter;
|
||||
}
|
||||
@@ -345,15 +358,29 @@
|
||||
dstTrackId = MP4AddCCTrack(fileHandle, timeScale, videoSize.width, videoSize.height);
|
||||
|
||||
[helper->importer setActiveTrack:track];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// We don't know how to handle this type of track.
|
||||
// Alert the user.
|
||||
NSError *error = MP42Error(@"Unsupported track",
|
||||
[NSString stringWithFormat:@"%@, %@, has not been muxed.", track.name, track.format],
|
||||
140);
|
||||
|
||||
[_logger writeErrorToLog:error];
|
||||
if (outError) { *outError = error; }
|
||||
[unsupportedTracks addObject:track];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
MP4SetTrackDurationPerChunk(fileHandle, dstTrackId, timeScale / 8);
|
||||
track.Id = dstTrackId;
|
||||
if (dstTrackId) {
|
||||
MP4SetTrackDurationPerChunk(fileHandle, dstTrackId, timeScale / 8);
|
||||
track.Id = dstTrackId;
|
||||
}
|
||||
}
|
||||
|
||||
[_workingTracks removeObjectsInArray:unsupportedTracks];
|
||||
[unsupportedTracks release];
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user