小编Muh*_*san的帖子

使用库或算法压缩视频大小的最快方法

我正在尝试将高质量视频压缩到更小的尺寸,并且我能够使用以下Objective-c代码缩小我压缩的视频大小:

 - (BOOL)convertMovieToMP4:(NSString ) originalMovPath andStoragePath:(NSString ) compMovPath
        {
            NSURL *tmpSourceUrl = [NSURL fileURLWithPath:originalMovPath];

            compMovPath = [compMovPath stringByReplacingOccurrencesOfString:[compMovPath pathExtension] withString:@"mp4"];
            NSURL *tmpDestUrl = [NSURL fileURLWithPath:compMovPath];

            AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:tmpSourceUrl options:nil];
            AVMutableComposition* mixComposition = [AVMutableComposition composition];

            AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo  preferredTrackID:kCMPersistentTrackID_Invalid];

            AVAssetTrack *clipVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
            [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
                                           ofTrack:clipVideoTrack
                                            atTime:kCMTimeZero error:nil];

            [compositionVideoTrack setPreferredTransform:[[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] preferredTransform]];

            CGSize videoSize = [[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] naturalSize];

            CATextLayer *titleLayer = [CATextLayer layer];
            titleLayer.string = @"Ojatro";
            titleLayer.font = (_bridge CFTypeRef Nullable)(@"Helvetica");
            titleLayer.fontSize …
Run Code Online (Sandbox Code Playgroud)

python java macos ffmpeg objective-c

8
推荐指数
1
解决办法
952
查看次数

标签 统计

ffmpeg ×1

java ×1

macos ×1

objective-c ×1

python ×1