Improve audio sync.
This commit is contained in:
3 files changed
+16
-7
No files matched your search
@@ -26,7 +26,9 @@
|
|||||||
|
|
||||||
@interface AVFDemuxHelper : NSObject {
|
@interface AVFDemuxHelper : NSObject {
|
||||||
@public
|
@public
|
||||||
|
#ifdef SB_AVF_DEBUG
|
||||||
int64_t currentTime;
|
int64_t currentTime;
|
||||||
|
#endif
|
||||||
int64_t minDisplayOffset;
|
int64_t minDisplayOffset;
|
||||||
|
|
||||||
AVAssetReaderOutput *assetReaderOutput;
|
AVAssetReaderOutput *assetReaderOutput;
|
||||||
@@ -1003,7 +1005,9 @@
|
|||||||
[self enqueue:sample];
|
[self enqueue:sample];
|
||||||
[sample release];
|
[sample release];
|
||||||
|
|
||||||
|
#ifdef SB_AVF_DEBUG
|
||||||
demuxHelper->currentTime += duration.value;
|
demuxHelper->currentTime += duration.value;
|
||||||
|
#endif
|
||||||
currentDataLength += sampleSize;
|
currentDataLength += sampleSize;
|
||||||
} else if (samplesNum > 1) {
|
} else if (samplesNum > 1) {
|
||||||
// The CMSampleBufferRef contains more than one sample
|
// The CMSampleBufferRef contains more than one sample
|
||||||
@@ -1103,7 +1107,9 @@
|
|||||||
[self enqueue:sample];
|
[self enqueue:sample];
|
||||||
[sample release];
|
[sample release];
|
||||||
|
|
||||||
|
#ifdef SB_AVF_DEBUG
|
||||||
demuxHelper->currentTime += duration.value;
|
demuxHelper->currentTime += duration.value;
|
||||||
|
#endif
|
||||||
currentDataLength += sampleSize;
|
currentDataLength += sampleSize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1198,8 +1204,10 @@
|
|||||||
[demuxHelper->editsConstructor addSample:sample];
|
[demuxHelper->editsConstructor addSample:sample];
|
||||||
[self enqueue:sample];
|
[self enqueue:sample];
|
||||||
[sample release];
|
[sample release];
|
||||||
|
|
||||||
|
#ifdef SB_AVF_DEBUG
|
||||||
demuxHelper->currentTime += sampleTimingInfo.duration.value;
|
demuxHelper->currentTime += sampleTimingInfo.duration.value;
|
||||||
|
#endif
|
||||||
currentDataLength += sampleSize;
|
currentDataLength += sampleSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -601,7 +601,9 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
mkv_ReadFrame(_matroskaFile, 0, &Track, &StartTime, &EndTime, &FilePos, &FrameSize, &FrameFlags);
|
mkv_ReadFrame(_matroskaFile, 0, &Track, &StartTime, &EndTime, &FilePos, &FrameSize, &FrameFlags);
|
||||||
mkv_Seek(_matroskaFile, 0, 0);
|
mkv_Seek(_matroskaFile, 0, 0);
|
||||||
|
|
||||||
return StartTime / SCALE_FACTOR;
|
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, Id);
|
||||||
|
|
||||||
|
return (StartTime - trackInfo->CodecDelay) / SCALE_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger)timescaleForTrack:(MP42Track *)track
|
- (NSUInteger)timescaleForTrack:(MP42Track *)track
|
||||||
|
|||||||
+4
-5
@@ -75,8 +75,9 @@
|
|||||||
|
|
||||||
- (void)addTrack:(MP42Track *)track
|
- (void)addTrack:(MP42Track *)track
|
||||||
{
|
{
|
||||||
if (![track isMemberOfClass:[MP42ChapterTrack class]])
|
if (![track isMemberOfClass:[MP42ChapterTrack class]]) {
|
||||||
[_workingTracks addObject:track];
|
[_workingTracks addObject:track];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)setup:(NSError **)outError
|
- (BOOL)setup:(NSError **)outError
|
||||||
@@ -594,14 +595,12 @@
|
|||||||
NSData *magicCookie = [track.muxer_helper->converter magicCookie];
|
NSData *magicCookie = [track.muxer_helper->converter magicCookie];
|
||||||
|
|
||||||
if (magicCookie) {
|
if (magicCookie) {
|
||||||
if (track.conversionSettings.format == kAudioFormatMPEG4AAC)
|
if (track.conversionSettings.format == kAudioFormatMPEG4AAC) {
|
||||||
{
|
|
||||||
MP4SetTrackESConfiguration(_fileHandle, track.trackId,
|
MP4SetTrackESConfiguration(_fileHandle, track.trackId,
|
||||||
magicCookie.bytes,
|
magicCookie.bytes,
|
||||||
magicCookie.length);
|
magicCookie.length);
|
||||||
}
|
}
|
||||||
else if (track.conversionSettings.format == kAudioFormatAC3)
|
else if (track.conversionSettings.format == kAudioFormatAC3) {
|
||||||
{
|
|
||||||
const uint64_t *ac3Info = (const uint64_t *)magicCookie.bytes;
|
const uint64_t *ac3Info = (const uint64_t *)magicCookie.bytes;
|
||||||
|
|
||||||
MP4SetTrackIntegerProperty(_fileHandle, track.trackId, "mdia.minf.stbl.stsd.ac-3.dac3.fscod", ac3Info[0]);
|
MP4SetTrackIntegerProperty(_fileHandle, track.trackId, "mdia.minf.stbl.stsd.ac-3.dac3.fscod", ac3Info[0]);
|
||||||
|
|||||||
Reference in new issue
Block a user