GStreamer Daemon - MP4 Video Recording
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.
1 #!/bin/bash
2
3 # Path to the video location
4 VIDEO=$1
5
6 # Make sure there is no pipeline with this name already
7 gstd-client pipeline_delete p
8
9 gstd-client pipeline_create p videotestsrc is-live=true pattern=ball ! x264enc ! mp4mux ! filesink location=$VIDEO
10 gstd-client pipeline_play p
11
12 # Wait for user interruption
13 echo "Press enter to finish file"
14 read
15
16 # Send the EOS event to avoid corruption
17 gstd-client event_eos p
18 gstd-client bus_filter p eos
19 gstd-client bus_read p
20 gstd-client pipeline_delete p
21
22 echo "Video recorded to \"${VIDEO}\""
You may run the script as
./simple-mp4-video-recording.sh /tmp/video.mp4