Search code examples
iosxcodeavfoundationavassetwriter

AVAssetWriterInput Video Not get


I generate image to video using AVAssetWriter, my writer settings

NSDictionary* videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                               AVVideoCodecH264, AVVideoCodecKey,
                               [NSNumber numberWithInt:self.frame.size.width], AVVideoWidthKey,
                               [NSNumber numberWithInt:self.frame.size.height], AVVideoHeightKey,
                               videoCompressionProps, AVVideoCompressionPropertiesKey,
                               nil];
videoWriterInput = [[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings] retain];

my input image Buffer images,

enter image description here

but generated mov file look like this

enter image description here


Solution

  • I generate image to video using AVAssetWriter, my writer settings just modified .

    NSDictionary* videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                   AVVideoCodecH264, AVVideoCodecKey,
                                   [NSNumber numberWithInt:imageView.size.width], AVVideoWidthKey,
                                   [NSNumber numberWithInt:imageView.size.height], AVVideoHeightKey,
                                   videoCompressionProps, AVVideoCompressionPropertiesKey,
                                   nil];
    videoWriterInput = [[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings] retain];