I'm confused with what h264parse
really does.
I tested with this commands:
with h264parse
:
gst-launch-1.0 videotestsrc num-buffers=10 ! x264enc ! h264parse ! avdec_h264 ! videoconvert ! autovideosink
without h264parse
:
gst-launch-1.0 videotestsrc num-buffers=10 ! x264enc ! avdec_h264 ! videoconvert ! autovideosink
it makes no difference and both work fine.
Then I tried to save h264 into file and then open it.
save it into file:
gst-launch-1.0 videotestsrc num-buffers=10 ! x264enc ! filesink location=videotestsrc.h264
Open it with h264parse, it works ok and I can see the video:
gst-launch-1.0 filesrc location=videotestsrc.h264 ! h264parse ! avdec_h264 ! videoconvert ! autovideosink
But if I open it without h264parse
:
gst-launch-1.0 filesrc location=videotestsrc.h264 ! avdec_h264 ! videoconvert ! autovideosink
it does not work and the error message is like this:
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/avdec_h264:avdec_h264-0: GStreamer error: negotiation problem.
Additional debug info:
gstvideodecoder.c(2448): gst_video_decoder_chain (): /GstPipeline:pipeline0/avdec_h264:avdec_h264-0:
decoder not initialized
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
I don't know how to understand it.
Thanks
According to the documentation of avdec_h264, his sink expects parsed format of h264 stream. And what h264parse does, it just parses bytes of h264 in a way that avdec_h264 could understand.
# avdec_h264 sink
video/x-h264:
alignment: au
stream-format: { (string)avc, (string)byte-stream }
video/x-h264:
alignment: nal
stream-format: byte-stream
# h264parse src
video/x-h264:
parsed: true
stream-format: { (string)avc, (string)avc3, (string)byte-stream }
alignment: { (string)au, (string)nal }
So, h264parse doesn't decode h264 bytes into the raw video stream, it just assembles bytes in some form.