Update major brand when saving a file.
This commit is contained in:
1 parent
3f63706eae
commit
a190617dc4
3 files changed
+22
-2
No files matched your search
+5
-2
@@ -164,7 +164,7 @@ MP42_OBJC_DIRECT_MEMBERS
|
||||
- (instancetype)initWithURL:(NSURL *)URL error:(NSError * _Nullable __autoreleasing *)error {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_URL = [URL fileReferenceURL];
|
||||
_URL = URL.fileReferenceURL;
|
||||
|
||||
// Open the file for reading
|
||||
if (![self startReading]) {
|
||||
@@ -1050,8 +1050,11 @@ MP42_OBJC_DIRECT_MEMBERS
|
||||
#endif
|
||||
[self.importers removeAllObjects];
|
||||
|
||||
// Update modified tracks properties
|
||||
// Update moov atom
|
||||
updateMoovDuration(self.fileHandle);
|
||||
updateMajorBrand(self.fileHandle, self.URL);
|
||||
|
||||
// Update modified tracks properties
|
||||
for (MP42Track *track in tracksToUpdate) {
|
||||
if (track.isEdited) {
|
||||
if (![track writeToFile:self.fileHandle error:outError]) {
|
||||
|
||||
@@ -33,6 +33,7 @@ int MP4SetTrackDisabled(MP4FileHandle fileHandle, MP4TrackId trackId);
|
||||
|
||||
int updateTracksCount(MP4FileHandle fileHandle);
|
||||
void updateMoovDuration(MP4FileHandle fileHandle);
|
||||
void updateMajorBrand(MP42FileHandle fileHandle, NSURL *url);
|
||||
|
||||
uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId);
|
||||
|
||||
|
||||
@@ -78,6 +78,22 @@ void updateMoovDuration(MP4FileHandle fileHandle)
|
||||
MP4SetIntegerProperty(fileHandle, "moov.mvhd.duration", maxTrackDuration);
|
||||
}
|
||||
|
||||
void updateMajorBrand(MP42FileHandle fileHandle, NSURL *url)
|
||||
{
|
||||
NSString *fileExtension = url.pathExtension;
|
||||
char *majorBrand = "mp42";
|
||||
|
||||
if ([fileExtension isEqualToString:MP42FileTypeM4V]) {
|
||||
majorBrand = "M4V ";
|
||||
} else if ([fileExtension isEqualToString:MP42FileTypeM4A] ||
|
||||
[fileExtension isEqualToString:MP42FileTypeM4B] ||
|
||||
[fileExtension isEqualToString:MP42FileTypeM4R]) {
|
||||
majorBrand = "M4A ";
|
||||
}
|
||||
|
||||
MP4SetStringProperty(fileHandle, "ftyp.majorBrand", majorBrand);
|
||||
}
|
||||
|
||||
uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId)
|
||||
{
|
||||
MP4SampleId i = 1, sampleNum;
|
||||
|
||||
Reference in new issue
Block a user