GStreamer H264 video and KLV mpegtsmux error

Hello guys! I need your help! I have a .ts video file that carries H264 video and KLV metadata stream. I need to demux the video, overlay an image on video and create a new .ts file with it and the same KLV stream.
I’ve tried different approaches using GStreamer without success. The following pipeline is the simplest version I’ve tried:

gst-launch-1.0 -t -v --gst-debug=3 filesrc location=/home/ubuntu/videoTeste.ts ! tsdemux name=demux demux. ! h264parse ! “video/x-h264” ! avdec_h264 ! x264enc bitrate = 10000 ! video/x-h264, profile=baseline ! queue ! mpegtsmux name=encod encod. ! filesink location=/home/ubuntu/teste.ts async=false demux. ! “meta/x-klv” ! queue ! encod.

This is the output:A definir pipeline para PAUSA …
0:00:00.053580180 19705 0x5647f4e61c00 WARN basesrc gstbasesrc.c:3600:gst_base_src_start_complete: pad not activated yet
Pipeline é PREROLLED …
A definir pipeline para REPRODUZIR …
New clock: GstSystemClock
/GstCapsFilter:capsfilter3: caps = meta/x-klv
/GstPipeline:pipeline0/GstCapsFilter:capsfilter4: caps = meta/x-klv
/GstPipeline:pipeline0/GstCapsFilter:capsfilter4.GstPad:src: caps = meta/x-klv, parsed=(boolean)true
/GstPipeline:pipeline0/GstQueue:queue1.GstPad:sink: caps = meta/x-klv, parsed=(boolean)true
/GstPipeline:pipeline0/GstQueue:queue1.GstPad:src: caps = meta/x-klv, parsed=(boolean)true
/GstPipeline:pipeline0/MpegTsMux:encod.GstPad:sink_66: caps = meta/x-klv, parsed=(boolean)true

(gst-launch-1.0:19705): GStreamer-CRITICAL **: 11:56:27.551: gst_segment_to_running_time: assertion ‘segment->format == format’ failed
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)nal
0:00:00.054452886 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 15508 will be dropped
0:00:00.054506922 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 24322 will be dropped
0:00:00.054553198 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 21270 will be dropped
0:00:00.054591203 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 26579 will be dropped
0:00:00.054630071 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25436 will be dropped
0:00:00.054663925 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25557 will be dropped
0:00:00.054697735 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25598 will be dropped
0:00:00.054734388 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25866 will be dropped
0:00:00.054768227 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25782 will be dropped
0:00:00.054805325 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 26169 will be dropped
0:00:00.054838313 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25996 will be dropped
0:00:00.054875026 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25735 will be dropped
0:00:00.054908194 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25991 will be dropped
0:00:00.054940617 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 26233 will be dropped
0:00:00.054974736 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 19915 will be dropped
0:00:00.055007396 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 26268 will be dropped
0:00:00.055037714 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 19609 will be dropped
0:00:00.055069936 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 26015 will be dropped
0:00:00.055103250 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 19613 will be dropped
0:00:00.055135263 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25920 will be dropped
0:00:00.055164929 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 19735 will be dropped
0:00:00.055197066 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25851 will be dropped
0:00:00.055235518 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 19638 will be dropped
0:00:00.055268897 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 19733 will be dropped
0:00:00.055301416 19705 0x5647f4dfcea0 WARN h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame: broken/invalid nal Type: 1 Slice, Size: 25492 will be dropped

Seems to be a sync problem between the H264 frames and the KLV chunks, I think…
I’ve tried changing the place of the queues, using a “tee” after filesrc and using separated demux, multiqueue…
I’m able to create a .ts file with H264 video only and I’m also able to extract and save to a file the KLV data. I’m even able to do this in the same pipeline:

gst-launch-1.0 -t -v --gst-debug=0 filesrc location=/home/ubuntu/videoTeste.ts ! tee name=t t. ! queue ! tsdemux name=demux demux. ! h264parse ! “video/x-h264” ! avdec_h264 ! x264enc bitrate = 10000 ! video/x-h264, profile=baseline ! mpegtsmux name=encod encod. ! filesink location=/home/ubuntu/teste.ts async=false t. ! queue ! tsdemux ! “meta/x-klv” ! filesink location=/home/ubuntu/klv.dat async=false

Do you have any suggestions to solve this?

Thank you!

Sorry for the late response, have you managed to get issue resolved? Thanks

Hi,
By default hardware decoder only processes compressed stream. This is metadata and would need 3rdparty software stacks to handle it. Please check if information in this website helps:
https://developer.ridgerun.com/wiki/index.php?title=GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream/MPEG_TS_Metadata_Basics#KLV_-_Key_Length_Value_Metadata
You may contact RidgeRun for further help.

Hello DaneLLL,
Thank you. Is a 3rdparty software needed even when the original .TS file has the KLV metadata? Resuming, the loaded .TS file has the video (No audio) and KLV metadata. After the tsdemux I can get both channels. Do I still need a “dedicated” pipeline module to process the KLV metadata somehow before sending it to mpegtsmux?

Hi,
We don’t have experience about KLV metadata. Would suggest contact RidgeRun for further support.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.