问题
Is there are any compression technique in iPhone to compress video using AVfoundation. or any open source.
Regards, Jeeva
回答1:
Try this :)
+ (void)convertVideoToLowQualityWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL successHandler:(void (^)())successHandler failureHandler:(void (^)(NSError *))failureHandler
{
if([[NSFileManager defaultManager] fileExistsAtURL:outputURL]) [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = outputURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSession exportAsynchronouslyWithCompletionHandler: ^(void) {
if (exportSession.status == AVAssetExportSessionStatusCompleted)
{
successHandler();
}
else
{
NSError *error = [NSError errorWithDomain:domain code:code userInfo:userInfo];
failureHandler(error);
}
}];
}
回答2:
Here is best example provided by Apple for recording using AVFoundation
You can make settings (Dimension/ FPS/ BitRate) custom.
https://developer.apple.com/library/ios/#samplecode/RosyWriter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011110
Hope this will help you
回答3:
Yes, it is called AVAssetWriter. Search around for examples, it is too complicated to give a coherent piece of working code as an answer here.
来源:https://stackoverflow.com/questions/8851335/how-to-compress-video-using-avfoundation-in-ios