'Gstreamer: Is there way to convert h264 video-stream from byte-stream to avc format
I would need the above mentioned method to convert h264 stream with stream format byte-stream to avc (sort of packetized format) in order for it to be fed into matroskamux
I have used C codes to program my pipeline and I have tried to use h264parse element before feeding to the matroskamux but it just simply parse it without changing the stream format.
However when I tried to use command line interfaces to script out the static pipeline that I use to mimic the same effects. Miraculously, the result is what I need and there is virtually no other h264parse properties that i use. I can obtain what I need to feed the matroskamux
I tried to figure out what is the property to set for h264parse but none of which seem to be able to explicitly convert to another format. Is there something else to packetize the stream bytes into avc? Or it is I must force the pad?
I am using vpuh264_enc on ARM platform and as such would have limited choice of plugins available but would still be happy to hear what I could do about the problem.
Thanks
==========================================================
More information:
How i have gotten the video pad of splitmuxsink
first i get the pad template
video_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (splitmuxsink), "video");
Next I get the pad using request pad
pad = tee_pad = gst_element_request_pad (splitmuxsink, video_pad_template, NULL, NULL);
After which i joined as per normal
'if (gst_pad_link (src_pad, pad) != GST_PAD_LINK_OK ) { g_printerr (" could not be linked.\n"); gst_object_unref (pipeline); return -1; }'
============================================================
The CLI command (which I use)
gst-launch-1.0 \
v4l2src \
! video/x-raw,width=640,height=480,framerate=30/1,is-live=true \
! videorate \
! video/x-raw,framerate=25/1 \
! tee name=tv \
tv. \
! queue \
! vpuenc_h264 \
! tee name=tv2 \
tv2. \
! queue \
! h264parse \
! queue \
! m.video \
tv2. \
! queue \
! rtph264pay pt=96 \
! udpsink host="192.168.50.3" port=2534 \
pulsesrc \
! audioconvert \
! audioresample \
! audio/x-raw,rate=8000,channels=1,depth=8,format=S16LE \
! tee name=ta \
! queue \
! mulawenc \
! tee name=ta2 \
ta2. \
! queue \
! rtppcmupay pt=97 \
! udpsink host="192.168.50.3" port=2536 \
ta2. \
! queue \
! m.audio_0 splitmuxsink location=log%02d.mkv muxer=matroskamux max-size-time=60000000000 name=m
Solution 1:[1]
The full source or a minimal reproducible example would be useful to help you better. It seems like matroskamux is not being considered during the caps negotiation so AVC conversion is not being forced.
Ideally, you want to figure out why this is happening. But you can simply force the conversion from byte-stream to AVC by placing a capsfilter element right after the h264parse and configure its caps property accordingly. For example:
... ! h264parse ! capsfilter caps="video/x-h264,stream-format=avc,alignment=au ! splitmuxsink
The output format of the h264parse is controlled via caps, not properties.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Michael Gruner |