How to convert a raw BGRA image to a JPG using GStreamer 1.0?

I am trying to display a raw image (1.8MB) using gst-launch-1.0 . I understand that data must be encoded in JPG before this is achieved. If the image was already saved as a jpg file, the story would be quite simple:

 gst-launch-1.0.exe -v filesrc location=output.jpg ! decodebin ! imagefreeze ! autovideosink 

RaxAI.png

However, I need to assemble a pipeline to display raw BGRA 800x600 images (looks the same as above), which was photographed on a disk using a 3D application.

This is what I have 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 

Can GStreamer complete this task?

+1
source share
1 answer

Solved! I ran into two main problems:

  • dump.bin was a symbolic link 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 indicate the block size 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 

In this particular case, I also needed to flip the image vertically because it was captured from the framebuffer of an OpenGL 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 
+5
source

Source: https://habr.com/ru/post/970032/


All Articles