Difference between revisions of "Using gstreamer"

From ElphelWiki
Jump to: navigation, search
(Requirements)
Line 10: Line 10:
  
 
* a fairly recent Gstreamer distribution ("gstreamer0.10" as Ubuntu package for example), with the rtpjpegdepay plugin.
 
* a fairly recent Gstreamer distribution ("gstreamer0.10" as Ubuntu package for example), with the rtpjpegdepay plugin.
 
= Limitations =
 
 
You will not (at this time) be able to decode the video streams from Elphel 353 cameras on resolutions higher than 1920x1088, because of the RTP payloading limits.
 
 
To bypass this limitation you can modify the limit and build it from source yourself (see [http://www.pitivi.org/wiki/GStreamer_CVS_Setup_Page this guide from PiTiVi]).
 
  
 
= Tips =
 
= Tips =
Line 29: Line 23:
  
 
Display the cameras live video stream at its native resolution:
 
Display the cameras live video stream at its native resolution:
  gst-launch-0.10 rtspsrc location=rtsp://*CAMERA_IP*:554 ! rtpjpegdepay ! jpegdec ! queue ! ffmpegcolorspace ! xvimagesink sync=false
+
  gst-launch-0.10 rtspsrc location=rtsp://192.168.0.9:554 ! rtpjpegdepay ! jpegdec ! queue ! ffmpegcolorspace ! xvimagesink sync=false
  
 
Display the cameras live video stream, resize to fit window (the ! videoscale element takes care of that)  
 
Display the cameras live video stream, resize to fit window (the ! videoscale element takes care of that)  
  gst-launch-0.10 rtspsrc location=rtsp://*CAMERA_IP*:554 ! rtpjpegdepay ! jpegdec ! queue ! ffmpegcolorspace ! videoscale ! xvimagesink sync=false
+
  gst-launch-0.10 rtspsrc location=rtsp://192.168.0.9:554 ! rtpjpegdepay ! jpegdec ! queue ! ffmpegcolorspace ! videoscale ! xvimagesink sync=false
  
 
== Dumping ==
 
== Dumping ==
 
=== mjpeg dumping ===
 
=== mjpeg dumping ===
  
gst-launch -v rtspsrc location=rtsp://elphel:554 ! queue ! rtpjpegdepay ! videorate ! capsfilter caps = "image/jpeg, framerate=(fraction)25/1, width=1024, height=768" ! queue ! matroskamux ! filesink location=/tmp/test.mkv
+
gst-launch -v rtspsrc location=rtsp://192.168.0.9:554 ! queue ! rtpjpegdepay ! videorate ! capsfilter caps = "image/jpeg, framerate=(fraction)25/1, width=1024, height=768" ! queue ! matroskamux ! filesink location=/tmp/test.mkv
  
 
=== YUV Dumping ===
 
=== YUV Dumping ===
  
gst-launch -v rtspsrc location=rtsp://elphel:554 ! queue ! rtpjpegdepay ! queue ! jpegdec ! queue ! videorate ! capsfilter caps="video/x-raw-yuv, format=(fourcc)I420, width=(int)1024, height=(int)768, framerate=(fraction)25/1" ! queue ! avimux ! filesink location=/tmp/test.avi
+
gst-launch -v rtspsrc location=rtsp://192.168.0.9:554 ! queue ! rtpjpegdepay ! queue ! jpegdec ! queue ! videorate ! capsfilter caps="video/x-raw-yuv, format=(fourcc)I420, width=(int)1024, height=(int)768, framerate=(fraction)25/1" ! queue ! avimux ! filesink location=/tmp/test.avi
  
 
== Dump transcoding example ==
 
== Dump transcoding example ==

Revision as of 10:29, 24 January 2010

Gstreamer has made a lot of progress lately and some say it already outperforms Mplayer because of its focus on speed and hardware acceleration like using OpenGL, etc.

Gstreamer is a modular node based player as well as encoder in a single application. It is possible to create chains of so called elements with a wide range of different plugins.

Gstreamer and live video processing over the network

Gstreamer is very suited to live video and audio processing, notably for live decoding/encoding, audio muxing.

Requirements

  • a fairly recent Gstreamer distribution ("gstreamer0.10" as Ubuntu package for example), with the rtpjpegdepay plugin.

Tips

You won't get 25 fps if autoexposure is on and local brightness not high enough: the camera will automatically lower framerate for keeping clear picture. Either lighten up, or play with image settings (notably, gain).

Commandline examples

(Note: replace width and height accordingly to your camera setup and your computer's horsepower :p).

Displaying

careful with streams at higher resolution than 1920x1088

Display the cameras live video stream at its native resolution:

gst-launch-0.10 rtspsrc location=rtsp://192.168.0.9:554 ! rtpjpegdepay ! jpegdec ! queue ! ffmpegcolorspace ! xvimagesink sync=false

Display the cameras live video stream, resize to fit window (the ! videoscale element takes care of that)

gst-launch-0.10 rtspsrc location=rtsp://192.168.0.9:554 ! rtpjpegdepay ! jpegdec ! queue ! ffmpegcolorspace ! videoscale ! xvimagesink sync=false

Dumping

mjpeg dumping

gst-launch -v rtspsrc location=rtsp://192.168.0.9:554 ! queue ! rtpjpegdepay ! videorate ! capsfilter caps = "image/jpeg, framerate=(fraction)25/1, width=1024, height=768" ! queue ! matroskamux ! filesink location=/tmp/test.mkv

YUV Dumping

gst-launch -v rtspsrc location=rtsp://192.168.0.9:554 ! queue ! rtpjpegdepay ! queue ! jpegdec ! queue ! videorate ! capsfilter caps="video/x-raw-yuv, format=(fourcc)I420, width=(int)1024, height=(int)768, framerate=(fraction)25/1" ! queue ! avimux ! filesink location=/tmp/test.avi

Dump transcoding example

gst-launch filesrc location=test.mkv ! matroskademux ! queue ! jpegdec ! queue ! theoraenc bitrate=4000 ! queue ! oggmux ! filesink location=test.ogg

Live encoding

gst-launch -v rtspsrc location=rtsp://elphel:554 ! queue ! rtpjpegdepay ! queue ! jpegdec ! queue ! videorate ! capsfilter caps="video/x-raw-yuv, format=(fourcc)I420, width=(int)1024, height=(int)768, framerate=(fraction)25/1" ! queue ! theoraenc bitrate=4000 ! queue ! oggmux ! filesink location=/tmp/test1024.ogg

I did some benchmarks; a Core 2 Quad Q6600 (2.4 Ghz) is not powerful enough for h264 encoding @fullHD resolution (using 4 treads).