GStreamer Daemon - MP4 Video Recording

From RidgeRun Developer Wiki


Previous: Gapless Playback Index Next: New Clock




The MP4 Video Recording example shows how to record a videotestsrc stream into a MP4 file. The only subtlety to notice is the End Of Stream (EOS) event sent before shutting the pipeline down. Without it, some header information in the MP4 standard wouldn't be updated and the file wouldn't be able to be reproduced.

Example

The following example is a bash script that demonstrates the simple video recording.

#!/bin/bash

# Path to the video location
VIDEO=$1

# Make sure there is no pipeline with this name already
gstd-client pipeline_delete p

gstd-client pipeline_create p videotestsrc is-live=true pattern=ball ! x264enc ! mp4mux ! filesink location=$VIDEO
gstd-client pipeline_play p

# Wait for user interruption
echo "Press enter to finish file"
read

# Send the EOS event to avoid corruption
gstd-client event_eos p
gstd-client bus_filter p eos 
gstd-client bus_read p
gstd-client pipeline_delete p

echo "Video recorded to \"${VIDEO}\""

You may run the script as

./simple-mp4-video-recording.sh /tmp/video.mp4


Previous: Gapless Playback Index Next: New Clock