Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Forked from flufy3d/gstreamer-tips.md
Created September 1, 2022 11:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinvanemden/3d5e9e756c40f243805670e53afbf670 to your computer and use it in GitHub Desktop.
Save robinvanemden/3d5e9e756c40f243805670e53afbf670 to your computer and use it in GitHub Desktop.
gstreamer remote streaming

simple test

gst-launch-1.0 -v videotestsrc ! video/x-raw,width=1280,height=640 ! glimagesink

streaming mpegts

gst-launch-1.0 -v videotestsrc ! video/x-raw,width=1280,height=640 ! videoconvert ! x264enc key-int-max=12 byte-stream=true ! mpegtsmux ! tcpserversink port=8888 host=0.0.0.0

vlc using tcp://192.168.1.192:8888

streaming self jpegenc

gst-launch-1.0 videotestsrc ! queue ! videoconvert ! video/x-raw,width=1280,height=480,framerate=30/1 ! jpegenc ! multipartmux ! tcpserversink host=192.168.11.59 port=7001

gst-launch-1.0 tcpclientsrc host=192.168.11.59 port=7001 ! multipartdemux ! jpegdec ! glimagesink

streaming windows desktop

gst-launch-1.0 dx9screencapsrc ! queue ! videoconvert ! jpegenc ! multipartmux ! tcpserversink port=7001

gst-launch-1.0 tcpclientsrc port=7001 ! multipartdemux ! jpegdec ! glimagesink

streaming windows camera

gst-launch-1.0 ksvideosrc do-stats=TRUE ! queue ! videoscale ! video/x-raw,width=1280,height=480,framerate=30/1 ! jpegenc quality=50 ! multipartmux ! tcpserversink host=192.168.11.59 port=7001

gst-launch-1.0 tcpclientsrc host=192.168.11.59 port=7001 ! multipartdemux ! jpegdec ! glimagesink

streaming h264

gst-launch-1.0 -v videotestsrc is-live=true ! video/x-raw,width=1280,height=480 ! queue ! videoconvert ! nvh264enc ! h264parse ! queue ! matroskamux ! queue leaky=2 ! tcpserversink port=7001 host=0.0.0.0 recover-policy=keyframe sync-method=latest-keyframe

gst-launch-1.0 tcpclientsrc host=192.168.11.59 port=7001 ! multipartdemux ! jpegdec ! glimagesink

auto decode

gst-launch-1.0 -v tcpclientsrc host=192.168.1.192 port=7001 ! decodebin ! autovideosink

hardware decode

gst-launch-1.0 tcpclientsrc host=192.168.1.192 port=7001 ! matroskademux ! h264parse ! nvh264dec ! glimagesink

gst-launch-1.0 tcpclientsrc host=192.168.1.192 port=7001 ! matroskademux ! h264parse ! d3d11h264dec ! glimagesink

software decode

gst-launch-1.0 tcpclientsrc host=192.168.1.192 port=7001 ! matroskademux ! h264parse ! openh264dec ! glimagesink

gst-launch-1.0 tcpclientsrc host=192.168.1.192 port=7001 ! matroskademux ! h264parse ! avdec_h264 ! glimagesink

hls streaming test

gst-launch-1.0 videotestsrc num-buffers=300 ! 'video/x-raw,width=1280,height=720' ! x264enc ! mpegtsmux ! hlssink

gst-launch-1.0 videotestsrc ! 'video/x-raw,width=1280,height=720' ! x264enc ! mpegtsmux ! hlssink

gst-launch-1.0 filesrc location=Raw.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h264parse ! mpegtsmux ! hlssink

merge audio and video

gst-launch-1.0 -e
autovideosrc ! queue ! videoconvert ! mkv.
autoaudiosrc ! queue ! audioconvert ! mkv.
matroskamux name=mkv ! filesink location=test.mkv sync=false

test render

gst-launch-1.0 -v videotestsrc ! video/x-raw,width=1280,height=640 ! glimagesink

debug

# Name Description
0 none No debug information is output.
1 ERROR Logs all fatal errors. These are errors that do not allow the
core or elements to perform the requested action. The
application can still recover if programmed to handle the
conditions that triggered the error.
2 WARNING Logs all warnings. Typically these are non-fatal, but
user-visible problems are expected to happen.
3 FIXME Logs all "fixme" messages. Those typically that a codepath that
is known to be incomplete has been triggered. It may work in
most cases, but may cause problems in specific instances.
4 INFO Logs all informational messages. These are typically used for
events in the system that only happen once, or are important
and rare enough to be logged at this level.
5 DEBUG Logs all debug messages. These are general debug messages for
events that happen only a limited number of times during an
object's lifetime; these include setup, teardown, change of
parameters, etc.
6 LOG Logs all log messages. These are messages for events that
happen repeatedly during an object's lifetime; these include
streaming and steady-state conditions. This is used for log
messages that happen on every buffer in an element for example.
7 TRACE Logs all trace messages. Those are message that happen very
very often. This is for example is each time the reference
count of a GstMiniObject, such as a GstBuffer or GstEvent, is
modified.
9 MEMDUMP Logs all memory dump messages. This is the heaviest logging and
may include dumping the content of blocks of memory.
+------------------------------------------------------------------------------+

export GST_DEBUG=azurekinectsrc:5 gst-launch-1.0 -v azurekinectsrc ! fakesink sync=false

export GST_DEBUG=azurekinectsrc:5 gst-launch-1.0 -v azurekinectsrc ! glimagesink sync=false

gst-launch-1.0 -v azurekinectsrc ! video/x-raw,width=1280,height=480 ! fakesink sync=false

export GST_DEBUG=videotestsrc:5 gst-launch-1.0 -v videotestsrc ! glimagesink sync=false

rtmp streaming

gst-launch-1.0 -v azurekinectsrc ! ffenc_flv ! flvmux ! rtmpsink location='rtmp://localhost/path/to/stream live=1'

tcp streaming

gst-launch-1.0 -v azurekinectsrc ! videoconvert ! x264enc key-int-max=12 byte-stream=true ! mpegtsmux ! tcpserversink port=8888 host=0.0.0.0

using nvidia hardware h264 acc

gst-launch-1.0 -v azurekinectsrc ! videoconvert ! omxh264enc ! mpegtsmux ! tcpserversink port=8888 host=0.0.0.0

play it in client

vlc using tcp://192.168.1.101:8888

hls streaming

gst-launch-1.0 azurekinectsrc ! videoconvert ! omxh264enc ! mpegtsmux ! hlssink

reduce latency

gst-launch-1.0 azurekinectsrc ! videoconvert ! omxh264enc ! mpegtsmux ! hlssink target-duration=2

gst-launch-1.0 azurekinectsrc ! videoconvert ! omxh264enc ! h264parse ! hlssink2 target-duration=1 playlist-length=4

tiny (if you don't want install webserver like nginx)

./tiny port

ramdis optimize

if you runing hls you can create a ramdisk for it

create folder

sudo mkdir -p /media/ramdisk

mount it

sudo mount -t tmpfs -o size=256M tmpfs /media/ramdisk

unmount it

sudo umount /media/ramdisk

auto mount when boot

sudo vim /etc/fstab none /media/ramdisk tmpfs nodev,nosuid,noexec,nodiratime,size=256M 0 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment