Added setting to set the position of the rendered chapter previews. Default is the middle of the chapter.
This commit is contained in:
1 parent
414b5e559a
commit
0af9487aa5
4 files changed
+27
-13
No files matched your search
+6
-3
@@ -20,6 +20,7 @@
|
||||
NSString * const MP4264BitData = @"MP4264BitData";
|
||||
NSString * const MP4264BitTime = @"MP4264BitTime";
|
||||
NSString * const MP42GenerateChaptersPreviewTrack = @"MP42ChaptersPreview";
|
||||
NSString * const MP42ChaptersPreviewPosition = @"MP42ChaptersPreviewPosition";
|
||||
NSString * const MP42CustomChaptersPreviewTrack = @"MP42CustomChaptersPreview";
|
||||
|
||||
/**
|
||||
@@ -853,7 +854,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
||||
|
||||
// Generate previews images for chapters
|
||||
if ([options[MP42GenerateChaptersPreviewTrack] boolValue] && self.itracks.count) {
|
||||
[self createChaptersPreview];
|
||||
[self createChaptersPreviewAtPosition:[options[MP42ChaptersPreviewPosition] floatValue]];
|
||||
} else if ([options[MP42CustomChaptersPreviewTrack] boolValue] && self.itracks.count) {
|
||||
[self customChaptersPreview];
|
||||
}
|
||||
@@ -968,7 +969,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)createChaptersPreview {
|
||||
- (BOOL)createChaptersPreviewAtPosition:(CGFloat)position {
|
||||
NSInteger decodable = 1;
|
||||
MP42ChapterTrack *chapterTrack = nil;
|
||||
MP42VideoTrack *refTrack = nil;
|
||||
@@ -1001,7 +1002,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
||||
}
|
||||
|
||||
if (chapterTrack && decodable && (!jpegTrack)) {
|
||||
NSArray<NSImage *> *images = [MP42PreviewGenerator generatePreviewImagesFromChapters:chapterTrack.chapters fileURL:self.URL];
|
||||
NSArray<NSImage *> *images = [MP42PreviewGenerator generatePreviewImagesFromChapters:chapterTrack.chapters
|
||||
fileURL:self.URL
|
||||
atPosition:position];
|
||||
|
||||
// If we haven't got any images, return.
|
||||
if (!images || !images.count) {
|
||||
|
||||
Reference in new issue
Block a user