Jetson Nano Gstreamer Multibitrate Transcoding

Hello evryone,
I am trying to transcode mpegts stream from web camera into multibitrate hls stream similar to youtube.
Since FFmpeg is not fully supported on jetson platform I am using Gstreamer. So far this is what I managed to put together:
gst-launch-1.0 souphttpsrc location="http://192.168.0.22/mpegts" ! progressreport ! decodebin ! multiqueue ! nvvidconv ! deinterlace ! tee name=t ! queue ! "video/x-raw(memory:NVMM),width=1280,height=720" ! omxh264enc control-rate=1 bitrate=3000000 preset-level=3 profile=8 ! video/x-h264 ! h264parse ! mpegtsmux ! hlssink location="720-%05d.ts" playlist-location="720.m3u8" t. ! queue ! "video/x-raw(memory:NVMM),width=1280,height=720" ! omxh264enc control-rate=1 bitrate=1500000 preset-level=3 profile=8 ! video/x-h264 ! h264parse ! mpegtsmux ! hlssink location="360-%05d.ts" playlist-location="360.m3u8"

This snippet takes mpegts stream, deinterlaces it and encodes into two different bitrates. All would be good, but as you have probably already noticed size of the image is same for both outputs (1280x720) and if changed to be different it stops working. Snippet can be modified to produce any resolution only as long as both are the same. If I set second output to 640 by 360 script throws following errors repeated multiple times:

(gst-launch-1.0:24465): GStreamer-CRITICAL **: 18:24:52.672: gst_mini_object_copy: assertion 'mini_object != NULL' failed

(gst-launch-1.0:24465): GStreamer-CRITICAL **: 18:24:52.673: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(gst-launch-1.0:24465): GStreamer-CRITICAL **: 18:24:52.673: gst_structure_copy: assertion 'structure != NULL' failed

(gst-launch-1.0:24465): GStreamer-CRITICAL **: 18:24:52.673: gst_caps_append_structure_full: assertion 'GST_IS_CAPS (caps)' failed

Any help is highly appreciated.

Hi,
We are deprecating omx plugins. Please use v4l2 plugins like nvv4l2h264enc.
And you may break down the pipeline to see which plugin triggers the error.

After a long process of trial and error I have finally managed to achieve multibitrate transcoding. The final code is:

gst-launch-1.0 souphttpsrc location="http://192.168.0.22/mpegts" ! progressreport ! decodebin name=demux \
demux. ! audioconvert ! voaacenc bitrate=128000 ! queue ! tee name=audio ! queue ! mux1. \
demux. ! deinterlace ! tee name=video ! \
    queue ! nvvidconv ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420" ! nvv4l2h264enc maxperf-enable=1 bitrate=8000000 ! h264parse ! mux1. \
    mpegtsmux name=mux1 ! hlssink location="1080-%05d.ts" playlist-location="1080.m3u8" max-files=7 target-duration=10 audio. ! queue ! mux2. \
video. ! \
    queue ! nvvidconv ! "video/x-raw(memory:NVMM),width=1280,height=720,format=I420" ! nvv4l2h264enc maxperf-enable=1 bitrate=4000000 ! h264parse ! mux2. \
    mpegtsmux name=mux2 ! hlssink location="720-%05d.ts" playlist-location="720.m3u8" max-files=7 target-duration=10 audio. ! queue ! mux3. \
video. ! \
    queue ! nvvidconv ! "video/x-raw(memory:NVMM),width=640,height=360,format=I420" ! nvv4l2h264enc maxperf-enable=1 bitrate=1000000 ! h264parse ! mux3. \
    mpegtsmux name=mux3 ! hlssink location="360-%05d.ts" playlist-location="360.m3u8" max-files=7 target-duration=10

I am using decodebin demuxer so this line should work with any input. If you have more than one video/audio track you can select track by adding src_<trackNumber> after demux. like so: demux.src_1

1 Like