Hello everyone,
I'm trying to collect Video file from NSArray of UIImages, but has problem with video duration, i can't make a video more than 1 second, all of my frames collect in 1 second video, could you help with this?
[adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero];
int i = 1;
while (writerInput.readyForMoreMediaData) // every iteration i add my CGImage to buffer, but after 5th iteration readyForMoreMediaData sets to NO, Why???
{
NSLog(@"inside for loop %d",i);
CMTime frameTime = CMTimeMake(1, 10);
CMTime lastTime=CMTimeMake(i, 100);
CMTime presentTime=CMTimeAdd(lastTime, frameTime);
ok, assuming that you want a video of 2 seconds with 10 fps, you need 20 UIImages (you can also insert in the array the same image more than 1 time).
So for example if you need a video of 3.4 seconds, set 10 fps and add 34 images.
with that code i'm able to create a video > 1 sec.
array is an NSArray with 20 UIImage on it, setting 10 fps, i have a video of 2 seconds.
Thanks, it works perfectly on a Simulator, but on Device application is stops after first Loop and that's all. Device is stops, app stops. Why this can happen?
I am trying to grab frames from an animating layer on the iphone. I've copied the two key methods below.
This code sample helped me a lot!! Thanks for posting. I couldn't figure out why mine was failing all the time. I used some code from another sample and mixed and matched and part of my problem was using a quicktime movie instead of AVFileTypeMPEG4.
The one strange thing I can't figure out is why this line of code always returns NO.
Code:
if ([localAdaptor appendPixelBuffer:buffer withPresentationTime:presentTime] == NO) {
NSLog(@"failed to write frame to video %i", i);
}
Is there anywhere I can find out by querying some api to know what is causing my adds to fail? Strangely I still get a movie and it moves correctly to my library and I can play it on my iphone 4.
I know I had it working at some point so something subtle changed and I can't figure out what that is. One thing is that my images are 320x380
and I was unsure what differing image sizes have to do with issues.
Other things I've read is that bad presentation times cause issues. I still don't exactly understand the logic for computing the presentation time either. Isn't it just the same as using i/10 instead of having to add presentation times?
Is there away to use this method to make video for an iphone 3? iphone 3 does not support H264 encoding, I've tried AVVideoCodecJPEG but the AVAssetWriter status is always AVAssetWriterStatusFailed
Got this from AVAssetWriterInput
Video output settings keys are defined in AVVideoSettings.h. Video output settings with keys from
<CoreVideo/CVPixelBuffer.h> are not currently supported. The only values currently supported for
AVVideoCodecKey are AVVideoCodecH264 and AVVideoCodecJPEG. AVVideoCodecH264 is not supported on iPhone 3G.