avassetwriter

AVAssetWriterInputPixelBufferAdaptor and CMTime

懵懂的女人 提交于 2019-12-03 16:16:54
问题 I'm writing some frames to video with AVAssetWriterInputPixelBufferAdaptor , and the behavior w.r.t. time isn't what I'd expect. If I write just one frame: [videoWriter startSessionAtSourceTime:kCMTimeZero]; [adaptor appendPixelBuffer:pxBuffer withPresentationTime:kCMTimeZero]; this gets me a video of length zero, which is what I expect. But if I go on to add a second frame: // 3000/600 = 5 sec, right? CMTime nextFrame = CMTimeMake(3000, 600); [adaptor appendPixelBuffer:pxBuffer

.wav to any compressed form from AVAssetWritter ios

十年热恋 提交于 2019-12-03 13:59:01
问题 Well the problem I am facing right now is a size issue problem. I am allowing the user to to choose a song from their library and then chop it up into pieces and then be able to use the .wav or .mp3 file on their computer with file sharing enabled. Basically I am using the following AVAssetWritter options and I keep getting a giant huge audio file. E.G. 5 minutes of music is about 50MB. I am looking to try and cut that down to an industry given standard size. I have a feeling it has to do

Get PTS from raw H264 mdat generated by iOS AVAssetWriter

一世执手 提交于 2019-12-03 13:24:56
问题 I'm trying to simultaneously read and write H.264 mov file written by AVAssetWriter. I managed to extract individual NAL units, pack them into ffmpeg's AVPackets and write them into another video format using ffmpeg. It works and the resulting file plays well except the playback speed is not right. How do I calculate the correct PTS/DTS values from raw H.264 data? Or maybe there exists some other way to get them? Here's what I've tried: Limit capture min/max frame rate to 30 and assume that

Using AVAssetWriter to create a movie from images is not working as expected on a 3GS device

耗尽温柔 提交于 2019-12-03 10:16:59
问题 The call to appendPixelBuffer is returning NO on 3GS device (IOS 4.1), but is working well on iPhone 4 devices. The following call to appendPixelBuffer is the source of the problem: CVPixelBufferRef buffer = NULL; buffer = [self pixelBufferFromCGImage:[[UIImage imageNamed:@"frame1.png"] CGImage]]; BOOL result = [adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero]; if (result == NO) //failes on 3GS, but works on iphone 4 NSLog(@"failed to append buffer"); } Full Code: -(void

AVAssetWriter multiple sessions and the status property

帅比萌擦擦* 提交于 2019-12-03 09:55:54
问题 I am attempting to create multiple, serial writing sessions with AVAssetWriter. Once I've completed one successfully (after calling finishWriting) the status is set to 2 (AVAssetWriterStatusCompleted). Trying to create another session, I call startWriting, but I get the error: [AVAssetWriter startWriting] cannot call method when status is 2 Seems I cannot create a writing session unless I configure something. Do I have to recreate the AVAssetWriter again? I must be missing something, and the

Iphone SDK,Create a Video from UIImage

眉间皱痕 提交于 2019-12-03 08:38:28
i needs to create a video from the image selected. i have code it shoudl work but its giving error while appending buffer. This is how both type of images has been saved. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { // NSLog(@"Came From Here"); imgv.image = img; AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; app.imgmain = img; [self dismissModalViewControllerAnimated:YES]; RecordVoice *rec = [[RecordVoice alloc] initWithNibName:@"RecordVoice" bundle:nil]; rec

Hold multiple Frames in Memory before sending them to AVAssetWriter

三世轮回 提交于 2019-12-03 08:06:27
I need to hold some video frames from a captureSession in memory and write them to a file when 'something' happens. Similar to this solution , i use this code to put a frame into a NSMutableArray: - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection*)connection { //... CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); uint8 *baseAddress = (uint8*)CVPixelBufferGetBaseAddress(imageBuffer); NSData *rawFrame = [[NSData alloc] initWithBytes:(void*)baseAddress length:(height *

Rotating video without rotating AVCaptureConnection and in the middle of AVAssetWriter session

落爺英雄遲暮 提交于 2019-12-03 07:44:23
问题 I'm using PBJVision to implement tap-to-record video functionality. The library doesn't support orientation yet so I'm in the process of trying to engineer it in. From what I see, there are three ways to rotate the video - I need help on deciding the best way forward and how to implement it. Note that rotation can happen between tap-to-record segments. So in a recording session, the orientation is locked to what it was when the user tapped the button. The next time the user taps the button to

AVAssetWriterInputPixelBufferAdaptor and CMTime

陌路散爱 提交于 2019-12-03 05:32:21
I'm writing some frames to video with AVAssetWriterInputPixelBufferAdaptor , and the behavior w.r.t. time isn't what I'd expect. If I write just one frame: [videoWriter startSessionAtSourceTime:kCMTimeZero]; [adaptor appendPixelBuffer:pxBuffer withPresentationTime:kCMTimeZero]; this gets me a video of length zero, which is what I expect. But if I go on to add a second frame: // 3000/600 = 5 sec, right? CMTime nextFrame = CMTimeMake(3000, 600); [adaptor appendPixelBuffer:pxBuffer withPresentationTime:nextFrame]; I get ten seconds of video, where I'm expecting five. What's going on here? Does

What does shouldOptimizeForNetworkUse actually do?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 04:54:18
问题 From the Apple documentation it just says: When the value of this property is YES, the output file will be written in such a way that playback can start after only a small amount of the file is downloaded. But what is actually happening? 回答1: When shouldOptimizeForNetworkUse is set to YES calling finishWriting will move the MP4 moov atom (movie atom) from the end of the file to the beginning of the file. The moov atom contains information about the movie file like timescale and duration. The