如何使用GStreamer 1.0将原始BGRA图像转换为JPG?

kar*_*lip 1 image converter gstreamer gst-launch

我想显示原始图像(1.8MB)gst-launch-1.0。我了解必须先将数据编码为JPG,然后才能实现。如果图像已经以jpg文件存储,那么故事将非常简单:

gst-launch-1.0.exe -v filesrc location=output.jpg ! decodebin ! imagefreeze ! autovideosink
Run Code Online (Sandbox Code Playgroud)

但是,我需要组装管道以显示由3D应用程序转储到磁盘上的原始BGRA 800x600图像(与上面相同)。

到目前为止,这是我所做的,但是问题是它在磁盘上创建了一个完全黑的图像:

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
Run Code Online (Sandbox Code Playgroud)

GStreamer可以处理此任务吗?

kar*_*lip 5

解决了!我遇到的2个主要问题是:

  • dump.bin是我的系统(Cygwin)上的一个符号链接,由于某种原因gst-launch-1.0无法使用它。
  • 当原始数据的工作,一个必须指定块大小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
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我还需要垂直翻转图像,因为它是从3D应用程序的OpenGL帧缓冲区中捕获的

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
Run Code Online (Sandbox Code Playgroud)