gstreamer 的 h264parse 到底做了什么?

What does gstreamer's h264parse really do?

我对 h264parse 的真正作用感到困惑。

我用这个命令测试过:

h264parse:

gst-launch-1.0 videotestsrc num-buffers=10 ! x264enc ! h264parse ! avdec_h264 ! videoconvert ! autovideosink

没有h264parse:

gst-launch-1.0 videotestsrc num-buffers=10 ! x264enc ! avdec_h264 ! videoconvert ! autovideosink

没有区别,两者都可以正常工作。

然后我尝试将h264保存到文件中然后打开它。

将其保存到文件中:

gst-launch-1.0  videotestsrc num-buffers=10 ! x264enc ! filesink location=videotestsrc.h264

用h264parse打开,可以正常看到视频:

gst-launch-1.0 filesrc location=videotestsrc.h264 ! h264parse ! avdec_h264 ! videoconvert ! autovideosink

但是如果我不打开它 h264parse:

gst-launch-1.0 filesrc location=videotestsrc.h264 ! avdec_h264 ! videoconvert ! autovideosink

它不起作用,错误信息是这样的:

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 ...

不知道怎么理解

谢谢

按照documentation of avdec_h264, his sink expects parsed format of h264 stream. And what h264parse做的,只是解析了h264[=25=的字节] 以 avdec_h264 可以理解的方式。

# 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 }

所以,h264parse 不解码 h264字节到原始视频流中,它只是以某种形式组装字节。