0

我用来阅读 AVAssetReaderTrackOutput 视频。

设置“kCVPixelBufferPixelFormatTypeKey”-“kCVPixelFormatType_32BGRA”工作!

但我需要一个 16 位的视频。

如果设置设置值“kCVPixelFormatType_16....”不起作用。 [asset_reader_output copyNextSampleBuffer]- 总是零 =(

为什么会这样?

我如何改变一点颜色?

UPD:`代码:

[videoWriterInput requestMediaDataWhenReadyOnQueue:queueVideo usingBlock:^
{
    while([videoWriterInput isReadyForMoreMediaData])
    {
        CMSampleBufferRef sampleBuffer=[video_asset_reader_output copyNextSampleBuffer];
        if(sampleBuffer)
        {
            NSLog(@"write video");
            [videoWriterInput appendSampleBuffer:sampleBuffer];
            CFRelease(sampleBuffer);
        } else
        {
            [videoWriterInput markAsFinished];
            dispatch_release(queueVideo);
            videoFinished=YES;
            break;
        }
    }
}];

`

4

1 回答 1

0

Core Video 不支持所有像素格式。BGRA 保证可以工作。您必须执行自己的转换。你用缓冲区做什么?

更新:要访问像素,请使用以下内容:

CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(pixelBuffer, 0);

void* bufferAddress = CVPixelBufferGetBaseAddress(pixelBuffer);
size_t width = CVPixelBufferGetWidth(pixelBuffer);
size_t height = CVPixelBufferGetHeight(pixelBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer);

// Read / modify the pixel data with bufferAddress, height & bytesPerRow
// For BGRA format, it's 4-byte per pixel in that order

CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
于 2013-06-21T06:36:14.340 回答