如何使用GStreamer 1.0将原始BGRA图像转换为JPG? [英] How to convert raw BGRA image to JPG using GStreamer 1.0?
问题描述
我正在尝试显示 原始图片(1.8MB)与gst-launch-1.0
.我了解必须先将数据编码为JPG,然后才能实现.如果图像已经存储为 jpg 文件,那么故事将非常简单:
I'm trying to display a raw image (1.8MB) with gst-launch-1.0
. I understand that the data needs to be encoded to JPG before this can be achieve. If image was already stored as a jpg file the story would be quite simple:
gst-launch-1.0.exe -v filesrc location=output.jpg ! decodebin ! imagefreeze ! autovideosink
但是,我需要组装管道以显示原始 BGRA 由3D应用程序转储到磁盘的800x600图像(与上面相同).
However, I need to assemble the pipeline to display a raw BGRA 800x600 image (looks the same as the above) that was dumped to the disk by a 3D application.
这是我到目前为止所做的,但是问题是它在磁盘上创建了一个全黑的图像:
This is what I've done so far, but the problem is that it creates a completely black image on the disk:
gst-launch-1.0.exe -v filesrc location=dumped.bin ! video/x-raw,format=BGRA,width=800,height=600,framerate=1/1 ! videoconvert ! video/x-raw,format=RGB,framerate=1/1 ! jpegenc ! filesink location=out.jpg
GStreamer可以处理此任务吗?
Can GStreamer handle this task?
推荐答案
已解决!我遇到的2个主要问题是:
Solved! The 2 major issues I faced were:
- dump.bin 是我的系统(Cygwin)上的符号链接,由于某些原因
gst-launch-1.0
无法使用它; - 使用原始数据时,必须为
filesrc
指定块大小.
- dump.bin was a symlink on my system (Cygwin) and for some reason
gst-launch-1.0
was unable to work with it; - When working with raw data, one MUST specify the blocksize for
filesrc
.
❄
gst-launch-1.0.exe -v filesrc location=dumped.bin blocksize=1920000 ! video/x-raw,format=BGRA,width=800,height=600,framerate=1/1 ! videoconvert ! video/x-raw,format=RGB,framerate=1/1 ! jpegenc ! filesink location=out.jpg
在这种情况下,我还需要垂直翻转图像,因为它是从3D应用程序的OpenGL帧缓冲区中捕获的 >:
On this specific case I also needed to flip the image vertically because it was captured from the OpenGL framebuffer of a 3D application:
gst-launch-1.0.exe -v filesrc location=dumped.bin blocksize=1920000 ! video/x-raw,format=BGRA,width=800,height=600,framerate=1/1 ! videoconvert ! video/x-raw,format=RGB,framerate=1/1 ! videoflip method=vertical-flip ! jpegenc ! filesink location=out.jpg
这篇关于如何使用GStreamer 1.0将原始BGRA图像转换为JPG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!