问题
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

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
Can GStreamer handle this task?
回答1:
Solved! The 2 major issues I faced were:
- 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
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
来源:https://stackoverflow.com/questions/26931886/how-to-convert-raw-bgra-image-to-jpg-using-gstreamer-1-0