This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import <AVFoundation/AVFoundation.h> | |
#import <AssetsLibrary/AssetsLibrary.h> | |
//typedef (^AudioWriteComplection)(Bool, NSError); | |
@interface AVAsset (AudiExtract) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil]; | |
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; | |
generator.requestedTimeToleranceAfter = kCMTimeZero; | |
generator.requestedTimeToleranceBefore = kCMTimeZero; | |
for (Float64 i = 0; i < CMTimeGetSeconds(asset.duration) * FPS ; i++){ | |
@autoreleasepool { | |
CMTime time = CMTimeMake(i, FPS); | |
NSError *err; | |
CMTime actualTime; | |
CGImageRef image = [generator copyCGImageAtTime:time actualTime:&actualTime error:&err]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL* videoURL = [[NSBundle mainBundle] URLForResource:@"demo-clip" withExtension:@"mp4"];; | |
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
ALAssetsLibraryWriteVideoCompletionBlock completionBlock = | |
^(NSURL *savedURL, NSError *error) { | |
if (error) { | |
NSLog( @"Error while saving video Photo Library: %@", error ); | |
} else { | |
NSLog( @"Successfuly saved video to Photo Library %@", savedURL.absoluteString); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init]; | |
[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { | |
if (group != NULL) { | |
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { | |
NSLog(@"asset: %@", result); | |
}]; | |
} | |
} failureBlock:^(NSError *error) { | |
NSLog(@"Error -- %@", error); | |
}]; |