GStreamer

Índex

General

Instal·lació / Installation

  • Instal·lació / Installation
    • From packages
      • Mageia
        • urpmi  ... gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-x264
    • Compilació des de codi font / Compilation from source
      • Dependencies

        • Mageia CentOS Ubuntu

          urpmi ...
          yum install ...
          apt-get install ...
          general
          autoconf gettext-devel libtool bison flex gtk-doc yasm autoconf gettext-devel libtool bison flex gtk-doc yasm glib2-devel gcc-c++ autoconf bison flex ...
          plugins-base
          lib64opus-devel libvorbis-devel libogg-devel libtheora-devel libxv-devel libsoup-devel opus-devel libvorbis-devel libogg-devel libtheora-devel libxv-devel pango-devel libopus-dev libvorbis-dev libogg-dev libtheora-dev libxv-dev libpango1.0-dev
          plugins-good
          libvpx-devel libvpx-devel libvpx-dev
          plugins-bad
          librtmp-devel librtmp-devel librtmp-dev
          plugins-ugly
          libx264-devel libx264-devel libx264-dev

        • Mageia
          • urpmi autoconf gettext-devel libtool bison flex gtk-doc yasm
          • For plugins-base:
            • urpmi lib64opus-devel lib64vorbis-devel lib64ogg-devel lib64theora-devel lib64xv-devel libsoup-devel
        • Raspbian
          • ...
        • CentOS
          • automake >=1.14 (CentOS 7 provides version 1.13)
          • yum install -y autoconf gettext-devel libtool bison flex gtk-doc yasm glib2-devel gcc-c++
          • plugins-base
            • yum install opus-devel libvorbis-devel libogg-devel libtheora-devel libxv-devel pango-devel
          • plugins-good
            • yum install libvpx-devel
          • plugins-bad
            • yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
            • yum -y install librtmp-devel
          • plugins-ugly
            • yum install libx264-devel
      • From git
      • From tar files
        • https://gstreamer.freedesktop.org/src/
        • if you want to use PyGObject (e.g. from Python):
          • Dependencies
            • Mageia
              • urpmi lib64girepository-devel
            • CentOS
              • sudo yum install gobject-introspection-devel
          • Check config.log
            • HAVE_INTROSPECTION_TRUE=''
              INTROSPECTION_COMPILER='/usr/bin/g-ir-compiler'
              ...

          • Check that this file exists after compilation:
            • /usr/local/lib/girepository-1.0/Gst*.typelib
          • You will need to set environment variable:
            • export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0
        • gstreamer_install.sh 1.13.91
        • gstreamer_install.sh
          • #!/bin/bash

            EXPECTED_ARGS=1
            if (( $# != $EXPECTED_ARGS ))
            then
                cat <<EOF
            Usage: `basename $0` version

            Examples:
            - `basename $0` 1.13.91
            EOF
                exit 1
            fi

            modules="gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav gstreamer-editing-services"
            version=$1

            mkdir gst-${version}
            cd gst-${version}


            for module in $modules
            do
                src_name="${module}-${version}"
                echo "-- $src_name"
                tar_filename="${src_name}.tar.xz"
                #curl -s -L -O https://gstreamer.freedesktop.org/src/${module}/${tar_filename}
                if ! wget https://gstreamer.freedesktop.org/src/${module}/${tar_filename}
                then
                    echo "ERROR: could not find version ${version}"
                    exit 1
                fi

                tar xJf ${tar_filename}
                cd ${src_name}
                ./autogen.sh PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
                make
                sudo make install
                cd ..
            done

            # update ldconfig
            sudo
            sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf'
            sudo ldconfig

            exit 0
        • gstreamer will be installed in:
          • /usr/local/lib/gstreamer-1.0/
      • Problemes / Problems
        • Opus audio encoder not found
          • gst-plugins-bad/ext/opus/opusenc.c was present until version 1.6; then it was moved to plugins-base
          • Solució / Solution
            • install system-wide Opus devel libraries and reconfigure and make plugins-base

Ús / Usage

  • ...
    • Ús / Usage
    • Tools (CLI)
      • How do I use the GStreamer command line interface ?
      • ges-launch
        • ...
      • gst-discoverer
      • gst-inspect:
        • list of all plug-ins
          • gst-inspect-1.0
        • available properties for a specified plugin
          • gst-inspect-1.0 videoconvert
          • ...
        • ...
      • gst-launch (wp)
        • gst-launch-1.0 ... ! ... ! ...
        • gst-launch-1.0 ... ! ... ! ...demux name=mydemux ...mux name=mymux ! ... ! ... mydemux. ! ... ! mymux. mydemux. ! ... ! mymux.
          • input + demux
          • mux + output
          • audio
          • video
        • Options
          • -e: end of stream on shutdown
          • -f, --no_fault : ...
          • --help : ...
          • -q, --quiet : ...
          • -m, --messages :  ...
          • -o FILE, --output=FILE : ...
          • -t, --tags : ...
          • -T, --trace : ...
          • -v: verbose : ...
          • --gst-debug-level=2
        • Verbose messages (-v)
          • /<element>:<name>/<element>:<name>.<subelement>:<name>: <property>=<value>, <property>=<value> ...
          • gst_format_logs.sh
            • #!/bin/bash
              input_path=$1
              awk -F'\\\\ ' 'BEGIN {OFS="\n";ORS="\n\n"} $1 ~ /^\/GstPipeline/ {$1=$1;print $0}' ${input_path}
              exit 0
        • Debug
          • Debugging tools
          • export GST_DEBUG=1 # default
          • export GST_DEBUG="*:2"
          • export GST_DEBUG=WARN,udpsrc:INFO,videodecoder:DEBUG
          • export GST_DEBUG=3,rtpjitterbuffer:3,rtpbasedepayload:6,videodecoder:4
          • number
            name
            1
            ERROR
            2
            WARNING
            3
            FIXME
            4
            INFO
            5
            DEBUG
            6
            LOG
            7
            TRACE
            8

            9
            MEMDUMP
            • Gstreamer pipeline diagram
              • How to generate a Gstreamer pipeline diagram (graph)
              • Dependencies
                • Mageia
                  • urpmi graphviz
              • Utilització / Usage
                • mkdir /tmp/dots
                • export GST_DEBUG_DUMP_DOT_DIR=/tmp/dots
                • gst-launch ...
                • cd /tmp/dots
                • to generate svg:
                  • dot -Tsvg ...-gst-launch...PLAYING....dot >pipeline.svg
                  • gwenview pipeline.svg
                • to generate png:
                  • dot -Tpng ...-gst-launch...PLAYING....dot >pipeline.png
                  • gwenview pipeline.png
          • Sintaxi / Syntax
            • element:
              ELEMENTTYPE [PROPERTY1 ...]
              elements can be put into bins:
              [BINTYPE.] ( [PROPERTY1 ...] PIPELINE-DESCRIPTION )
              property:
              NAME=*[(TYPE)]*VALUE in lists and ranges: *[(TYPE)]*VALUE
              • range: [VALUE,VALUE]
              • list: {VALUE[,VALUE...]}
              type:
              • -i int
              • -f float
              • -4 fourcc
              • -b bool boolean
              • -s str string
              • -fraction
              link:
              [[SRCELEMENT].[PAD1,...]] ! [[SINKELEMENT].[PAD1,...]] [[SRCELEMENT].[PAD1,...]] ! CAPS ! [[SINKELEMENT].[PAD1,...]]
              caps:
              MIMETYPE [, PROPERTY[, PROPERTY ...]]] [; CAPS[; CAPS ...]]
            • input
              demuxer
              decoder
              filter
              encoder muxer

              demux
              buffer
              parse
              (to get specific packets from demuxer)
              decode
              filter
              encode codec parameters
              (CAPS)
              parse
              (to prepare specific packets for muxer)
              mux
              output
              file
              • filesrc location=videofile
              • uri=file:///path/to/test.ts
              devices
              • dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 pids=111:112
              network
              unix
              decodebin name=decoder
              (does not include sdpdemux)
              • corresponding parameters (caps) can be grouped, but must appear after filter declaration (except videoconvert: videoconvert ! <caps> ! videoconvert)
              • if a value in caps must be used, the corresponding filter must be present. If the value in caps is not used, because the input already has this value, the filter is not needed


              filter
              description
              mimetype, comma separated key=value
              video

              video/x-raw
              videoscale
              width=360 height=288
              pixel-aspect-ratio=1/1
              videorate
              framerate=25/1
              videoconvert
              format=BGRA
              ?

              interlace-mode=progressive
              audio


              audio/x-raw
              audiorate
              Drops/duplicates/adjusts timestamps on audio samples to make a perfect stream
              tolerance=...
              ...
              audioresample
              Resamples audio
              rate=48000
              audioconvert Convert audio to different formats
              format=S16LE
              channels=2
              layout=interleaved

              • video
                • video/x-h264,
                  profile=baseline
              • video
                • h264parse
              • audio
              • mpegtsmux name=mux
              • flvmux  streamable=true name=mux
              • mp4mux faststart=true
              file
              • filesink location=music.ogg
              devices
              network
              • udpsink host=192.168.0.8 port=5004 sync=false
              • rtmpsink location=rtmp://rtmp_server:1935/app/stream
              unix
              • fdsink
              • shmsink socket-path=...
                shm-size=...
                wait-for-connection=...
              demux
              specific stream (source Element Pads)

              • demux.
              matroskademux
              • demux.audio_%u
              • demux.video_%u
              • demux.subtitle_%u
              qtdemux name=demux
              • demux.video_0
              • demux.audio_0
              • demux.audio_1
              • ...
              sdpdemux name=demux
              • demux.stream_0
              • demux.stream_1
              • ...
              tsdemux program-number=805 name=demux
              flvdemux name=demux
              • audio
              • video
              ...


              • video
                • mpegvideoparse
                • h264parse
              • audio
                • mpegaudioparse
                • aacparse
              • decodebin
              • video
                • omxmpeg2videodec
                • omxh264dec
              • audio
                • avdec_mpeg2video





              • video
                • video/x-raw, framerate=25/1, width=640, height=360,
                • if format is specified, videoconvert must be specified after it
                  • format=...,
                    ...
              • audio
                • audio/x-raw,
                  format=...,
                  layout=...,
                  rate=...,
                  channels=...

          • sdpdemux

            rtpbin
            udpsrc
            rtpsession
            rtpssrcdemux
            rtpjitterbuffer
            rtpptdemux

          • Sources and sinks
            • GstBaseSrc
              • do-timestamp
                • it has to be specified at source if we want lipsync at the output: sync=true
            • GstBaseSink
              • async
              • sync
                • the source must be specified with do-timestamp=true
            • fd (file descriptor) (see Snowmix audio)
            • shm (shared memory) (see Snowmix video)
              • shmsink
                • gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=25/1,width=640,height=480,format=BGRA ! videoconvert ! shmsink socket-path=/tmp/feed1 shm-size=`echo 640*480*4*22 | bc` wait-for-connection=0
                • gst-launch-1.0 -v videotestsrc is-live=true do-timestamp=true ! video/x-raw,framerate=25/1,width=640,height=480,format=BGRA ! videoconvert ! clockoverlay halignment=right valignment=top shaded-background=true font-desc="Sans, 24" ! shmsink socket-path=/tmp/feed1 shm-size=`echo 640*480*4*22 | bc` wait-for-connection=1 sync=true
                • gst-launch-1.0 filesrc location=sintel_timecode_640x272_44100_stereo.mp4 ! qtdemux name=demux demux. ! decodebin ! videoconvert ! videoscale ! videorate ! video/x-raw,width=320,height=136,format=BGRA ! shmsink socket-path=/tmp/feed1 shm-size=`echo 320*136*4*22 | bc -l` wait-for-connection=1 sync=true
              • shmsrc
                • you must specify: width, height, framerate, format+videoconvert, and they shoud match values specified in shmsink
                • gst-launch-1.0 -v shmsrc socket-path=/tmp/feed1 do-timestamp=true is-live=true ! video/x-raw,width=640,height=480,framerate='24/1',format=BGRA ! videoconvert ! autovideosink
                • to play at a framerate different from the input, specify a different framerate and add videorate
              • du -h /dev/shm
              • ls -l /dev/shm
              • netstat -pena --unix
            • shm (video) + fd (audio)
              • transmission
                • ...
              • reception
                • ...
          • Demux
            • sdpdemux
              • Play from SDP file
              • Includes
              • Parameters
                • latency (ms)
                  • INFO         rtpjitterbuffer gstrtpjitterbuffer.c:3942:do_deadline_timeout:<rtpjitterbuffer0> got deadline timeout
          • Codecs
          • Bins
          • Play
            • general: using playbin
              • gst-launch-1.0 -v playbin uri=...
            • from testsrc
              • videotestsrc
                • gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=25/1,width=1280,height=720 ! autovideosink
                • gst-launch-1.0 -v videotestsrc pattern=snow ! video/x-raw,framerate=12/1,width=1280,height=720 ! autovideosink
                • gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=12/1,width=1280,height=720,format=BGRA ! videoconvert ! autovideosink
                • clock overlay
                  • gst-launch-1.0 -v videotestsrc is-live=true ! clockoverlay halignment=right valignment=top shaded-background=true font-desc="Sans, 24" ! autovideosink
                • time overlay
                  • gst-launch-1.0 -v videotestsrc is-live=true ! timecodestamper ! timeoverlay shaded-background=true 'time-mode=time-code'  font-desc="Sans, 24" ! autovideosink
                  • gst-launch-1.0 -v videotestsrc is-live=true ! video/x-raw, framerate=25/1, width=640, height=360 ! timecodestamper ! timeoverlay halignment=right valignment=bottom text="Stream time:" shaded-background=true font-desc="Sans, 24" ! autovideosink
                • clock + time overlay
                  • gst-launch-1.0 -v videotestsrc is-live=true ! video/x-raw, framerate=25/1, width=640, height=360 ! timecodestamper ! timeoverlay halignment=left valignment=top shaded-background=true font-desc="Sans, 24" ! clockoverlay halignment=right valignment=top shaded-background=true font-desc="Sans, 24" ! autovideosink
              • audiotestsrc
                • gst-launch-1.0 -v audiotestsrc ! autoaudiosink
                • white noise (wave=5), stereo (channels=2)
                  • gst-launch-1.0 -v audiotestsrc is-live=true wave=5 ! 'audio/x-raw,format=S16LE,layout=interleaved,rate=48000,channels=2' ! autoaudiosink
              • test video + audio
                • gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=25/1,width=1280,height=720 ! autovideosink audiotestsrc ! autoaudiosink
            • from DVB device
              • only video from DVB device (mpegvideoparse is needed because if not, maybe teletext is taken; and error is shown):
                • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0  ! tsdemux program-number=805 ! queue ! mpegvideoparse ! decodebin ! autovideosink
              • only audio:
                • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0  ! tsdemux program-number=805 ! queue ! mpegaudioparse ! decodebin ! autoaudiosink
                • gst-launch-1.0 dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux demux. ! queue ! mpegaudioparse ! decodebin ! omxanalogaudiosink
              • audio and video from program 805 in DVB input:
                • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=805 name="demux" \
                  demux. ! queue ! mpegaudioparse ! decodebin ! autoaudiosink \
                  demux. ! queue ! mpegvideoparse ! decodebin ! autovideosink
            • from file
              • gst-launch-1.0 -v playbin uri=file:/absoulte/path/to/your_video_file
              • MP4
                • gst-launch-1.0 -v playbinuri=file:/absoulte/path/to/toto.mp4
                • audio and video from an MP4 file (queue is needed when playin audio and video)
                  • gst-launch-1.0 filesrc location=sintel-1024-stereo.mp4 ! qtdemux name=demux \
                    demux. ! queue ! decodebin ! autovideosink \
                    demux. ! queue ! decodebin ! autoaudiosink
                     
                • rescale an anamorphic video
                  • gst-launch-1.0 filesrc location=toto_720x576_anamorphic.mp4 ! qtdemux name=demux demux. ! queue ! decodebin ! videoscale ! video/x-raw,width=176,height=140,pixel-aspect-ratio=64/45 ! autovideosink
                • only audio from an MP4 file
                  • gst-launch-1.0 filesrc location=sintel-1024-stereo.mp4 ! qtdemux name=demux \
                    demux.audio_0 ! decodebin ! autoaudiosink
              • TS
                • program in a TS file (first program found?):
                  • gst-launch-1.0 -v playbinuri=file:/tmp/toto.ts
                • only video from TS file (program_number=802)
                  • gst-launch-1.0 -v filesrc location=/disc/videos/tvc/tvc_794_20140821_1709.ts ! tsdemux program-number=802 ! mpegvideoparse ! decodebin ! autovideosink
              • OGG
                • audio and video from an OGG file (queue is needed when playin audio and video)
                  • gst-launch-1.0 filesrc location=sintel_trailer-720p.ogv ! oggdemux name=demux \
                    demux. ! queue ! decodebin ! autovideosink \
                    demux. ! queue ! decodebin ! autoaudiosink
              • WebM / Matroska
                • gst-launch-1.0 -v playbin uri=file:/absoulte/path/to/toto.webm
                • playbinaudio and video from a webm file:
                  • gst-launch-1.0 -v \
                    filesrc location=/path/to/toto.webm ! matroskademux name=demux \
                    demux.video_0 ! queue ! decodebin ! autovideosink sync=true \
                    demux.audio_0 ! queue ! decodebin ! autoaudiosink sync=true

                  • gst-launch-1.0 -v \
                    filesrc location=/path/to/toto.webm ! matroskademux name=demux \
                    demux. ! queue ! vp8dec ! autovideosink sync=true \
                    demux. ! queue ! opusdec ! autoaudiosink sync=true
              • SDP
                • See also: play from RTP
                • sdpdemux
                • UDP buffer
                  • value is taken from kernel parameter net.core.rmem_default
                  • GST_DEBUG=3,udpsrc:4 gst-launch filesrc location=toto.sdp ! sdpdemux name=demux ...
                    • udpsrc gstudpsrc.c:1428:gst_udpsrc_open:<udpsrc0> have udp buffer of 212992 bytes
                • audio and video from SDP file (RTP):
                  • gst-launch-1.0 filesrc location=toto.sdp do-timestamp=true ! sdpdemux latency=1000 debug=true name=demux \
                    demux. ! "application/x-rtp, media=(string)video" ! decodebin ! autovideosink sync=true \
                    demux. ! "application/x-rtp, media=(string)audio" ! decodebin ! autoaudiosink sync=true

                  • # RTP + RTCP, using sdpdemux
                    gst-launch-1.0 \
                          filesrc location=$sdp_path do-timestamp=true ! sdpdemux latency=${sdpdemux_latency_ms} name=demux \
                          demux. ! "application/x-rtp, media=(string)video" ! queue ! decodebin ! videoconvert ! videoscale ! videorate ! autovideosink sync=true \
                          demux. ! "application/x-rtp, media=(string)audio" ! queue ! decodebin ! audioconvert ! audioresample ! audiorate ! autoaudiosink sync=true

                  • H.264 + AAC
                    • gst-launch-1.0 filesrc location=toto.sdp do-timestamp=true ! sdpdemux name=demux \
                      demux. ! queue ! rtph264depay ! decodebin ! autovideosink sync=true \
                      demux. ! queue ! rtpmp4gdepay ! decodebin ! autoaudiosink sync=true

                • only video from SDP file (RTP). Make sure that video is the first stream specified in sdp file:
                  • gst-launch-1.0 filesrc location=toto.sdp ! sdpdemux name=demux \
                    demux.stream_0 ! queue ! decodebin ! autovideosink
                • only audio from SDP file (RTP). Make sure that audio is the second stream specified in sdp file:
                  • gst-launch-1.0 filesrc location=toto.sdp ! sdpdemux name=demux \
                    demux.stream_1 ! queue ! decodebin ! autoaudiosink
                • Problemes / Problems
                  • Pèrdua de paquets / Packet loss
                  • Manca de fluïdesa / Lack of smoothness
                    • videodecoder gstvideodecoder.c:2775:gst_video_decoder_prepare_finish_frame:<avdec_h264-0> decreasing timestamp (0:00:00.008558259 < 0:00:00.058900688)
                      • Solució / Solution
                        • Increase latency parameter (default: 200 ms) for sdpdemux:
                        • gst-launch-1.0 filesrc location=toto.sdp ! sdpdemux latency=400 name=demux ...
                    • audiobasesink gstaudiobasesink.c:1787:gst_audio_base_sink_get_alignment:<autoaudiosink0-actual-sink-alsa> Unexpected discontinuity in audio timestamps of +0:00:00.131360544, resyncing
                      • Solució / Solution
                        • ...
                  • “delayed linking failed”
                  • lipsync
            • from network
              • RTP
                • See also: Play from SDP file
                • Problemes / Problems
                  • udpsrc
                    • videodecoder gstvideodecoder.c:2775:gst_video_decoder_prepare_finish_frame:<avdec_h264-0> decreasing timestamp (0:00:45.183879818 < 0:00:45.188331700)
                • gst-launch-1.0 udpsrc address=127.0.0.1 port=5004 ! "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, profile-level-id=(string)64001f, payload=(int)96" ! queue ! \
                  rtph264depay ! decodebin ! autovideosink
                • gst-launch-1.0 -v \
                      udpsrc address=${address} port=${video_port} do-timestamp=true ! queue ! "application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, sprop-parameter-sets=(string)\"Z2QAHqzZQKAv+XARAAADAAEAAAMAPA8WLZY\=\,aOvssiw\=\", profile-level-id=(string)64001E" ! rtph264depay ! decodebin ! autovideosink sync=true \
                      udpsrc address=${address} port=${audio_port} do-timestamp=true ! queue ! "application/x-rtp, media=(string)audio, payload=(int)97, clock-rate=(int)44100, encoding-name=(string)MPEG4-GENERIC, encoding-params=(string)2, profile-level-id=(string)1, mode=(string)AAC-hbr, sizelength=(string)13, indexlength=(string)3, indexdeltalength=(string)3, config=(string)121056E500" ! rtpmp4gdepay ! decodebin ! autoaudiosink sync=true
                  • caps can be obtained e.g. by executing: gst-launch -v ... sdpdemux ...
                • common variables:
                  • # ffmpeg -re -i easylife.mp4 -c:v copy -an -f rtp rtp://234.1.2.3:5004 -vn -c:audio copy -f rtp rtp://234.1.2.3:5006 -sdp_file /mnt/nfs/sdp/toto.sdp

                    address=234.1.2.3

                    video_rtp_port=5004
                    video_rtcp_port=$(( video_rtp_port + 1 ))
                    VIDEOCAPS="application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, sprop-parameter-sets=(string)\"Z2QAHqzZQKAv+XARAAADAAEAAAMAPA8WLZY\=\,aOvssiw\=\", profile-level-id=(string)64001E"

                    audio_rtp_port=$(( video_rtp_port + 2 ))
                    audio_rtcp_port=$(( video_rtp_port + 3 ))
                    AUDIOCAPS="application/x-rtp, media=(string)audio, payload=(int)97, clock-rate=(int)44100, encoding-name=(string)MPEG4-GENERIC, encoding-params=(string)2, profile-level-id=(string)1, mode=(string)AAC-hbr, sizelength=(string)13, indexlength=(string)3, indexdeltalength=(string)3, config=(string)121056E500"
                • RTP
                  • # RTP
                    gst-launch-1.0 \
                        udpsrc address=${address} port=${video_rtp_port} do-timestamp=true ! "$VIDEOCAPS" ! \
                        rtph264depay ! queue ! decodebin ! autovideosink sync=true \
                        udpsrc address=${address} port=${audio_rtp_port} do-timestamp=true ! "$AUDIOCAPS" ! \
                        rtpmp4gdepay ! queue ! decodebin ! autoaudiosink sync=true

                • RTP (using rtpbin)
                  • # RTP, using rtpbin
                    gst-launch-1.0 \
                        rtpbin name=bin \
                        udpsrc address=${address} port=${video_rtp_port} do-timestamp=true ! "$VIDEOCAPS" ! bin.recv_rtp_sink_0 \
                        bin. ! rtph264depay ! queue ! decodebin ! autovideosink sync=true \
                        udpsrc address=${address} port=${audio_rtp_port} do-timestamp=true ! "$AUDIOCAPS" ! bin.recv_rtp_sink_1 \
                        bin. ! rtpmp4gdepay ! queue ! decodebin ! autoaudiosink sync=true

                • RTP with RTCP (using rtpbin)
                  • # RTP + RTCP, using rtpbin
                    gst-launch-1.0 \
                        rtpbin name=bin \
                        udpsrc address=${address} port=${video_rtp_port} do-timestamp=true ! "$VIDEOCAPS" ! bin.recv_rtp_sink_0 \
                        bin. ! rtph264depay ! queue ! decodebin ! autovideosink sync=true \
                        udpsrc address=${address} port=${video_rtcp_port} ! "application/x-rtcp" ! bin.recv_rtcp_sink_0 \
                        udpsrc address=${address} port=${audio_rtp_port} do-timestamp=true ! "$AUDIOCAPS" ! bin.recv_rtp_sink_1 \
                        bin. ! rtpmp4gdepay ! queue ! decodebin ! autoaudiosink sync=true \
                        udpsrc address=${address} port=${audio_rtcp_port} ! "application/x-rtcp" ! bin.recv_rtcp_sink_1
                • Problemes / Problems
                  • lipsync
                    • source: specify do-timestamp=true
                    • sinks: specify sync=true
                    • sdpdemux: latency must be big enough. If stream has B images, try with latency=1000
                    • check that RTP flow contains RTCP packets with "Source Description" (SDES) information
              • HTTP
                • check that souphttpsrc is present
                  • gst-inspect-1.0 | grep souphttpsrc
                • if not present, compile it
                  • Dependencies
                    • CentOS
                      • sudo yum install libsoup-devel
                    • Mageia
                      • urpmi libsoup-devel
                  • gst-plugins-good
                    • ./configure
                    • make
                    • sudo make install
                • gst-launch-1.0 playbin uri=http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4
              • RTMP
                • gst-launch-1.0 -v playbin uri=rtmp://nginx-server/myapp/mystream
                • gst-launch-1.0 -v \
                                    rtmpsrc location=${source} do-timestamp=true ! queue2 ! decodebin name=mydecoder \
                                    mydecoder. ! autovideosink sync=true \
                                    mydecoder. ! autoaudiosink sync=true

                • (not working?) source=rtmp://nginx-server/myapp/mystream
                  gst-launch-1.0 \
                      rtmpsrc location=${source} do-timestamp=true ! flvdemux name=demux \
                      demux.video ! queue ! decodebin ! autovideosink sync=true \
                      demux.audio ! queue ! decodebin ! autoaudiosink sync=true

          • Mux to
            • test to TS
              • gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=24/1,width=1280,height=720 ! videoconvert ! x264enc ! video/x-h264,profile=high ! mpegtsmux ! filesink location=toto.ts
            • test to MP4
              • NOTE: stream-format=(string)byte-stream is not supported by MP4
              • gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=24/1,width=1280,height=720 ! videoconvert ! x264enc ! video/x-h264,profile=high ! mp4mux ! filesink location=toto.mp4
                • Problem:
                  • moov atom not found
                    • Solution
                      • (?) mp4mux faststart=true
          • Transmux
            • only video (mp4 -> ts):
              • gst-launch-1.0 filesrc location=sintel-1024-stereo.mp4 ! qtdemux name=demux \
                mpegtsmux name=mux ! filesink location=toto.ts \
                demux. ! queue ! h264parse ! mux.
              • gst-launch-1.0 filesrc location=sintel-1024-stereo.mp4 ! qtdemux name=demux \
                mpegtsmux name=mux ! filesink location=toto.ts \
                demux. ! video/x-h264 ! queue ! h264parse ! mux.
            • video and audio (mp4 -> ts)
              • gst-launch-1.0 filesrc location=sintel-1024-stereo.mp4 ! qtdemux name=demux \
                mpegtsmux name=mux ! filesink location=toto2015.ts \
                demux. ! queue ! h264parse ! mux. \
                demux. ! queue ! aacparse ! mux.
            • video and audio (mp4 -> flv)
              • gst-launch-1.0 -v filesrc location=sintel-1024-stereo.mp4 ! qtdemux name=demux \
                flvmux streamable=true name=mux ! filesink location=toto.flv \
                demux. ! queue ! h264parse ! mux. \
                demux. ! queue ! aacparse ! mux.
                 
            • video and audio (flv ->mp4)
              • ...
            • video (H.264) (sdp -> ts)
              • gst-launch-1.0 -v filesrc location=toto.sdp ! sdpdemux name=demux \
                mpegtsmux name=mux ! filesink location=toto.ts \
                demux. ! queue ! rtph264depay ! mux.
            • video (H.264) and audio (AAC) (sdp -> ts)
              • gst-launch-1.0 -v filesrc location=toto.sdp ! sdpdemux name=demux \
                mpegtsmux name=mux ! filesink location=toto.ts \
                demux. ! queue ! rtph264depay ! mux. \
                demux. ! queue ! rtpmp4gdepay ! mux.
            • video (sdp->mp4) (not working)
              • gst-launch-1.0 filesrc location=/tmp/bbb.sdp ! sdpdemux name=demux \
                mp4mux name=mux ! filesink location=/tmp/toto.mp4 \
                demux. ! rtph264depay ! h264parse ! mux.

                • problem
                  • ffplay toto.mp4
                    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f128c0008c0] moov atom not found
                    toto.mp4: Invalid data found when processing input
                  • Solution?
                    • mp4mux faststart=true
            • video and audio (sdp -> mp4) (not working)
              • gst-launch-1.0 -v filesrc location=toto.sdp ! sdpdemux name=demux \
                mp4mux name=mux ! filesink location=toto.mp4 \
                demux. ! queue ! h264parse ! mux. \
                demux. ! queue ! aacparse ! mux.
          • Transcode
            • only video, to file:
              • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=805 name="demux" \
                demux. ! queue ! mpegvideoparse ! decodebin ! videoconvert ! x264enc ! video/x-h264,stream-format=byte-stream,profile=high ! h264parse ! \
                mpegtsmux ! filesink location=/tmp/toto.ts
            • and resize, stream:
              • gst-launch-1.0 -v filesrc location=tvc_20150604.ts ! tsdemux program-number=806 ! \
                mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc ! h264parse ! \
                mpegtsmux ! udpsink host=192.168.0.8 port=5004 sync=false
              • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 ! \
                mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc ! h264parse ! \
                mpegtsmux ! udpsink host=192.168.0.8 port=5004 sync=false

              • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=805 name="demux" \
                demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! 'video/x-raw, width=360, height=288' ! videoconvert ! x264enc ! video/x-h264,stream-format=byte-stream,profile=main ! h264parse ! \
                mpegtsmux ! udpsink host=192.168.0.8 port=5004 sync=false

          • Stream
            • Introduction to network streaming using GStreamer
            • TS over UDP
              • UDP unicast stream only audio:
                • gst-launch-1.0 dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                  demux. ! queue ! mpegaudioparse ! decodebin ! audioconvert ! lamemp3enc ! \
                  mpegtsmux ! udpsink host=192.168.0.8 port=5004 sync=false
                • gst-launch-1.0 dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                  demux. ! queue ! mpegaudioparse ! decodebin ! audioconvert ! lamemp3enc ! mux. \
                  mpegtsmux name=mux ! udpsink host=192.168.0.8 port=5004 sync=false
                • gst-launch-1.0 dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                  mpegtsmux name=mux ! udpsink host=192.168.0.8 port=5004 sync=false \
                  demux. ! queue ! mpegaudioparse ! decodebin ! audioconvert ! lamemp3enc ! mux.

              • Encode to H.264, mux to TS, UDP stream:
                • gst-launch-1.0 -e videotestsrc ! video/x-raw, framerate=25/1, width=640, height=360 ! x264enc ! \
                  mpegtsmux ! udpsink host=192.168.0.8 port=5004 sync=false

                • gst-launch-1.0 -v -e videotestsrc ! video/x-raw, framerate=25/1, width=640, height=360 ! x264enc bitrate=512 ! video/x-h264,profile=high ! h264parse ! \
                  mpegtsmux ! udpsink host=192.168.0.8 port=5004 sync=false
                • gst-launch-1.0 -e mpegtsmux name="muxer" ! udpsink host=192.168.0.8 port=5004 sync=false \
                  videotestsrc ! video/x-raw, framerate=25/1, width=640, height=360 ! x264enc bitrate=512 ! video/x-h264,profile=high ! h264parse ! muxer.

              • Mux video and audio, UDP stream:
                • gst-launch-1.0 -e mpegtsmux name="muxer" ! udpsink host=192.168.0.8 port=5004 sync=false \
                  videotestsrc ! video/x-raw, framerate=25/1, width=640, height=360 ! x264enc bitrate=512 ! video/x-h264,profile=high ! h264parse ! muxer. \
                  audiotestsrc wave=5 ! audioconvert ! lamemp3enc ! muxer.
                • gst-launch-1.0 dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                  mpegtsmux name=mux ! udpsink host=192.168.0.8 port=5004 sync=false \
                  demux. ! queue ! mpegaudioparse ! decodebin ! audioconvert ! lamemp3enc ! mux. \
                  demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=50 ! h264parse ! mux.
                • Notes:
                  • default for omxh264enc is inline-header=true
                  • specification of periodicty-idr is needed by vlc to be played
                  • these parameters are available on latest version of gstreamer. Maybe you need to compile  version 1.2.
            • to RTP
              • RTP and RTSP support
              • gstreamer/gst-plugins-good/gst/rtp/README
              • Streaming H.264 via RTP
              • Play from SDP file
              • SDP generation
              • gstreamer
                sdp file
                command
                gst-launch-1.0 -v videotestsrc ! videoconvert ! x264enc ! rtph264pay config-interval=10 pt=96 ! udpsink host=234.1.2.3 port=5004
                v=0
                m=<media> <port> RTP/AVP <payload>
                c=IN IP4 <host>
                a=rtpmap:<payload> <encoding-name>/<clock-rate>
                a=fmtp:96 packetization-mode=<packetization-mode>; sprop-parameter-sets=<sprop-parameter-sets>; profile-level-id=<profile-level-id>
                caps
                (given by -v)
                application/x-rtp,
                media=(string)video,
                clock-rate=(int)90000,
                encoding-name=(string)H264,
                packetization-mode=(string)1,
                profile-level-id=(string)f4000d,
                sprop-parameter-sets=(string)"Z/QADZGbKCg/YC1BgEFQAAADABAAAAMDyPFCmWA\=\,aOvsRIRA",
                payload=(int)96,
                ssrc=(uint)3934427744,
                timestamp-offset=(uint)2187273080,
                seqnum-offset=(uint)1602,
                a-framerate=(string)30


                media=(string)audio,
                ...


              • send
                receive

                from file

                common code
                input_path=$1

                sdp_path=/tmp/toto.sdp
                dst_address=234.1.2.3

                video_rtp_port=5004
                video_rtcp_port=$(( video_rtp_port + 1 ))
                video_media_subtype="H264"
                rtp_video_payload_type=96

                audio_rtp_port=$(( video_rtp_port + 2 ))
                audio_rtcp_port=$(( video_rtp_port + 3 ))
                audio_media_subtype="aac"
                rtp_audio_payload_type=$(( rtp_video_payload_type + 1 ))
                audio_rate=48000
                audio_channels=2
                sdp_path=$1

                address=234.1.2.3

                video_rtp_port=5004
                video_rtcp_port=$(( video_rtp_port + 1 ))
                rtp_video_payload_type=96
                VIDEOCAPS="application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, sprop-parameter-sets=(string)\"Z2QAHqzZQKAv+XARAAADAAEAAAMAPA8WLZY\=\,aOvssiw\=\", profile-level-id=(string)64001E"

                audio_rtp_port=$(( video_rtp_port + 2 ))
                audio_rtcp_port=$(( video_rtp_port + 3 ))
                rtp_audio_payload_type=$(( rtp_video_payload_type + 1 ))
                AUDIOCAPS="application/x-rtp, media=(string)audio, payload=(int)97, clock-rate=(int)44100, encoding-name=(string)MPEG4-GENERIC, encoding-params=(string)2, profile-level-id=(string)1, mode=(string)AAC-hbr, sizelength=(string)13, indexlength=(string)3, indexdeltalength=(string)3, config=(string)121056E500"
                SDP
                function create_sdp {
                    local sdp_path=$1

                    # sdp
                    cat >$sdp_path <<EOF
                v=0
                c=IN IP4 ${dst_address}
                m=video ${video_rtp_port} RTP/AVP ${rtp_video_payload_type}
                a=rtpmap:${rtp_video_payload_type} ${video_media_subtype}/90000
                m=audio ${audio_rtp_port} RTP/AVP ${rtp_audio_payload_type}
                a=rtpmap:${rtp_audio_payload_type} ${audio_media_subtype}/${audio_rate}/${audio_channels}
                EOF
                    if (( channels == 2 )) && [[ ${audio_media_subtype} == "opus" ]]
                    then
                    echo "a=fmtp:${rtp_audio_payload_type} sprop-stereo=1" >>${sdp_path}
                    fi
                }


                RTP
                gst-launch-1.0 \
                    filesrc location=${input_path} ! qtdemux name=demux \
                    demux.video_0 ! queue ! rtph264pay pt=$rtp_video_payload_type ! \
                    udpsink host=${dst_address} port=${video_rtp_port} sync=true \
                    demux.audio_0 ! queue ! rtpmp4gpay pt=$rtp_audio_payload_type ! \
                    udpsink host=${dst_address} port=${audio_rtp_port} sync=true
                gst-launch-1.0 \
                    udpsrc address=${address} port=${video_rtp_port} do-timestamp=true ! "$VIDEOCAPS" ! \
                    rtph264depay ! queue ! decodebin ! autovideosink sync=true \
                    udpsrc address=${address} port=${audio_rtp_port} do-timestamp=true ! "$AUDIOCAPS" ! \
                    rtpmp4gdepay ! queue ! decodebin ! autoaudiosink sync=true
                RTP using rtpbin
                gst-launch-1.0 \
                    rtpbin name=bin \
                    filesrc location=${input_path} ! qtdemux name=demux \
                    demux.video_0 ! queue ! rtph264pay pt=$rtp_video_payload_type ! bin.send_rtp_sink_0 \
                    bin.send_rtp_src_0 ! udpsink host=${dst_address} port=${video_rtp_port} sync=true \
                    demux.audio_0 ! queue ! rtpmp4gpay pt=$rtp_audio_payload_type ! bin.send_rtp_sink_1\
                    bin.send_rtp_src_1 ! udpsink host=${dst_address} port=${audio_rtp_port} sync=true
                gst-launch-1.0 \
                    rtpbin name=bin \
                    udpsrc address=${address} port=${video_rtp_port} do-timestamp=true ! "$VIDEOCAPS" ! bin.recv_rtp_sink_0 \
                    bin. ! rtph264depay ! queue ! decodebin ! autovideosink sync=true \
                    udpsrc address=${address} port=${audio_rtp_port} do-timestamp=true ! "$AUDIOCAPS" ! bin.recv_rtp_sink_1 \
                    bin. ! rtpmp4gdepay ! queue ! decodebin ! autoaudiosink sync=true

                RTP+RTCP using rtpbin
                gst-launch-1.0 \
                    rtpbin name=bin \
                    filesrc location=${input_path} ! qtdemux name=demux \
                    demux.video_0 ! queue ! rtph264pay pt=$rtp_video_payload_type ! bin.send_rtp_sink_0 \
                    bin.send_rtp_src_0 ! udpsink host=${dst_address} port=${video_rtp_port} sync=true \
                    bin.send_rtcp_src_0 ! udpsink host=${dst_address} port=${video_rtcp_port} sync=false async=false \
                    demux.audio_0 ! queue ! rtpmp4gpay pt=$rtp_audio_payload_type ! bin.send_rtp_sink_1\
                    bin.send_rtp_src_1 ! udpsink host=${dst_address} port=${audio_rtp_port} sync=true \
                    bin.send_rtcp_src_1 ! udpsink host=${dst_address} port=${audio_rtcp_port} sync=false async=false \
                gst-launch-1.0 \
                    rtpbin name=bin \
                    udpsrc address=${address} port=${video_rtp_port} do-timestamp=true ! "$VIDEOCAPS" ! bin.recv_rtp_sink_0 \
                    bin. ! rtph264depay ! queue ! decodebin ! autovideosink sync=true \
                    udpsrc address=${address} port=${video_rtcp_port} ! "application/x-rtcp" ! bin.recv_rtcp_sink_0 \
                    udpsrc address=${address} port=${audio_rtp_port} do-timestamp=true ! "$AUDIOCAPS" ! bin.recv_rtp_sink_1 \
                    bin. ! rtpmp4gdepay ! queue ! decodebin ! autoaudiosink sync=true \
                    udpsrc address=${address} port=${audio_rtcp_port} ! "application/x-rtcp" ! bin.recv_rtcp_sink_1

                RTP+RTCP using sdpdemux

                gst-launch-1.0 -v \
                      filesrc location=$sdp_path do-timestamp=true ! sdpdemux latency=${sdpdemux_latency_ms} name=demux \
                      demux. ! "application/x-rtp, media=(string)video" ! queue ! decodebin ! videoconvert ! videoscale ! videorate ! autovideosink sync=true \
                      demux. ! "application/x-rtp, media=(string)audio" ! queue ! decodebin ! audioconvert ! audioresample ! audiorate ! autoaudiosink sync=true


              • encode webcam, UDP stream:
                • gst-launch v4l2src ! video/x-raw-yuv,width=128,height=96,format='(fourcc)'UYVY ! ffmpegcolorspace ! ffenc_h263 ! video/x-h263 ! rtph263ppay pt=96 ! udpsink host=192.168.1.1 port=5000 sync=false
              • test VP8 / Opus to RTP (no RTPC) (WebRTC and Janus)
                • gst-launch-1.0 \
                  audiotestsrc is-live=true wave=5 ! audioresample ! audioconvert ! audio/x-raw,channels=2,rate=16000 ! opusenc bitrate=20000 ! rtpopuspay pt=97 ! udpsink host=127.0.0.1 port=5002 \
                  videotestsrc ! video/x-raw,width=320,height=240,framerate=15/1 ! videoscale ! videorate ! videoconvert ! timeoverlay ! vp8enc ! rtpvp8pay pt=96 ! udpsink host=127.0.0.1 port=5004
                • sdp
                  • v=0
                    c=IN IP4 127.0.0.1
                    m=video 5100 RTP/AVP 96
                    a=rtpmap:96 VP8/90000
                    m=audio 5102 RTP/AVP 97
                    a=rtpmap:97 opus/48000/2
                    a=fmtp:97 sprop-stereo=1

              • test VP8 / Opus to RTP (with RTCP, using rtpbin):
                • sdp_path=/tmp/toto.sdp
                  dst_address=225.4.3.2

                  video_rtp_port=5100
                  video_rtcp_port=$(( video_rtp_port + 1 ))
                  video_media_subtype="VP8"
                  rtp_video_payload_type=96

                  audio_rtp_port=$(( video_rtp_port + 2 ))
                  audio_rtcp_port=$(( video_rtp_port + 3 ))
                  audio_media_subtype="opus"
                  rtp_audio_payload_type=$(( rtp_video_payload_type + 1 ))

                  rate=48000
                  channels=2

                  # sdp
                  cat >$sdp_path <<EOF
                  v=0
                  c=IN IP4 $dst_address
                  m=video $video_rtp_port RTP/AVP $rtp_video_payload_type
                  a=rtpmap:$rtp_video_payload_type ${video_media_subtype}/90000
                  m=audio $audio_rtp_port RTP/AVP $rtp_audio_payload_type
                  a=rtpmap:$rtp_audio_payload_type ${audio_media_subtype}/${rate}/${channels}
                  EOF
                  if (( channels == 2 )) && [[ ${audio_media_subtype} == "opus" ]]
                  then
                      echo "a=fmtp:${rtp_audio_payload_type} sprop-stereo=1" >>${sdp_path}
                  fi

                  gst-launch-1.0 -v \
                  rtpbin name=bin \
                  videotestsrc ! video/x-raw,width=320,height=240,framerate=25/1 ! videoscale ! videorate ! videoconvert ! timeoverlay ! vp8enc ! rtpvp8pay pt=$rtp_video_payload_type ! bin.send_rtp_sink_0 \
                  bin.send_rtp_src_0 ! udpsink host=${dst_address} port=${video_rtp_port} sync=true \
                  bin.send_rtcp_src_0 ! udpsink host=${dst_address} port=${video_rtcp_port} sync=false async=false \
                  audiotestsrc is-live=true wave=5 ! audioconvert  ! audioresample ! audio/x-raw,channels=${channels},rate=${rate} ! opusenc bitrate=64000 ! rtpopuspay pt=$rtp_audio_payload_type ! bin.send_rtp_sink_1 \
                  bin.send_rtp_src_1 ! udpsink host=${dst_address} port=${audio_rtp_port} sync=true \
                  bin.send_rtcp_src_1 ! udpsink host=${dst_address} port=${audio_rtcp_port} sync=false async=false


              • test H.264 to RTP (no RTCP)
                • gst-launch-1.0 -v videotestsrc ! videoconvert ! x264enc ! rtph264pay config-interval=10 pt=96 ! udpsink host=234.1.2.3 port=5004
                • player:
                  • toto.sdp
                    • v=0
                      m=video 5004 RTP/AVP 96
                      c=IN IP4 234.1.2.3
                      a=rtpmap:96 H264/90000
                      a=fmtp:96 packetization-mode=1
                  • ffplay -i toto.sdp
              • from file (VP8, Opus) to RTP (no RTCP)
                • sdp_path=/tmp/toto.sdp
                  dst_address=225.4.3.2

                  video_rtp_port=5100
                  video_rtcp_port=$(( video_rtp_port + 1 ))
                  video_media_subtype="VP8"
                  rtp_video_payload_type=96

                  audio_rtp_port=$(( video_rtp_port + 2 ))
                  audio_rtcp_port=$(( video_rtp_port + 3 ))
                  audio_media_subtype="opus"
                  rtp_audio_payload_type=$(( rtp_video_payload_type + 1 ))

                  rate=48000
                  channels=2

                  # sdp
                  cat >$sdp_path <<EOF
                  v=0
                  c=IN IP4 $dst_address
                  m=video $video_rtp_port RTP/AVP $rtp_video_payload_type
                  a=rtpmap:$rtp_video_payload_type ${video_media_subtype}/90000
                  m=audio $audio_rtp_port RTP/AVP $rtp_audio_payload_type
                  a=rtpmap:$rtp_audio_payload_type ${audio_media_subtype}/${rate}/${channels}
                  EOF
                  if (( channels == 2 )) && [[ ${audio_media_subtype} == "opus" ]]
                  then
                      echo "a=fmtp:${rtp_audio_payload_type} sprop-stereo=1" >>${sdp_path}
                  fi

                  gst-launch-1.0 -v \
                  filesrc location=/path/to/toto.webm ! matroskademux name=demux \
                  demux.video_0 ! queue ! rtpvp8pay pt=$rtp_video_payload_type ! udpsink host=${dst_address} port=${video_rtp_port} sync=true \
                  demux.audio_0 ! queue ! rtpopuspay pt=$rtp_audio_payload_type ! udpsink host=${dst_address} port=${audio_rtp_port} sync=true

              • from file (H.264, AAC) to RTP
                • gst-launch \
                      filesrc location=${input_path} ! qtdemux name=demux \
                      demux.video_0 ! queue ! rtph264pay pt=$rtp_video_payload_type ! udpsink host=${dst_address} port=${video_rtp_port} sync=true \
                      demux.audio_0 ! queue ! rtpmp4gpay pt=$rtp_audio_payload_type ! udpsink host=${dst_address} port=${audio_rtp_port} sync=true

              • from file (H.264, AAC) to RTP, using rtpbin
                • ...
              • from file (H.264, AAC) to RTP + RTCP, using rtpbin
                • ...
            • RTMP to:
              • options from librtmp
              • nginx-rtmp
                • Video and audio:
                  • from test to H.264, AAC
                    • gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://nginx-server/myapp/mystream \
                      videotestsrc ! video/x-raw, width=360, height=288 ! x264enc ! video/x-h264,profile=baseline,width=360,height=288 ! h264parse ! mux. \
                      audiotestsrc wave=5 ! audioconvert !  avenc_aac compliance=experimental ! aacparse ! mux.

                  • from test to H.264 (omx), MP3
                    • gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://nginx-server/myapp/mystream \
                      videotestsrc ! video/x-raw, width=360, height=288 ! omxh264enc ! video/x-h264,profile=baseline,width=360,height=288 ! h264parse ! mux. \
                      audiotestsrc wave=5 ! audioconvert ! lamemp3enc ! mpegaudioparse ! mux.
                  • from DVB
                    • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                      flvmux name=mux ! rtmpsink location=rtmp://nginx-server/myapp/mystream \
                      demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=50 ! h264parse ! mux. \
                      demux. ! queue ! mpegaudioparse ! decodebin ! audioconvert ! avenc_aac compliance=experimental ! aacparse ! mux.
                  • video, audio with PID 0x7c:
                    • gst-launch-1.0 -vvv dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                      flvmux name=mux ! rtmpsink location=rtmp://192.168.0.8/myapp/mystream \
                      demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=50 ! h264parse ! mux. \
                      demux.audio_007c ! queue ! mpegaudioparse ! decodebin ! audioconvert ! avenc_aac compliance=experimental ! aacparse ! mux.

                  • video, test audio:
                    • gst-launch-1.0 -vvv dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                      flvmux name=mux ! rtmpsink location=rtmp://nginx-server/myapp/mystream \
                      demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=50 ! h264parse ! mux. \
                      audiotestsrc wave=5 ! audioconvert ! lamemp3enc ! mpegaudioparse ! mux.

                  • video, audio forced to 44100Hz (MP3 at 48000Hz is not supported by FLV) (AAC at 48000Hz is supported, though) (queue max-size-time must be increase from 1000000ns [1s] to ... )
                    • gst-launch-1.0 -vvv dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                      flvmux name=mux ! rtmpsink location=rtmp://nginx-server/myapp/mystream \
                      demux. ! queue max-size-time=4000000000 ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=320, height=320 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=50 ! h264parse ! mux. \
                      demux.audio_007c ! queue max-size-time=4000000000 ! mpegaudioparse ! decodebin ! audioconvert ! audioresample ! audio/x-raw,rate=44100 ! lamemp3enc ! mpegaudioparse ! mux.
                  • video, audio AAC at 48000Hz:
                    • gst-launch-1.0 -vvv dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=806 name=demux \
                      flvmux name=mux ! rtmpsink location=rtmp://nginx-server/myapp/mystream \
                      demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=32, height=32 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=50 ! h264parse ! mux. \
                      demux.audio_007c ! queue ! mpegaudioparse ! decodebin ! audioconvert ! audioresample ! audio/x-raw,rate=48000 ! avenc_aac compliance=experimental ! aacparse ! mux.

                • Problemes / Problems
              • Wowza
                • Live Streaming from RaspberryPi using GStreamer - Help please?
                  • Incoming security / Flash Version String:
                    • Wirecast/|FME/|FMLE/|Wowza GoCoder*|Gstreamer/|Gstreamer/*|Gstreamer*
                • How to secure publishing from an RTMP encoder that does not support authentication (ModuleSecureURLParams)
                • Streaming to a Flash Media Server using the rtmpsink element
                  • profile=baseline
                • woking / not working
                  • working
                    • omxh264enc ! video/x-h264,profile=high
                    • omxh264enc ! video/x-h264,profile=baseline
                    • x264enc ! video/x-h264,profile=baseline
                  • not working
                    • x264enc ! video/x-h264,profile=high
                • only video:
                  • gst-launch-1.0 -v -e flvmux name=mux ! rtmpsink  location=rtmp://wowza_server/application/stream \
                    videotestsrc ! video/x-raw, framerate=25/1, width=640, height=360 ! x264enc bitrate=512 ! video/x-h264,profile=baseline ! h264parse ! mux.
                  • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=805 name=demux \
                    flvmux name=mux ! rtmpsink location=rtmp://wowza_server/application/stream \
                    demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=360, height=288 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=1 ! video/x-h264,profile=baseline ! h264parse ! mux.
                  • gst-launch-1.0 -v dvbsrc modulation="QAM 64" trans-mode=8k bandwidth=8 frequency=658000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=4 hierarchy=0 ! tsdemux program-number=805 name=demux \
                    flvmux name=mux ! rtmpsink location=rtmp://wowza-server/application/stream \
                    demux. ! queue ! mpegvideoparse ! decodebin ! videoscale ! video/x-raw, width=360, height=288 ! videoconvert ! omxh264enc inline-header=true periodicty-idr=1 ! video/x-h264,profile=high ! h264parse ! mux.
                  • gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://wowza-server/application/stream \
                    videotestsrc ! video/x-raw, width=360, height=288 ! omxh264enc ! video/x-h264,profile=high ! h264parse ! mux.
                • video and audio:
                  • gst-launch-1.0 -v -e flvmux name=mux ! rtmpsink  location=rtmp://wowza-server/application/stream videotestsrc ! video/x-raw, framerate=24/1, width=1024, height=436 ! x264enc bitrate=800 ! video/x-h264,profile=baseline ! h264parse ! mux. audiotestsrc wave=5 ! audioconvert ! lamemp3enc ! mpegaudioparse ! mux.
                  • gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://wowza-server/application/stream videotestsrc ! video/x-raw, width=360, height=288 ! x264enc        ! video/x-h264,profile=baseline ! h264parse ! mux. audiotestsrc wave=5 ! audioconvert ! lamemp3enc ! mpegaudioparse ! mux.
                  • gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://wowza-server/application/stream videotestsrc ! video/x-raw, width=360, height=288 ! omxh264enc ! video/x-h264,profile=baseline ! h264parse ! mux. audiotestsrc wave=5 ! audioconvert ! lamemp3enc ! mpegaudioparse ! mux.
                  • gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://wowza-server/application/stream videotestsrc ! video/x-raw, width=360, height=288 ! omxh264enc ! video/x-h264,profile=baseline ! h264parse ! mux.
              • Flash Media Server
          • gst-launch filesrc location=videofile ! decodebin name=decoder \
            decoder. ! queue ! audioconvert ! audioresample ! osssink \
            decoder. ! ffmpegcolorspace ! xvimagesink
        • capture timestamped frames (BeagleCam)
          • gst-launch v4l2src num-buffers=1 ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! ffmpegcolorspace ! jpegenc ! filesink location=$(date +"%s").jpg
        • gstreamer dvb streaming
      • Graphical editor
        • gst-editor (only for gstreamer 0.8)

    http://www.francescpinyol.cat/.html
    Primera versió: / First version: 27.X.2018
    Darrera modificació: 12 de desembre de 2018 / Last update: 12th December 2018

    Valid HTML 4.01!

    Cap a casa / Back home