Rename MP42Track Id to trackId

This commit is contained in:
Damiano Galassi committed 2015-09-14 11:23:14 +02:00
1 parent 1319ffb9e2
commit 24d215fda9
15 files changed
+243 -206

No files matched your search

+3 -3
View File
@@ -299,7 +299,7 @@
// Set the usual track properties
newTrack.format = [self formatForTrack:track];
newTrack.Id = track.trackID;
newTrack.trackId = track.trackID;
newTrack.sourceURL = self.fileURL;
newTrack.dataLength = track.totalSampleDataLength;
@@ -958,13 +958,13 @@
trackDuration += duration.value;
MP4AddTrackEdit(fileHandle, track.Id, MP4_INVALID_EDIT_ID, timeRange.start.value,
MP4AddTrackEdit(fileHandle, track.trackId, MP4_INVALID_EDIT_ID, timeRange.start.value,
duration.value, 0);
}
if (trackDuration) {
MP4SetTrackIntegerProperty(fileHandle, track.Id, "tkhd.duration", trackDuration);
MP4SetTrackIntegerProperty(fileHandle, track.trackId, "tkhd.duration", trackDuration);
}
}
+52 -40
View File
@@ -16,11 +16,14 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle
{
if ((self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle])) {
MP4GetTrackFloatProperty(fileHandle, _Id, "tkhd.volume", &_volume);
self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
if (self) {
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.volume", &_volume);
_mediaType = MP42MediaTypeAudio;
u_int8_t audioType = MP4GetTrackEsdsObjectTypeId(fileHandle, _Id);
u_int8_t audioType = MP4GetTrackEsdsObjectTypeId(fileHandle, _trackId);
if (audioType != MP4_INVALID_AUDIO_TYPE) {
if (MP4_IS_AAC_AUDIO_TYPE(audioType)) {
@@ -28,7 +31,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
u_int32_t aacConfigLength;
if (MP4GetTrackESConfiguration(fileHandle,
_Id,
_trackId,
&pAacConfig,
&aacConfigLength) == true)
if (pAacConfig != NULL || aacConfigLength >= 2) {
@@ -40,10 +43,10 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
(audioType == MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE)) {
u_int32_t samplesPerFrame =
MP4GetSampleSize(fileHandle, _Id, 1) / 2;
MP4GetSampleSize(fileHandle, _trackId, 1) / 2;
MP4Duration frameDuration =
MP4GetSampleDuration(fileHandle, _Id, 1);
MP4GetSampleDuration(fileHandle, _trackId, 1);
if (frameDuration != 0) {
// assumes track time scale == sampling rate
@@ -54,35 +57,35 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
if (audioType == 0xA9) {
uint64_t channels_count = 0;
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.mp4a.channels", &channels_count);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.mp4a.channels", &channels_count);
_channels = channels_count;
}
else if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.ac-3.dac3")) {
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.ac-3.dac3")) {
uint64_t acmod, lfeon;
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.ac-3.dac3.acmod", &acmod);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.ac-3.dac3.lfeon", &lfeon);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.ac-3.dac3.acmod", &acmod);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.ac-3.dac3.lfeon", &lfeon);
readAC3Config(acmod, lfeon, &_channels, &_channelLayoutTag);
}
else if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.ac-3.dec3")) {
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.ac-3.dec3")) {
// TODO
}
else if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.alac")) {
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.alac")) {
uint64_t channels_count = 0;
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.alac.channels", &channels_count);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.alac.channels", &channels_count);
_channels = channels_count;
}
if (MP4HaveTrackAtom(fileHandle, _Id, "tref.fall")) {
if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.fall")) {
uint64_t fallbackId = 0;
MP4GetTrackIntegerProperty(fileHandle, _Id, "tref.fall.entries.trackId", &fallbackId);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "tref.fall.entries.trackId", &fallbackId);
_fallbackTrackId = (MP4TrackId) fallbackId;
}
if (MP4HaveTrackAtom(fileHandle, _Id, "tref.folw")) {
if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.folw")) {
uint64_t followsId = 0;
MP4GetTrackIntegerProperty(fileHandle, _Id, "tref.folw.entries.trackId", &followsId);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "tref.folw.entries.trackId", &followsId);
_followsTrackId = (MP4TrackId) followsId;
}
@@ -125,44 +128,53 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
- (BOOL)writeToFile:(MP4FileHandle)fileHandle error:(NSError **)outError
{
if (!fileHandle)
if (!fileHandle) {
return NO;
}
if (_Id)
if (_trackId) {
[super writeToFile:fileHandle error:outError];
}
if ([_updatedProperty valueForKey:@"volume"] || !_muxed)
MP4SetTrackFloatProperty(fileHandle, _Id, "tkhd.volume", _volume);
if (_updatedProperty[@"volume"] || !_muxed) {
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.volume", _volume);
}
if ([_updatedProperty valueForKey:@"fallback"] || !_muxed) {
if (_fallbackTrack)
_fallbackTrackId = _fallbackTrack.Id;
if (_updatedProperty[@"fallback"] || !_muxed) {
if (MP4HaveTrackAtom(fileHandle, _Id, "tref.fall") && (_fallbackTrackId == 0)) {
MP4RemoveAllTrackReferences(fileHandle, "tref.fall", _Id);
if (_fallbackTrack) {
_fallbackTrackId = _fallbackTrack.trackId;
}
else if (MP4HaveTrackAtom(fileHandle, _Id, "tref.fall") && (_fallbackTrackId)) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "tref.fall.entries.trackId", _fallbackTrackId);
if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.fall") && (_fallbackTrackId == 0)) {
MP4RemoveAllTrackReferences(fileHandle, "tref.fall", _trackId);
}
else if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.fall") && (_fallbackTrackId)) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "tref.fall.entries.trackId", _fallbackTrackId);
}
else if (_fallbackTrackId) {
MP4AddTrackReference(fileHandle, "tref.fall", _fallbackTrackId, _trackId);
}
else if (_fallbackTrackId)
MP4AddTrackReference(fileHandle, "tref.fall", _fallbackTrackId, _Id);
}
if ([_updatedProperty valueForKey:@"follows"] || !_muxed) {
if (_followsTrack)
_followsTrackId = _followsTrack.Id;
if (_updatedProperty[@"follows"] || !_muxed) {
if (MP4HaveTrackAtom(fileHandle, _Id, "tref.folw") && (_followsTrackId == 0)) {
MP4RemoveAllTrackReferences(fileHandle, "tref.folw", _Id);
if (_followsTrack) {
_followsTrackId = _followsTrack.trackId;
}
else if (MP4HaveTrackAtom(fileHandle, _Id, "tref.folw") && (_followsTrackId)) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "tref.folw.entries.trackId", _followsTrackId);
if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.folw") && (_followsTrackId == 0)) {
MP4RemoveAllTrackReferences(fileHandle, "tref.folw", _trackId);
}
else if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.folw") && (_followsTrackId)) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "tref.folw.entries.trackId", _followsTrackId);
}
else if (_followsTrackId) {
MP4AddTrackReference(fileHandle, "tref.folw", _followsTrackId, _trackId);
}
else if (_followsTrackId)
MP4AddTrackReference(fileHandle, "tref.folw", _followsTrackId, _Id);
}
return _Id;
return (_trackId > 0);
}
- (NSString *)defaultName {
+12 -6
View File
@@ -32,11 +32,17 @@
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle
{
if ((self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle])) {
if (!_name || [_name isEqualToString:@"Text Track"])
self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
if (self) {
if (!_name || [_name isEqualToString:@"Text Track"]) {
_name = [self defaultName];
if (!_format)
}
if (!_format) {
_format = MP42SubtitleFormatText;
}
_mediaType = MP42MediaTypeText;
chapters = [[NSMutableArray alloc] init];
@@ -183,7 +189,7 @@
// get the list of chapters
MP4GetChapters(fileHandle, &fileChapters, &chapterCount, MP4ChapterTypeQt);
MP4DeleteChapters(fileHandle, MP4ChapterTypeAny, _Id);
MP4DeleteChapters(fileHandle, MP4ChapterTypeAny, _trackId);
updateTracksCount(fileHandle);
MP4TrackId refTrack = findFirstVideoTrack(fileHandle);
@@ -239,7 +245,7 @@
MP4SetChapters(fileHandle, fileChapters, i, MP4ChapterTypeQt);
free(fileChapters);
success = _Id = findChapterTrackId(fileHandle);
success = _trackId = findChapterTrackId(fileHandle);
}
}
@@ -250,7 +256,7 @@
120);
return success;
} else if (_Id) {
} else if (_trackId) {
success = [super writeToFile:fileHandle error:outError];
}
+6 -3
View File
@@ -13,7 +13,9 @@
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle
{
if (self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle]) {
self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
if (self) {
_mediaType = MP42MediaTypeClosedCaption;
}
@@ -33,12 +35,13 @@
- (BOOL)writeToFile:(MP42FileHandle)fileHandle error:(NSError **)outError
{
if (_isEdited && !_muxed)
if (_isEdited && !_muxed) {
_muxed = YES;
}
[super writeToFile:fileHandle error:outError];
return _Id;
return (_trackId > 0);
}
- (NSString *)defaultName {
+25 -22
View File
@@ -220,9 +220,11 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
[self reconnectReferences];
// Ugly hack to check for the previews track
for (MP42Track *track in _tracks)
if ([track.format isEqualToString:MP42VideoFormatJPEG])
previewsId = track.Id;
for (MP42Track *track in _tracks) {
if ([track.format isEqualToString:MP42VideoFormatJPEG]) {
previewsId = track.trackId;
}
}
// Load the previews images
[self loadPreviewsFromTrackID:previewsId];
@@ -271,7 +273,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
- (void)loadPreviewsFromTrackID:(MP4TrackId)trackID {
MP42Track *track = [self trackWithTrackID:trackID];
if (track) {
MP4SampleId sampleNum = MP4GetTrackNumberOfSamples(self.fileHandle, track.Id);
MP4SampleId sampleNum = MP4GetTrackNumberOfSamples(self.fileHandle, track.trackId);
for (MP4SampleId currentSampleNum = 1; currentSampleNum <= sampleNum; currentSampleNum++) {
uint8_t *pBytes = NULL;
@@ -282,7 +284,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
bool isSyncSample;
if (!MP4ReadSample(self.fileHandle,
track.Id,
track.trackId,
currentSampleNum,
&pBytes, &numBytes,
&pStartTime, &duration, &renderingOffset,
@@ -343,8 +345,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
- (id)trackWithTrackID:(NSUInteger)trackID {
for (MP42Track *track in self.itracks) {
if (track.Id == trackID)
if (track.trackId == trackID) {
return track;
}
}
return nil;
@@ -367,8 +370,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to add a track while the file is open for writing");
NSAssert(![self.itracks containsObject:track], @"Unsupported operation: trying to add a track that is already present.");
track.sourceId = track.Id;
track.Id = 0;
track.sourceId = track.trackId;
track.trackId = 0;
track.muxed = NO;
track.isEdited = YES;
@@ -514,11 +517,11 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
// We have to handle a few special cases here.
if ([track isMemberOfClass:[MP42ChapterTrack class]]) {
MP4ChapterType err = MP4DeleteChapters(self.fileHandle, MP4ChapterTypeAny, track.Id);
MP4ChapterType err = MP4DeleteChapters(self.fileHandle, MP4ChapterTypeAny, track.trackId);
if (err == 0)
MP4DeleteTrack(self.fileHandle, track.Id);
MP4DeleteTrack(self.fileHandle, track.trackId);
} else {
MP4DeleteTrack(self.fileHandle, track.Id);
MP4DeleteTrack(self.fileHandle, track.trackId);
}
updateTracksCount(self.fileHandle);
@@ -850,7 +853,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
MP4DeleteTrack(self.fileHandle, jpegTrack);
}
jpegTrack = MP4AddJpegVideoTrack(self.fileHandle, MP4GetTrackTimeScale(self.fileHandle, [chapterTrack Id]),
jpegTrack = MP4AddJpegVideoTrack(self.fileHandle, MP4GetTrackTimeScale(self.fileHandle, chapterTrack.trackId),
MP4_INVALID_DURATION, imageSize.width, imageSize.height);
MP4SetTrackLanguage(self.fileHandle, jpegTrack, lang_for_english([videoTrack.language UTF8String])->iso639_2);
@@ -860,7 +863,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
NSUInteger idx = 1;
for (MP42TextSample *chapterT in chapterTrack.chapters) {
MP4Duration duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx++);
MP4Duration duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.trackId, idx++);
NSData *imageData = chapterT.image.data;
@@ -901,10 +904,10 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
true);
}
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.Id);
MP4AddTrackReference(self.fileHandle, "tref.chap", chapterTrack.Id, videoTrack.Id);
MP4AddTrackReference(self.fileHandle, "tref.chap", jpegTrack, videoTrack.Id);
copyTrackEditLists(self.fileHandle, chapterTrack.Id, jpegTrack);
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.trackId);
MP4AddTrackReference(self.fileHandle, "tref.chap", chapterTrack.trackId, videoTrack.trackId);
MP4AddTrackReference(self.fileHandle, "tref.chap", jpegTrack, videoTrack.trackId);
copyTrackEditLists(self.fileHandle, chapterTrack.trackId, jpegTrack);
[self stopWriting];
@@ -926,7 +929,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
refTrack = (MP42VideoTrack *)track;
if ([track.format isEqualToString:MP42VideoFormatJPEG] && !jpegTrack)
jpegTrack = track.Id;
jpegTrack = track.trackId;
}
if (!refTrack)
@@ -955,7 +958,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
}
if ([track.format isEqualToString:MP42VideoFormatJPEG] && !jpegTrack) {
jpegTrack = track.Id;
jpegTrack = track.trackId;
}
if ([track.format isEqualToString:MP42VideoFormatH264]) {
@@ -995,9 +998,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
return NO;
}
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", refTrack.Id);
MP4AddTrackReference(self.fileHandle, "tref.chap", chapterTrack.Id, refTrack.Id);
MP4AddTrackReference(self.fileHandle, "tref.chap", jpegTrack, refTrack.Id);
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", refTrack.trackId);
MP4AddTrackReference(self.fileHandle, "tref.chap", chapterTrack.trackId, refTrack.trackId);
MP4AddTrackReference(self.fileHandle, "tref.chap", jpegTrack, refTrack.trackId);
[self stopWriting];
}
+1 -1
View File
@@ -1608,7 +1608,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height
- (BOOL)cleanUp:(MP4FileHandle)fileHandle
{
MP42Track *track = self.inputTracks.lastObject;
MP4TrackId trackId = track.Id;
MP4TrackId trackId = track.trackId;
if (h264_dpb.dpb.size_min > 0) {
unsigned int ix;
+2 -2
View File
@@ -217,7 +217,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
if (newTrack) {
newTrack.format = [self matroskaCodecIDToHumanReadableName:mkvTrack];
newTrack.Id = i;
newTrack.trackId = i;
newTrack.sourceURL = self.fileURL;
newTrack.dataLength = trackSizes[i];
if (mkvTrack->Type == TT_AUDIO)
@@ -948,7 +948,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId];
MatroskaDemuxHelper *demuxHelper = inputTrack.muxer_helper->demuxer_context;
MP4TrackId trackId = track.Id;
MP4TrackId trackId = track.trackId;
if (demuxHelper->minDisplayOffset != 0) {
+1 -1
View File
@@ -309,7 +309,7 @@
{
for (MP42Track *track in self.outputsTracks) {
MP4TrackId srcTrackId = track.sourceId;
MP4TrackId dstTrackId = track.Id;
MP4TrackId dstTrackId = track.trackId;
MP4Duration trackDuration = 0;
uint32_t i = 1, trackEditCount = MP4GetTrackNumberOfEdits(_fileHandle, srcTrackId);
+5 -5
View File
@@ -393,7 +393,7 @@
if (dstTrackId) {
MP4SetTrackDurationPerChunk(_fileHandle, dstTrackId, timeScale / 8);
track.Id = dstTrackId;
track.trackId = dstTrackId;
}
}
@@ -436,7 +436,7 @@
MP42SampleBuffer *sampleBuffer = nil;
for (int i = 0; i < 100 && (sampleBuffer = [track copyNextSample]) != nil; i++) {
if (!MP4WriteSample(_fileHandle, track.Id,
if (!MP4WriteSample(_fileHandle, track.trackId,
sampleBuffer->data, sampleBuffer->size,
sampleBuffer->duration, sampleBuffer->offset,
sampleBuffer->isSync)) {
@@ -478,9 +478,9 @@
for (MP42Track *track in _workingTracks) {
if(track.muxer_helper->converter && track.needConversion && [track isMemberOfClass:[MP42AudioTrack class]]) {
NSData *magicCookie = [track.muxer_helper->converter magicCookie];
MP4SetTrackESConfiguration(_fileHandle, track.Id,
[magicCookie bytes],
[magicCookie length]);
MP4SetTrackESConfiguration(_fileHandle, track.trackId,
magicCookie.bytes,
magicCookie.length);
}
}
+4 -4
View File
@@ -230,7 +230,7 @@
if (newTrack) {
newTrack.format = [self formatForTrack:track];
newTrack.Id = [[track attributeForKey:QTTrackIDAttribute] integerValue];
newTrack.trackId = [[track attributeForKey:QTTrackIDAttribute] integerValue];
newTrack.sourceURL = self.fileURL;
newTrack.name = [track attributeForKey:QTTrackDisplayNameAttribute];
newTrack.language = [self langForTrack:track];
@@ -956,11 +956,11 @@
editDwell = GetTrackEditRate64(qtcTrack, editTrackStart);
if (demuxHelper->minDisplayOffset < 0 && editDisplayStart != -1) {
MP4AddTrackEdit(fileHandle, track.Id, MP4_INVALID_EDIT_ID, editDisplayStart - demuxHelper->minDisplayOffset,
MP4AddTrackEdit(fileHandle, track.trackId, MP4_INVALID_EDIT_ID, editDisplayStart - demuxHelper->minDisplayOffset,
editTrackDuration, !Fix2X(editDwell));
}
else {
MP4AddTrackEdit(fileHandle, track.Id, MP4_INVALID_EDIT_ID, editDisplayStart,
MP4AddTrackEdit(fileHandle, track.trackId, MP4_INVALID_EDIT_ID, editDisplayStart,
editTrackDuration, !Fix2X(editDwell));
}
@@ -974,7 +974,7 @@
&editTrackDuration);
}
MP4SetTrackIntegerProperty(fileHandle, track.Id, "tkhd.duration", trackDuration);
MP4SetTrackIntegerProperty(fileHandle, track.trackId, "tkhd.duration", trackDuration);
}
return YES;
+38 -27
View File
@@ -15,29 +15,37 @@
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle
{
if ((self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle])) {
self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
if (self) {
_mediaType = MP42MediaTypeSubtitle;
if (![_format isEqualToString:MP42SubtitleFormatVobSub]) {
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", &height);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", &width);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", &height);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", &width);
uint64_t displayFlags = 0;
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.tx3g.displayFlags", &displayFlags);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.displayFlags", &displayFlags);
if (displayFlags) {
if ((displayFlags & 0x20000000) == 0x20000000)
if ((displayFlags & 0x20000000) == 0x20000000) {
_verticalPlacement = YES;
if ((displayFlags & 0x40000000) == 0x40000000)
}
if ((displayFlags & 0x40000000) == 0x40000000) {
_someSamplesAreForced = YES;
if ((displayFlags & 0x80000000) == 0x80000000)
}
if ((displayFlags & 0x80000000) == 0x80000000) {
_allSamplesAreForced = YES;
}
}
if (MP4HaveTrackAtom(fileHandle, _Id, "tref.forc")) {
if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.forc")) {
uint64_t forcedId = 0;
MP4GetTrackIntegerProperty(fileHandle, _Id, "tref.forc.entries.trackId", &forcedId);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "tref.forc.entries.trackId", &forcedId);
_forcedTrackId = (MP4TrackId) forcedId;
}
}
@@ -59,7 +67,7 @@
- (BOOL)writeToFile:(MP4FileHandle)fileHandle error:(NSError **)outError
{
if (!fileHandle || !_Id) {
if (!fileHandle || !_trackId) {
if ( outError != NULL) {
*outError = MP42Error(@"Error: couldn't mux subtitle track",
nil,
@@ -69,30 +77,33 @@
}
}
if ([_updatedProperty valueForKey:@"forced"] || !_muxed) {
if (_forcedTrack)
_forcedTrackId = _forcedTrack.Id;
if (_updatedProperty[@"forced"] || !_muxed) {
if (MP4HaveTrackAtom(fileHandle, _Id, "tref.forc") && (_forcedTrackId == 0)) {
MP4RemoveAllTrackReferences(fileHandle, "tref.forc", _Id);
if (_forcedTrack) {
_forcedTrackId = _forcedTrack.trackId;
}
else if (MP4HaveTrackAtom(fileHandle, _Id, "tref.forc") && (_forcedTrackId)) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "tref.forc.entries.trackId", _forcedTrackId);
if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.forc") && (_forcedTrackId == 0)) {
MP4RemoveAllTrackReferences(fileHandle, "tref.forc", _trackId);
}
else if (MP4HaveTrackAtom(fileHandle, _trackId, "tref.forc") && (_forcedTrackId)) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "tref.forc.entries.trackId", _forcedTrackId);
}
else if (_forcedTrackId) {
MP4AddTrackReference(fileHandle, "tref.forc", _forcedTrackId, _trackId);
}
else if (_forcedTrackId)
MP4AddTrackReference(fileHandle, "tref.forc", _forcedTrackId, _Id);
}
if (_isEdited && !_muxed) {
MP4GetTrackFloatProperty(fileHandle, _Id, "tkhd.width", &trackWidth);
MP4GetTrackFloatProperty(fileHandle, _Id, "tkhd.height", &trackHeight);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", &trackWidth);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", &trackHeight);
uint8_t *val;
uint8_t nval[36];
uint32_t *ptr32 = (uint32_t*) nval;
uint32_t size;
MP4GetTrackBytesProperty(fileHandle ,_Id, "tkhd.matrix", &val, &size);
MP4GetTrackBytesProperty(fileHandle ,_trackId, "tkhd.matrix", &val, &size);
memcpy(nval, val, size);
offsetX = CFSwapInt32BigToHost(ptr32[6]) / 0x10000;
offsetY = CFSwapInt32BigToHost(ptr32[7]) / 0x10000;
@@ -100,15 +111,15 @@
[super writeToFile:fileHandle error:outError];
return _Id;
return _trackId;
}
else {
[super writeToFile:fileHandle error:outError];
}
if (![_format isEqualToString:MP42SubtitleFormatVobSub]) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", trackHeight);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", trackWidth);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", trackHeight);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", trackWidth);
uint32_t displayFlags = 0;
if (_verticalPlacement)
@@ -118,7 +129,7 @@
if (_allSamplesAreForced)
displayFlags |= 0x80000000;
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.tx3g.displayFlags", displayFlags);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.displayFlags", displayFlags);
}
return YES;
@@ -227,7 +238,7 @@ static void insertTagsFromStyleRecord(style_record record, NSMutableString *samp
if (!fileHandle)
return NO;
MP4TrackId srcTrackId = _Id;
MP4TrackId srcTrackId = _trackId;
MP4SampleId sampleId = 1;
NSUInteger srtSampleNumber = 1;
+11 -9
View File
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface MP42Track : NSObject <NSCoding, NSCopying> {
@protected
MP42TrackId _Id;
MP42TrackId _trackId;
MP42TrackId _sourceId;
NSURL *_sourceURL;
@@ -28,11 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *_language;
NSString *_extendedLanguageTag;
NSSet<NSString *> *_mediaCharacteristicTags;
BOOL _enabled;
uint64_t _alternate_group;
int64_t _startOffset;
BOOL _isEdited;
BOOL _muxed;
@@ -45,6 +41,12 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableDictionary<NSString *, NSNumber *> *_updatedProperty;
@private
NSSet<NSString *> *_mediaCharacteristicTags;
uint64_t _alternate_group;
int64_t _startOffset;
void *_helper;
}
@@ -52,10 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)writeToFile:(MP42FileHandle)fileHandle error:(NSError **)outError;
- (NSString *)timeString;
- (NSString *)formatSummary;
@property(nonatomic, readwrite) MP42TrackId Id;
@property(nonatomic, readwrite) MP42TrackId trackId;
@property(nonatomic, readwrite) MP42TrackId sourceId;
@property(nonatomic, readwrite, copy) NSURL *sourceURL;
@@ -83,6 +82,9 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readwrite) uint64_t dataLength;
@property (nonatomic, readonly) NSString *timeString;
@property (nonatomic, readonly) NSString *formatSummary;
@end
NS_ASSUME_NONNULL_END
+32 -32
View File
@@ -33,36 +33,36 @@
{
if ((self = [super init])) {
_sourceURL = [URL retain];
_Id = (MP4TrackId)trackID;
_trackId = (MP4TrackId)trackID;
_isEdited = NO;
_muxed = YES;
_updatedProperty = [[NSMutableDictionary alloc] init];
if (fileHandle) {
_format = [getHumanReadableTrackMediaDataName(fileHandle, _Id) retain];
_name = [getTrackName(fileHandle, _Id) retain];
_language = [getHumanReadableTrackLanguage(fileHandle, _Id) retain];
_format = [getHumanReadableTrackMediaDataName(fileHandle, _trackId) retain];
_name = [getTrackName(fileHandle, _trackId) retain];
_language = [getHumanReadableTrackLanguage(fileHandle, _trackId) retain];
// Extended language tag
if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.elng")) {
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.elng")) {
const char *elng;
if (MP4GetTrackStringProperty(fileHandle, _Id, "mdia.elng", &elng)) {
if (MP4GetTrackStringProperty(fileHandle, _trackId, "mdia.elng", &elng)) {
_extendedLanguageTag = [[NSString stringWithCString:elng encoding:NSASCIIStringEncoding] retain];
}
}
_bitrate = MP4GetTrackBitRate(fileHandle, _Id);
_duration = MP4ConvertFromTrackDuration(fileHandle, _Id,
MP4GetTrackDuration(fileHandle, _Id),
_bitrate = MP4GetTrackBitRate(fileHandle, _trackId);
_duration = MP4ConvertFromTrackDuration(fileHandle, _trackId,
MP4GetTrackDuration(fileHandle, _trackId),
MP4_MSECS_TIME_SCALE);
_timescale = MP4GetTrackTimeScale(fileHandle, _Id);
_startOffset = getTrackStartOffset(fileHandle, _Id);
_timescale = MP4GetTrackTimeScale(fileHandle, _trackId);
_startOffset = getTrackStartOffset(fileHandle, _trackId);
_size = getTrackSize(fileHandle, _Id);
_size = getTrackSize(fileHandle, _trackId);
// Track flags
uint64_t temp;
MP4GetTrackIntegerProperty(fileHandle, _Id, "tkhd.flags", &temp);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "tkhd.flags", &temp);
if (temp & TRACK_ENABLED) {
_enabled = YES;
}
@@ -70,7 +70,7 @@
_enabled = NO;
}
MP4GetTrackIntegerProperty(fileHandle, _Id, "tkhd.alternate_group", &_alternate_group);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "tkhd.alternate_group", &_alternate_group);
// Media characteristic tags
NSMutableSet *mediaCharacteristicTags = [[NSMutableSet alloc] init];
@@ -81,12 +81,12 @@
while (found) {
NSString *atomName = [NSString stringWithFormat:@"udta.tagc[%d]", count];
if (MP4HaveTrackAtom(fileHandle, _Id, atomName.UTF8String)) {
if (MP4HaveTrackAtom(fileHandle, _trackId, atomName.UTF8String)) {
uint8_t *ppValue;
uint32_t pValueSize;
NSString *propertyName = [atomName stringByAppendingString:@".tag"];
MP4GetTrackBytesProperty(fileHandle, _Id, propertyName.UTF8String, &ppValue, &pValueSize);
MP4GetTrackBytesProperty(fileHandle, _trackId, propertyName.UTF8String, &ppValue, &pValueSize);
if (pValueSize) {
NSString *tag = [[NSString alloc] initWithBytes:ppValue length:pValueSize encoding:NSASCIIStringEncoding];
@@ -116,7 +116,7 @@
MP42Track *copy = [[[self class] alloc] init];
if (copy) {
copy->_Id = _Id;
copy->_trackId = _trackId;
copy->_sourceId = _sourceId;
copy->_sourceURL = [_sourceURL retain];
@@ -153,7 +153,7 @@
{
BOOL success = YES;
if (!fileHandle || !_Id) {
if (!fileHandle || !_trackId) {
if ( outError != NULL) {
*outError = MP42Error(@"Failed to modify track",
nil,
@@ -176,41 +176,41 @@
const char *cString = [_name cStringUsingEncoding:NSMacOSRomanStringEncoding];
if (cString) {
MP4SetTrackName(fileHandle, _Id, cString);
MP4SetTrackName(fileHandle, _trackId, cString);
}
}
else {
MP4SetTrackName(fileHandle, _Id, "\0");
MP4SetTrackName(fileHandle, _trackId, "\0");
}
}
if (_updatedProperty[@"alternate_group"] || !_muxed) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "tkhd.alternate_group", _alternate_group);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "tkhd.alternate_group", _alternate_group);
}
if (_updatedProperty[@"start_offset"]) {
setTrackStartOffset(fileHandle, _Id, _startOffset);
setTrackStartOffset(fileHandle, _trackId, _startOffset);
}
if (_updatedProperty[@"language"] || !_muxed) {
MP4SetTrackLanguage(fileHandle, _Id, lang_for_english([_language UTF8String])->iso639_2);
MP4SetTrackLanguage(fileHandle, _trackId, lang_for_english([_language UTF8String])->iso639_2);
}
if (_updatedProperty[@"extendedLanguageTag"] || !_muxed) {
MP4SetTrackStringProperty(fileHandle, _Id, "mdia.elng", [_extendedLanguageTag cStringUsingEncoding:NSASCIIStringEncoding]);
MP4SetTrackStringProperty(fileHandle, _trackId, "mdia.elng", [_extendedLanguageTag cStringUsingEncoding:NSASCIIStringEncoding]);
}
if (_updatedProperty[@"enabled"] || !_muxed) {
if (_enabled) { MP4SetTrackEnabled(fileHandle, _Id); }
else { MP4SetTrackDisabled(fileHandle, _Id); }
if (_enabled) { MP4SetTrackEnabled(fileHandle, _trackId); }
else { MP4SetTrackDisabled(fileHandle, _trackId); }
}
if (_updatedProperty[@"mediaCharacteristicTags"] || !_muxed) {
MP4RemoveAllMediaCharacteristicTags(fileHandle, _Id);
MP4RemoveAllMediaCharacteristicTags(fileHandle, _trackId);
for (NSString *tag in _mediaCharacteristicTags) {
MP4AddMediaCharacteristicTag(fileHandle, _Id, tag.UTF8String);
MP4AddMediaCharacteristicTag(fileHandle, _trackId, tag.UTF8String);
}
}
@@ -223,7 +223,7 @@
}
@synthesize sourceURL = _sourceURL;
@synthesize Id = _Id;
@synthesize trackId = _trackId;
@synthesize sourceId = _sourceId;
@synthesize format = _format;
@@ -328,7 +328,7 @@
{
[coder encodeInt:2 forKey:@"MP42TrackVersion"];
[coder encodeInt64:_Id forKey:@"Id"];
[coder encodeInt64:_trackId forKey:@"Id"];
[coder encodeInt64:_sourceId forKey:@"sourceId"];
#ifdef SB_SANDBOX
@@ -383,7 +383,7 @@
NSInteger version = [decoder decodeInt32ForKey:@"MP42TrackVersion"];
_Id = (MP4TrackId)[decoder decodeInt64ForKey:@"Id"];
_trackId = (MP4TrackId)[decoder decodeInt64ForKey:@"Id"];
_sourceId = (MP4TrackId)[decoder decodeInt64ForKey:@"sourceId"];
NSData *bookmarkData = [decoder decodeObjectForKey:@"bookmark"];
@@ -429,7 +429,7 @@
}
- (NSString *)description {
return [NSString stringWithFormat:@"Track: %d, %@, %@, %llu kbit/s, %@", [self Id], [self name], [self timeString], [self dataLength] / [self duration] * 8, [self format]];
return [NSString stringWithFormat:@"Track: %d, %@, %@, %llu kbit/s, %@", [self trackId], [self name], [self timeString], [self dataLength] / [self duration] * 8, [self format]];
}
@synthesize timescale = _timescale;
+50 -50
View File
@@ -14,46 +14,49 @@
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle
{
if ((self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle])) {
self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
if (self) {
if ([self isMemberOfClass:[MP42VideoTrack class]]) {
height = MP4GetTrackVideoHeight(fileHandle, _Id);
width = MP4GetTrackVideoWidth(fileHandle, _Id);
height = MP4GetTrackVideoHeight(fileHandle, _trackId);
width = MP4GetTrackVideoWidth(fileHandle, _trackId);
}
_mediaType = MP42MediaTypeVideo;
MP4GetTrackFloatProperty(fileHandle, _Id, "tkhd.width", &trackWidth);
MP4GetTrackFloatProperty(fileHandle, _Id, "tkhd.height", &trackHeight);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", &trackWidth);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", &trackHeight);
uint8_t *val;
uint8_t nval[36];
uint32_t *ptr32 = (uint32_t*) nval;
uint32_t size;
MP4GetTrackBytesProperty(fileHandle ,_Id, "tkhd.matrix", &val, &size);
MP4GetTrackBytesProperty(fileHandle ,_trackId, "tkhd.matrix", &val, &size);
memcpy(nval, val, size);
offsetX = CFSwapInt32BigToHost(ptr32[6]) / 0x10000;
offsetY = CFSwapInt32BigToHost(ptr32[7]) / 0x10000;
free(val);
if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.*.pasp")) {
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.pasp.hSpacing", &hSpacing);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.pasp.vSpacing", &vSpacing);
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp")) {
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.hSpacing", &hSpacing);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.vSpacing", &vSpacing);
}
else {
hSpacing = 1;
vSpacing = 1;
}
if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap")) {
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", &cleanApertureWidthN);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", &cleanApertureWidthD);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", &cleanApertureHeightN);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", &cleanApertureHeightD);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.horizOffN", &horizOffN);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.horizOffD", &horizOffD);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.vertOffN", &vertOffN);
MP4GetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.vertOffD", &vertOffD);
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap")) {
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", &cleanApertureWidthN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", &cleanApertureWidthD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", &cleanApertureHeightN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", &cleanApertureHeightD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffN", &horizOffN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffD", &horizOffD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffN", &vertOffN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", &vertOffD);
}
if ([_format isEqualToString:MP42VideoFormatH264]) {
@@ -79,85 +82,82 @@
- (BOOL)writeToFile:(MP4FileHandle)fileHandle error:(NSError **)outError
{
if (!fileHandle)
if (!fileHandle) {
return NO;
}
if (_Id) {
if (_trackId) {
[super writeToFile:fileHandle error:outError];
if (trackWidth > 0 && trackHeight > 0) {
MP4SetTrackFloatProperty(fileHandle, _Id, "tkhd.width", trackWidth);
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", trackWidth);
MP4SetTrackFloatProperty(fileHandle, _Id, "tkhd.height", trackHeight);
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", trackHeight);
uint8_t *val;
uint8_t nval[36];
uint32_t *ptr32 = (uint32_t*) nval;
uint32_t size;
MP4GetTrackBytesProperty(fileHandle ,_Id, "tkhd.matrix", &val, &size);
MP4GetTrackBytesProperty(fileHandle ,_trackId, "tkhd.matrix", &val, &size);
memcpy(nval, val, size);
ptr32[6] = CFSwapInt32HostToBig(offsetX * 0x10000);
ptr32[7] = CFSwapInt32HostToBig(offsetY * 0x10000);
MP4SetTrackBytesProperty(fileHandle, _Id, "tkhd.matrix", nval, size);
MP4SetTrackBytesProperty(fileHandle, _trackId, "tkhd.matrix", nval, size);
free(val);
if ([_updatedProperty valueForKey:@"hSpacing"] || [_updatedProperty valueForKey:@"vSpacing"]) {
if (_updatedProperty[@"hSpacing"] || _updatedProperty[@"vSpacing"]) {
if (hSpacing >= 1 && vSpacing >= 1) {
if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.*.pasp")) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.pasp.hSpacing", hSpacing);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.pasp.vSpacing", vSpacing);
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp")) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.hSpacing", hSpacing);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.vSpacing", vSpacing);
}
else {
MP4AddPixelAspectRatio(fileHandle, _trackId, (uint32_t)hSpacing, (uint32_t)vSpacing);
}
else
MP4AddPixelAspectRatio(fileHandle, _Id, (uint32_t)hSpacing, (uint32_t)vSpacing);
}
}
if (cleanApertureWidthN >= 1 && cleanApertureHeightN >= 1) {
if (MP4HaveTrackAtom(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap")) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", cleanApertureWidthN);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", cleanApertureWidthD);
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap")) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", cleanApertureWidthN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", cleanApertureWidthD);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", cleanApertureHeightN);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", cleanApertureHeightD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", cleanApertureHeightN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", cleanApertureHeightD);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.horizOffN", horizOffN);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.horizOffD", horizOffD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffN", horizOffN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffD", horizOffD);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.vertOffN", vertOffN);
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*.clap.vertOffD", vertOffD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffN", vertOffN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", vertOffD);
}
else
MP4AddCleanAperture(fileHandle, _Id, cleanApertureWidthN, cleanApertureWidthD, cleanApertureHeightN, cleanApertureHeightD,
MP4AddCleanAperture(fileHandle, _trackId, cleanApertureWidthN, cleanApertureWidthD, cleanApertureHeightN, cleanApertureHeightD,
horizOffN, horizOffD, vertOffN, vertOffD);
}
if ([_format isEqualToString:MP42VideoFormatH264]) {
if ([_updatedProperty valueForKey:@"profile"]) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*[0].avcC.AVCProfileIndication", _newProfile);
if (_updatedProperty[@"profile"]) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*[0].avcC.AVCProfileIndication", _newProfile);
_origProfile = _newProfile;
}
if ([_updatedProperty valueForKey:@"level"]) {
MP4SetTrackIntegerProperty(fileHandle, _Id, "mdia.minf.stbl.stsd.*[0].avcC.AVCLevelIndication", _newLevel);
if (_updatedProperty[@"level"]) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*[0].avcC.AVCLevelIndication", _newLevel);
_origLevel = _newLevel;
}
}
}
}
return (_Id > 0);
return (_trackId > 0);
}
- (NSString *)defaultName {
return MP42MediaTypeVideo;
}
- (void)dealloc
{
[super dealloc];
}
@synthesize width;
@synthesize height;
+1 -1
View File
@@ -234,7 +234,7 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
newTrack.format = MP42SubtitleFormatVobSub;
newTrack.sourceURL = self.fileURL;
newTrack.alternate_group = 2;
newTrack.Id = count++;
newTrack.trackId = count++;
newTrack.language = [NSString stringWithFormat:@"%s", lang_for_code_s([track->language UTF8String])->eng_name];;
newTrack.duration = track->duration;