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
+40
-14
No files matched your search
@@ -61,7 +61,9 @@
|
|||||||
|
|
||||||
- (void)analyzeSample:(MP42SampleBuffer *)sample {
|
- (void)analyzeSample:(MP42SampleBuffer *)sample {
|
||||||
if (sample->attachments) {
|
if (sample->attachments) {
|
||||||
|
#ifdef DEBUG
|
||||||
NSLog(@"Attachments found: %@", sample->attachments);
|
NSLog(@"Attachments found: %@", sample->attachments);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CFDictionaryRef trimStart = NULL, trimEnd = NULL;
|
CFDictionaryRef trimStart = NULL, trimEnd = NULL;
|
||||||
@@ -96,7 +98,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
NSLog(@"%llu, %llu, %llu, %llu", _count++, _delta, _currentTime, sample->timestamp);
|
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
|
// Setup the muxer
|
||||||
noErr = [self.muxer setup:self.fileHandle error:outError];
|
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 work];
|
||||||
self.muxer = nil;
|
self.muxer = nil;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
@protocol MP42Logging <NSObject>
|
@protocol MP42Logging <NSObject>
|
||||||
|
|
||||||
|
@required
|
||||||
- (void)writeToLog:(NSString *)string;
|
- (void)writeToLog:(NSString *)string;
|
||||||
|
@optional
|
||||||
|
- (void)writeErrorToLog:(NSError *)error;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
+33
-6
@@ -48,6 +48,7 @@
|
|||||||
{
|
{
|
||||||
BOOL noErr = YES;
|
BOOL noErr = YES;
|
||||||
_fileHandle = fileHandle;
|
_fileHandle = fileHandle;
|
||||||
|
NSMutableArray *unsupportedTracks = [[NSMutableArray alloc] init];;
|
||||||
|
|
||||||
for (MP42Track *track in _workingTracks) {
|
for (MP42Track *track in _workingTracks) {
|
||||||
MP4TrackId dstTrackId = 0;
|
MP4TrackId dstTrackId = 0;
|
||||||
@@ -58,17 +59,23 @@
|
|||||||
if (helper) {
|
if (helper) {
|
||||||
magicCookie = [helper->importer magicCookieForTrack:track];
|
magicCookie = [helper->importer magicCookieForTrack:track];
|
||||||
timeScale = [helper->importer timescaleForTrack:track];
|
timeScale = [helper->importer timescaleForTrack:track];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if([track isMemberOfClass:[MP42AudioTrack class]] && track.needConversion) {
|
if([track isMemberOfClass:[MP42AudioTrack class]] && track.needConversion) {
|
||||||
MP42AudioConverter *audioConverter = [[MP42AudioConverter alloc] initWithTrack:(MP42AudioTrack *)track
|
MP42AudioConverter *audioConverter = [[MP42AudioConverter alloc] initWithTrack:(MP42AudioTrack *)track
|
||||||
andMixdownType:[(MP42AudioTrack *)track mixdownType]
|
andMixdownType:[(MP42AudioTrack *)track mixdownType]
|
||||||
error:outError];
|
error:outError];
|
||||||
|
|
||||||
if (audioConverter == nil)
|
if (audioConverter == nil) {
|
||||||
noErr = NO;
|
noErr = NO;
|
||||||
|
if (outError && *outError) {
|
||||||
|
[_logger writeErrorToLog:*outError];
|
||||||
|
}
|
||||||
|
[unsupportedTracks addObject:track];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
helper->converter = audioConverter;
|
helper->converter = audioConverter;
|
||||||
}
|
}
|
||||||
@@ -76,8 +83,14 @@
|
|||||||
MP42BitmapSubConverter *subConverter = [[MP42BitmapSubConverter alloc] initWithTrack:(MP42SubtitleTrack *)track
|
MP42BitmapSubConverter *subConverter = [[MP42BitmapSubConverter alloc] initWithTrack:(MP42SubtitleTrack *)track
|
||||||
error:outError];
|
error:outError];
|
||||||
|
|
||||||
if (subConverter == nil)
|
if (subConverter == nil) {
|
||||||
noErr = NO;
|
noErr = NO;
|
||||||
|
if (outError && *outError) {
|
||||||
|
[_logger writeErrorToLog:*outError];
|
||||||
|
}
|
||||||
|
[unsupportedTracks addObject:track];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
helper->converter = subConverter;
|
helper->converter = subConverter;
|
||||||
}
|
}
|
||||||
@@ -345,14 +358,28 @@
|
|||||||
dstTrackId = MP4AddCCTrack(fileHandle, timeScale, videoSize.width, videoSize.height);
|
dstTrackId = MP4AddCCTrack(fileHandle, timeScale, videoSize.width, videoSize.height);
|
||||||
|
|
||||||
[helper->importer setActiveTrack:track];
|
[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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dstTrackId) {
|
||||||
MP4SetTrackDurationPerChunk(fileHandle, dstTrackId, timeScale / 8);
|
MP4SetTrackDurationPerChunk(fileHandle, dstTrackId, timeScale / 8);
|
||||||
track.Id = dstTrackId;
|
track.Id = dstTrackId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[_workingTracks removeObjectsInArray:unsupportedTracks];
|
||||||
|
[unsupportedTracks release];
|
||||||
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user