Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [self dismissModalViewControllerAnimated:NO];
- // Handle movie capture
- NSURL *movieURL = [info objectForKey:
- UIImagePickerControllerMediaURL];
- NSData *data = [NSData dataWithContentsOfURL:movieURL];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"];
- BOOL success = [data writeToFile:tempPath atomically:NO];
- if (success)
- {
- NSLog(@"VIdeo Successfully written");
- }
- else
- {
- NSLog(@"VIdeo Wrting failed");
- }
- NSURL *uploadURL = [NSURL fileURLWithPath:[[NSTemporaryDirectory() stringByAppendingPathComponent:@"1234"] stringByAppendingString:@".mp4"]];
- // Compress movie first
- [self convertVideoToLowQuailtyWithInputURL:movieURL outputURL:uploadURL];
- while ([videoWriterInput isReadyForMoreMediaData])
- {
- CMSampleBufferRef sampleBuffer;
- if ([videoReader status] == AVAssetReaderStatusReading &&
- (sampleBuffer = [videoReaderOutput copyNextSampleBuffer]))
- {
- [videoWriterInput appendSampleBuffer:sampleBuffer];
- CFRelease(sampleBuffer);
- }
- else
- {
- [videoWriterInput markAsFinished];
- if ([videoReader status] == AVAssetReaderStatusCompleted)
- [videoWriter startSessionAtSourceTime:kCMTimeZero];
- dispatch_queue_t processingQueue = dispatch_queue_create("processingQueue2", NULL);
- [audioWriterInput requestMediaDataWhenReadyOnQueue:processingQueue usingBlock:^{
- while (audioWriterInput.readyForMoreMediaData)
- {
- CMSampleBufferRef sampleBuffer;
- if ([audioReader status] == AVAssetReaderStatusReading &&
- (sampleBuffer = [audioReaderOutput copyNextSampleBuffer])) {
- [audioWriterInput appendSampleBuffer:sampleBuffer];
- CFRelease(sampleBuffer);
- }
- else
- {
- [audioWriterInput markAsFinished];
- if ([audioReader status] == AVAssetReaderStatusCompleted)
- {
- [videoWriter finishWritingWithCompletionHandler:^()
- {
- NSLog(@"Output URl : %@",outputURL);
- }];
- }
- }
- }
- }
- ];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement