gpt4 book ai didi

ffmpeg - 如何将 16 位 RGB 帧缓冲区转换为可视格式?

转载 作者:行者123 更新时间:2023-12-02 01:53:31 24 4
gpt4 key购买 nike

我正在设备上使用其他人的代码,该设备可以将图像放入 /dev/fb/0 并显示在视频输出上或通过网络将其发送到客户端应用程序。

我无权访问客户端应用程序的旧源,但我了解以下有关数据的信息:

  • 720x480
  • 16 位
  • RGB(我不确定是 5、5、5 还是 5、6、5)
  • RAW(没有任何标题)
  • cat-能够/dev/fb/0
  • 675kb

如何为其添加标题或将其转换为 JPEG、BMP 或 RAW 类型以便我可以在桌面应用程序中查看?

最终,我希望它是 jpeg 格式并且可以在浏览器中查看,但目前我可以用眼睛看到的任何内容都可以使用。

成功

(见下面的评论)

ffmpeg \
-vcodec rawvideo \
-f rawvideo \
-pix_fmt rgb565 \
-s 720x480 \
-i in-buffer.raw \
\
-f image2 \
-vcodec mjpeg \
out-buffer.jpg

尝试失败

将图像横向显示三倍,几乎没有颜色,并垂直挤压:

rawtoppm -rgb -interpixel 720 480 fb.raw > fb.ppm

显示图像,但有条纹、垂直挤压且颜色不佳:

rawtoppm -rgb -interrow 720 480 fb.raw > fb.ppm

与上面类似

convert -depth 16 -size 720x480 frame_buffer.rgb fb.jpeg

最佳答案

rgb 到 ppm:只需调味即可!

维护于https://github.com/coolaj86/image-examples

#include <stdio.h>

int main(int argc, char* argv[]) {

FILE* infile; // fb.raw
FILE* outfile; // fb.ppm
unsigned char red, green, blue; // 8-bits each
unsigned short pixel; // 16-bits per pixel
unsigned int maxval; // max color val
unsigned short width, height;
size_t i;

infile = fopen("./fb.raw", "r");
outfile = fopen("./fb.ppm", "wb");
width = 720;
height = 480;
maxval = 255;

// P3 - PPM "plain" header
fprintf(outfile, "P3\n#created with rgb2ppm\n%d %d\n%d\n", width, height, maxval);

for (i = 0; i < width * height; i += 1) {
fread(&pixel, sizeof(unsigned short), 1, infile);

red = (unsigned short)((pixel & 0xF800) >> 11); // 5
green = (unsigned short)((pixel & 0x07E0) >> 5); // 6
blue = (unsigned short)(pixel & 0x001F); // 5

// Increase intensity
red = red << 3;
green = green << 2;
blue = blue << 3;

// P6 binary
//fwrite(&(red | green | blue), 1, sizeof(unsigned short), outfile);

// P3 "plain"
fprintf(outfile, "%d %d %d\n", red, green, blue);
}
}

关于ffmpeg - 如何将 16 位 RGB 帧缓冲区转换为可视格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3781549/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com