问题
I had a raw video file named video.i420 based on I420 format. And I tried to convert it into BGRA format using gst-launch-1.0:
gst-launch-1.0 filesrc location=video.i420 ! videoparse width=1920 height=816 format=2 framerate=24/1 ! videoconvert ! videoparse format=12 ! filesink location=video.bgra
But the output file video.bgra sized only 48 bytes larger than the source file.
Then I played the video.bgra with the followed command:
gst-launch-1.0 filesrc location=video.bgra ! videoparse width=1920 height=816 format=2 framerate=24/1 ! videoconvert ! autovideosink
and it's the same as playing the source file.
What's wrong with the pipeline I created for format conversion? And why didn't it convert as I expect?
回答1:
How about this:
gst-launch-1.0 filesrc location=video.i420 ! videoparse width=1920 height=816 format=i420 framerate=24/1 ! videoconvert ! video/x-raw, format=bgra ! filesink location=video.bgra
I have changed the magic numbers to human readable formats. Just for readability, it should work with numbers as well.
Aside from that. What is required is to tell videoconvert
a definitive video format. I think the videoparser
just parses data, but does not enforce specific caps on its predecessor element.
来源:https://stackoverflow.com/questions/38951754/how-to-convert-i420-frames-to-bgra-format-with-gst-launch-1-0