我想从网络摄像头转换视频流。该视频流称为 HDYC。我觉得这有点特别,所以我现在没有控制。
我的问题是如何使用 ffmpeg 在 C++ 中将该格式转换为 rgb?但有一些限制。
我不想做一个文件。换句话说,它需要转换来自网络摄像头的视频流。也是实时操作。
谢谢。
最佳答案
我不知道你为什么用 h.264 标记它, 因为 HDYC
是 UYVY
的味道像素格式、布局和二次采样,只需 ITU-R Rec. 709定义的色彩空间。
所以您的问题是如何使用 FFmpeg 将 BT.709 YUV 转换为 RGB。 FFmpeg 的 libswscale 可以做到这一点:它的 sws_scale
进行转换,其sws_setColorspaceDetails
允许您为转换提供色彩空间详细信息。
/**
* Scale the image slice in srcSlice and put the resulting scaled
* slice in the image in dst. A slice is a sequence of consecutive
* rows in an image.
[...] */
int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
const int srcStride[], int srcSliceY, int srcSliceH,
uint8_t *const dst[], const int dstStride[]);
/**
[...]
* @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]
[...] */
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
int srcRange, const int table[4], int dstRange,
int brightness, int contrast, int saturation);
关于c++ - 如何将实时视频流从 YUV(HDYC) 转换为 RGB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17183518/