質問

iPhoneのカメラフレームをFFMPEGのLibav*ライブラリを使用してH.264ビデオにエンコードしようとしています。私はこれで見つけましたAppleの記事 cmsamplebufferをuiimageに変換するにはどうすればよいですかが、どのようにしてFFMPEGのavpictureに変換できますか?

ありがとう。

役に立ちましたか?

解決

私自身の質問に答える:

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

// access the data
int width = CVPixelBufferGetWidth(pixelBuffer);
int height = CVPixelBufferGetHeight(pixelBuffer);
unsigned char *rawPixelBase = (unsigned char *)CVPixelBufferGetBaseAddress(pixelBuffer);

// Do something with the raw pixels here
// ...

// Fill in the AVFrame
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);

AVFrame *pFrame;
pFrame = avcodec_alloc_frame();

avpicture_fill((AVPicture*)pFrame, rawPixelBase, PIX_FMT_RGB32, width, height);

pFrame ピクセル形式を使用しているサンプルバッファーの内容が入っています kCVPixelFormatType_32BGRA.

これは私の問題を解決しました。ありがとう。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top