diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 01d27bf..69e13c6 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -776,20 +776,11 @@ } } - if (timescale == 0) { - timescale = duration.timescale; - } - CMTime currentOutputTimeStamp = CMTimeConvertScale(presentationOutputTimeStamp, duration.timescale, kCMTimeRoundingMethod_Default); int64_t delta = presentationTimeStamp.value - currentOutputTimeStamp.value; - - // Check for the initial empty edit - if (demuxHelper->currentTime == 0 && presentationOutputTimeStamp.value > 0) { - CMTime time = CMTimeConvertScale(presentationOutputTimeStamp, duration.timescale, kCMTimeRoundingMethod_Default); - [demuxHelper endEditListAtTime:time empty:YES]; - [demuxHelper startEditListAtTime:time]; - demuxHelper->currentTime += time.value; + if (timescale == 0) { + timescale = duration.timescale; } CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(NULL, sampleBuffer, kCMAttachmentMode_ShouldPropagate); @@ -823,10 +814,16 @@ if (delta != demuxHelper->delta && currentOutputTimeStamp.value > demuxHelper->currentTime) { if (![demuxHelper isEditListOpen]) { - CMTime editStart = CMTimeMake(demuxHelper->currentTime, duration.timescale); + CMTime editStart = CMTimeMake(demuxHelper->currentTime + delta, duration.timescale); [demuxHelper startEditListAtTime:editStart]; CMTime editEnd = CMTimeMake(demuxHelper->currentTime - delta, duration.timescale); [demuxHelper endEditListAtTime:editEnd empty:YES]; + demuxHelper->currentTime += delta; + } else { + CMTime editEnd = CMTimeMake(demuxHelper->currentTime + currentOutputTimeStamp.value, duration.timescale); + [demuxHelper endEditListAtTime:editEnd empty:YES]; + [demuxHelper startEditListAtTime:editEnd]; + demuxHelper->currentTime += currentOutputTimeStamp.value; } demuxHelper->delta = delta; } diff --git a/MP42/MP42Image.h b/MP42/MP42Image.h index 875ba94..7a7b3fb 100644 --- a/MP42/MP42Image.h +++ b/MP42/MP42Image.h @@ -38,4 +38,4 @@ typedef enum MP42TagArtworkType_e { @property(atomic, readonly) NSData *data; @property(atomic, readonly) NSInteger type; -@end \ No newline at end of file +@end diff --git a/MP42/MP42MediaFormat.h b/MP42/MP42MediaFormat.h index a293eec..b241a04 100644 --- a/MP42/MP42MediaFormat.h +++ b/MP42/MP42MediaFormat.h @@ -81,4 +81,4 @@ extern NSString *const MP42TimeCodeFormat; extern NSString * const SBMonoMixdown; extern NSString * const SBStereoMixdown; extern NSString * const SBDolbyMixdown; -extern NSString * const SBDolbyPlIIMixdown; \ No newline at end of file +extern NSString * const SBDolbyPlIIMixdown;