Skip to content

Instantly share code, notes, and snippets.

@nunogmartins
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nunogmartins/1641e358b3e24c15362b to your computer and use it in GitHub Desktop.
Save nunogmartins/1641e358b3e24c15362b to your computer and use it in GitHub Desktop.

First of all, a video came with two main types of data: audio and video. Since space is important, is important to compress data but since quality is important also, during the years has been developed a lot of codecs (this name came from their functions: coder and encoder). For a technical video overview look at the Xiph videos.

$ gst-launch -v -e  filesrc location="/home/gipi/Video/Nature by Numbers.mp4"  ! \
    qtdemux name=avi ! faad  ! pulsesink

And remember is not only about multimedia: http://www.cita.utoronto.ca/~kcannon/gstlalworkshop/intro_and_setup.html

PIPELINES

Play with guessing

$ gst-launch -v playbin uri="file:///home/gipi/Video/Nature by Numbers.mp4"

Play an image

$ gst-launch -v multifilesrc location=~/Image/debswirl-1280x1024.png caps="image/png, framerate=1/1" ! \
    pngdec ! ffmpegcolorspace ! ximagesink

Autodetect streams and play it

$ gst-launch-1.0 -v --gst-debug=4 filesrc location=//streaming.mp4 ! \
    decodebin name=demux \
    demux. ! queue ! autovideosink \
    demux. ! queue ! autoaudiosink

Show your webcam composite with a test pattern

gst-launch -e v4l2src ! \
    queue ! \
    ffmpegcolorspace ! \
    videoscale ! \
    video/x-raw-yuv, framerate=10/1, width=320, height=240 ! \
    videomixer name=mix ! \
    ffmpegcolorspace ! \
    xvimagesink \
    videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.

Show an overlay over the video

gst-launch-1.0 videotestsrc ! timeoverlay font-desc=60px ! xvimagesink

Resize the output

gst-launch-1.0 -v filesrc location=assange-ecuador.mp4 ! decodebin ! \
    videoscale ! \
    video/x-raw,width=\(int\)320,height=\(int\)200 ! \
    autovideosink filter-caps=video/x-raw

Create a video stream from an image

gst-launch-1.0 filesrc location=image001.jpg ! jpegdec ! imagefreeze ! autovideosink

Remote resource via HTTP

gst-launch-1.0 souphttpsrc location=http://foo.com/miao.mp3 ! autoaudiosink

Attach to a mountpoint of icecast

gst-launch -v filesrc location=audio/04\ -\ Blu\ di\ metilene.ogg ! \
    decodebin ! \
    audioconvert ! \
    vorbisenc  !  \
    oggmux ! \
    shout2send ip=localhost port=8000 mount=/lov

Icecast, you know

$ gst-launch v4l2src ! \
    queue ! \
    ffmpegcolorspace ! \
    videoscale ! \
    video/x-raw-yuv,width=320,height=240 ! \
    tee name=tscreen ! \
    queue ! \
    autovideosink \
    tscreen. ! \
    queue ! \
    videorate ! \
    video/x-raw-yuv,framerate=25/2 ! \
    queue ! \
    theoraenc quality=16 ! \
    queue ! \
    oggmux name=mux \
    alsasrc ! \
    queue ! \
    audioconvert ! \
    vorbisenc quality=0.2 ! \
    queue ! \
    queue ! \
    mux. \
    mux. ! \
    queue ! \
    tee name=tfile ! \
    queue ! \
    filesink location=stream.ogg tfile. ! \
    queue ! \
    shout2send ip=192.168.0.5 port=8000 mount=test.ogv password=sourcepassword

From an IP camera that serves JPEG images (multipartdemux is useless)

$ gst-launch souphttpsrc location=http://192.168.1.5:8080/videofeed ! \
    multipartdemux ! \
    jpegdec ! \
    xvimagesink

A simple test with audio

$ gst-launch -v audiotestsrc  wave=ticks ! audioconvert !  pulsesink

Send audio to a given pulse device

gst-launch -v filesrc location="yet-another-amazing-song.mp3" ! \
 decodebin ! \
 audioconvert ! \
 pulsesink device=nullsinkname

(the device can be a null sink created with pactl load-module module-null-sink sink_name=nullsinkname)

Screencast

$ gst-launch-1.0 ximagesrc ! \
    videoconvert ! \
    queue ! \
    vp8enc  ! mux. \
   pulsesrc ! audio/x-raw ! \
    queue ! \
    audioconvert ! \
    vorbisenc ! \
   mux. webmmux name=mux ! filesink location=screencast.webm

Build from source

Using scripts/create-uninstalled-setup.sh is possible to create a checkout of the sources needed in ~/gst; in that directory a script gst-head is created: this is useful in order to configure all the environment variables correctly and make the build success.

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