GStreamer pre-record element
The GStreamer pre-trigger element pre-records data continuously into a FIFO. You can set the FIFO size in miliseconds based on the amount of pre-recorded data you want to kept. When pre-recording, the pre-trigger element doesn't pass any buffer downstream. After the FIFO is filled, the oldest data in the FIFO is released as new data is added. When you want to start recording, you can trigger the pre-trigger element and it will pass the data in the FIFO downstream while adding new data to the end of the FIFO buffer so no data is lost. Eventually, the FIFO will be completely drained and the element will act as a pass though. When the pipeline is stopped, the pre-record process can be repeated.
Using pre-record with motion detection or other event activity sensor is a great way to see what happened right before an event occurs. For example, using pre-record in a car's video capture system along with an accelerometer allows the history right before an accident to be captured. Using pre-record with motion detection allows the changing scene to be included in the video allowing the sensitivity of the motion detection to be turned down and thus avoiding false MD triggers.
Getting the code
Pre-record is an add-on to RidgeRun's professional SDK. You can purchase the GStreamer pre-trigger element, with full source code, from the RidgeRun Store.
Building the code
The source code for the pre-trigger element can be found on
The element will be built along with the SDK if selected on the configuration menu:
cd $DEVDIR make config -> Proprietary software -> RidgeRun Pre Trigger GStreamer element
The pre-trigger element can be built manually by:
cd $DEVDIR/proprietary/gst-pre-trigger make make install
Pre-trigger element properties
GStreamer inspect returns:
Factory Details: Long name: RR Pre trigger element Class: Generic Description: RR pre trigger element Author(s): Melissa Montero <firstname.lastname@example.org> Rank: none (0) Plugin Details: Name: pretriggerplugin Description: Pre trigger plugin Filename: /usr/lib/gstreamer-0.10/libgstpretrigger.so Version: 0.10.0 License: Proprietary Source module: gst-pre-trigger Binary package: Ridgerun elements Origin URL: http://www.ridgerun.com GObject +----GstObject +----GstElement +----GstBin +----GstPreTrigger Implemented Interfaces: GstChildProxy Pad Templates: SINK template: 'sink%d' Availability: On request Has request_new_pad() function: gst_pre_trigger_request_new_pad Capabilities: ANY SRC template: 'src%d' Availability: Sometimes Capabilities: ANY Element Flags: no flags set Bin Flags: no flags set Element Implementation: Has change_state() function: gst_bin_change_state_func Has custom save_thyself() function: gst_bin_save_thyself Has custom restore_thyself() function: gst_bin_restore_thyself Clocking Interaction: element requires a clock element is supposed to provide a clock but returned NULL Indexing capabilities: element can do indexing Element has no URI handling capabilities. Pads: none Element Properties: name : The name of the object flags: readable, writable String. Default: "pretrigger0" async-handling : The bin will handle Asynchronous state changes flags: readable, writable Boolean. Default: false message-forward : Forwards all children messages flags: readable, writable Boolean. Default: false buf-time : Minimum amount of data that will be buffered - may contain more (in ms, 0=disable) flags: readable, writable Unsigned Integer64. Range: 0 - -1 Default: 0 buffering : Whether to keep buf-time buffers (buffering) or to pass the buffereddata downstream (debuffering) flags: readable, writable Boolean. Default: false on-key-frame : Wait for a video key frame to start debuffering. flags: readable, writable Boolean. Default: false Element Signals: "pad-added" : void user_function (GstElement* object, GstPad* arg0, gpointer user_data); "pad-removed" : void user_function (GstElement* object, GstPad* arg0, gpointer user_data); "no-more-pads" : void user_function (GstElement* object, gpointer user_data);
To test the pre-trigger GStreamer element, run the following pipelines:
v4l2src always-copy=false ! capsfilter caps=video/x-raw-yuv,width=640,height=480 ! x264enc speed-preset=ultrafast !\ pretrigger buf-time=5000 buffering=true on-key-frame=false name=trigger ! queue ! qtmux name=mux ! filesink qos=false \ sync=false async=false location=test2.mp4 audiotestsrc is-live=true ! faac ! trigger. trigger. ! queue ! mux.
filesrc location=$FILE ! qtdemux name=demux ! queue ! ffdec_h264 ! x264enc speed-preset=ultrafast ! pretrigger \ buf-time=5000 buffering=true on-key-frame=false name=trigger ! qtmux name=mux ! filesink location=test1.mp4 \ async=false demux. ! ffdec_aac ! trigger. trigger. ! queue ! faac ! mux. fakesink async=false