【问题标题】:AVAssetWriterInput, impossible to choose video resolution?AVAssetWriterInput,无法选择视频分辨率?
【发布时间】:2012-01-13 18:16:16
【问题描述】:

看起来无论AVVideoWidthKeyAVVideoHeightKeyAVVideoCleanApertureWidthKeyAVVideoCleanApertureHeightKey我选择什么,我的视频分辨率都是320x240或480x360。

我正在尝试以 480p 保存视频,我的所有缓冲区都是 640x480,我的会话是 AVCaptureSessionPreset640x480,一切都是 640x480,但我的输出视频仍然按比例缩小。

我正在使用 AVAssetWriterInputPixelBufferAdaptor 和我传入的 CMSampleBufferRef,它的分辨率为 640x480。

我查看了 Stack Overflow 的所有内容,但尚未发现此问题被报告。 :/

【问题讨论】:

    标签: ios video avfoundation


    【解决方案1】:

    我一直使用这个设置并且它有效。这是一个代码示例。

    self.compressionProperties = [[[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                   [NSNumber numberWithInt:params.bps], AVVideoAverageBitRateKey,
                                   [NSNumber numberWithInt:params.keyFrameInterval],AVVideoMaxKeyFrameIntervalKey,
                                   //videoCleanApertureSettings, AVVideoCleanApertureKey,
                                   params.videoProfileLevel, AVVideoProfileLevelKey,
                                   nil ] autorelease];
    
    self.videoSettings = [[[NSMutableDictionary alloc] initWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,
                           [NSNumber numberWithInt:params.outWidth], AVVideoWidthKey,
                           [NSNumber numberWithInt:params.outHeight], AVVideoHeightKey, 
                           self.compressionProperties, AVVideoCompressionPropertiesKey,
                           nil] autorelease];
    
    ...
    
    wobj.writerInput = [[[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo outputSettings:self.videoSettings] autorelease];
    

    【讨论】:

    • 好吧,我明白了,我只是愚蠢,因为任何 iPhone 共享实用程序(youtube、邮件、消息等)都会自动对视频进行缩减采样和缩减。我发现导出原始视频的唯一方法是通过 iPhoto。您在此处粘贴的代码几乎就是我所拥有的,并且运行良好,因此对我来说这是一个值得回答的问题。
    猜你喜欢
    • 1970-01-01
    • 2021-03-02
    • 2013-04-29
    • 2022-01-27
    • 2018-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    相关资源
    最近更新 更多