avassetexportsession

Swift Video Resizer AVAsset

匆匆过客 提交于 2020-01-21 05:21:07
问题 I have this code that resizes a video from 1280 x 720 to 640 x 360 But i want a resize with no crop. Is there a way to do a full resize the don't crop ? Here's the code class func resizer(inputURL : NSURL , completion: (outPutURL : NSURL?) -> Void ){ let videoAsset = AVAsset(URL: inputURL) as AVAsset let clipVideoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo).first! as AVAssetTrack let composition = AVMutableComposition() composition.addMutableTrackWithMediaType(AVMediaTypeVideo,

Creating a time range for AVAssetExportSession

安稳与你 提交于 2020-01-12 08:01:11
问题 I was wondering how to make a time range for AVAssetExportSession from time stamps such as: NSTimeInterval start = [[NSDate date] timeIntervalSince1970]; NSTimeInterval end = [[NSDate date] timeIntervalSince1970]; The code that I am using for my export session is as follows: AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality]; exportSession.outputURL = videoURL; exportSession.outputFileType =

Adding metadata to AAC M4A via AVAssetExportSession

雨燕双飞 提交于 2020-01-07 02:01:06
问题 I am creating and storing an AAC-encoded .m4a file using AVAudioRecorder. This produces a playable .m4a file just fine. I want to then use AVAssetExportSession to process the file in order to add metadata to the file. The below code is producing a .m4a file of a similar size (1 KB less than source), but when it plays back, there is just silence. NSURL* url = [NSURL fileURLWithPath:self.m4aPath]; AVURLAsset* asset = [AVAsset assetWithURL:url]; AVMutableMetadataItem* t = [AVMutableMetadataItem

AVExportSession to run in background

末鹿安然 提交于 2020-01-04 02:39:12
问题 I am working on one application in which it requires to merge more than one videos. I am using AVExportSession to export merged video. I am also displaying progress bar for exporting video. It is running correctly most of times. The issue occurs when we lock the screen or put application in background mode. This time if exporting is in process, it immediately fails after putting application in background mode. I have also tried to use background task. Check below code. bgTask = [

AVAssetExportSession fails on IOS 13, muxing together audio and video

∥☆過路亽.° 提交于 2020-01-04 00:30:09
问题 This code works (and still does) on all pre-IOS 13 devices. Currently howerver, am getting this error after the exportAsynchronously call runs: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12735), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x282e194a0 {Error Domain=NSOSStatusErrorDomain Code=-12735 "(null)"}} Unsure if IOS 13 adds/changes some

AVAssetExportSession fails on IOS 13, muxing together audio and video

自作多情 提交于 2020-01-04 00:30:09
问题 This code works (and still does) on all pre-IOS 13 devices. Currently howerver, am getting this error after the exportAsynchronously call runs: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12735), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x282e194a0 {Error Domain=NSOSStatusErrorDomain Code=-12735 "(null)"}} Unsure if IOS 13 adds/changes some

AVAssetWriter corrupting the video trimmed by AVAssetExportSession

十年热恋 提交于 2020-01-03 04:45:13
问题 I am trying to trim and then compress a video file. For trimming I am using AVAssetExportSession For compression I am using AVAssetWriter . If I use both codes individually every thing works fine but If I trim and then feed the trim output for compression I got compressed but corrupt video. - (void)viewDidLoad { [super viewDidLoad]; [self trimVideo]; } Trimming Code -(void)trimVideo { AVAsset *anAsset = [[AVURLAsset alloc]initWithURL:[self.asset valueForProperty:ALAssetPropertyAssetURL]

How to convert .caf Audio file into .mp4 file in swift

非 Y 不嫁゛ 提交于 2020-01-02 16:58:11
问题 I'm recording audio using device microphone with AVAudioRecorder which return file in .caf format that is playable only in Apple devices but not on Android devices. Since Apple is not supporting .mp3 file so I want to convert it in .mp4 format before uploading to server. Is .mp4 is good for audio only? Can I convert it with AVAssetExportSession ? Following is audio recorder code: func setupAudioRecorder () { let fileMgr = FileManager.default let dirPaths = fileMgr.urls(for:.documentDirectory,

How to convert .caf Audio file into .mp4 file in swift

穿精又带淫゛_ 提交于 2020-01-02 16:58:08
问题 I'm recording audio using device microphone with AVAudioRecorder which return file in .caf format that is playable only in Apple devices but not on Android devices. Since Apple is not supporting .mp3 file so I want to convert it in .mp4 format before uploading to server. Is .mp4 is good for audio only? Can I convert it with AVAssetExportSession ? Following is audio recorder code: func setupAudioRecorder () { let fileMgr = FileManager.default let dirPaths = fileMgr.urls(for:.documentDirectory,

AVAssetExportSession outputfile

六眼飞鱼酱① 提交于 2020-01-01 10:01:49
问题 How should the AVAssetExportSession output file look like? I'm trying to compress a video from an ALAsset item and it doesn't work. I'm guessing the output file has something to do with it. Here's the code i'm using: NSString *destinationPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie"]; [self convertVideoToLowQualityWithInputURL:asset.defaultRepresentation.url outputURL:[NSURL URLWithString:destinationPath]]; - (void)convertVideoToLowQualityWithInputURL:(NSURL*