Fix an error when reconstructing and edit, trimAtEnd should be always the last sample attachment.
This commit is contained in:
1 file changed
+11
-6
+11
-6
@@ -912,7 +912,7 @@
|
|||||||
for (MP42Track *track in self.inputTracks) {
|
for (MP42Track *track in self.inputTracks) {
|
||||||
AVAssetReaderOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[_localAsset trackWithTrackID:track.sourceId]
|
AVAssetReaderOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[_localAsset trackWithTrackID:track.sourceId]
|
||||||
outputSettings:nil];
|
outputSettings:nil];
|
||||||
if (![assetReader canAddOutput: assetReaderOutput]) {
|
if (![assetReader canAddOutput:assetReaderOutput]) {
|
||||||
NSLog(@"Unable to add the output to assetReader!");
|
NSLog(@"Unable to add the output to assetReader!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,7 +1005,7 @@
|
|||||||
|
|
||||||
demuxHelper->currentTime += duration.value;
|
demuxHelper->currentTime += duration.value;
|
||||||
currentDataLength += sampleSize;
|
currentDataLength += sampleSize;
|
||||||
} else {
|
} else if (samplesNum > 1) {
|
||||||
// The CMSampleBufferRef contains more than one sample
|
// The CMSampleBufferRef contains more than one sample
|
||||||
if (!CMSampleBufferDataIsReady(sampleBuffer)) {
|
if (!CMSampleBufferDataIsReady(sampleBuffer)) {
|
||||||
CMSampleBufferMakeDataReady(sampleBuffer);
|
CMSampleBufferMakeDataReady(sampleBuffer);
|
||||||
@@ -1050,7 +1050,6 @@
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL attachmentsSent = NO;
|
|
||||||
CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(NULL, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
|
CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(NULL, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
|
||||||
|
|
||||||
// Get CMBlockBufferRef to extract the actual data later
|
// Get CMBlockBufferRef to extract the actual data later
|
||||||
@@ -1185,9 +1184,15 @@
|
|||||||
sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0;
|
sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0;
|
||||||
sample->trackId = track.sourceId;
|
sample->trackId = track.sourceId;
|
||||||
|
|
||||||
if (attachmentsSent == NO) {
|
if (i == 0 && CFDictionaryContainsKey(attachments, kCMSampleBufferAttachmentKey_TrimDurationAtStart)) {
|
||||||
sample->attachments = (void *)attachments;
|
CFMutableDictionaryRef copy = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 2, attachments);
|
||||||
attachmentsSent = YES;
|
CFDictionaryRemoveValue(copy, kCMSampleBufferAttachmentKey_TrimDurationAtEnd);
|
||||||
|
sample->attachments = (void *)copy;
|
||||||
|
}
|
||||||
|
else if (i == (samplesNum - 1) && CFDictionaryContainsKey(attachments, kCMSampleBufferAttachmentKey_TrimDurationAtEnd)) {
|
||||||
|
CFMutableDictionaryRef copy = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 2, attachments);
|
||||||
|
CFDictionaryRemoveValue(copy, kCMSampleBufferAttachmentKey_TrimDurationAtStart);
|
||||||
|
sample->attachments = (void *)copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
[demuxHelper->editsConstructor addSample:sample];
|
[demuxHelper->editsConstructor addSample:sample];
|
||||||
|
|||||||
Reference in new issue
Block a user