Encoding Audio and Video

See also

Common Environment Variables

RSB-specific environment variables can be used to control the transport configuration used by the GStreamer scripts.

bag-play

bag-play is used to obtain event s from log file s and transport them into a GStreamer :pipeline.

When recording audio and video streams into an audio/video container file, GStreamer is used to encode audio and video payload s of event s and write the resulting streams into an output file.

Warning

This approach can only be used when GStreamer audio and video encoders can process all data at the rate with which it arrives.

Scripts

The rsb-gstreamer project includes the scripts record_ogv.sh and record_mp4.sh which allow encoding audio data and video data into a video container file. Both scripts are used as follows

$ record_{ogv,mp4}.sh OUTPUTFILE VIDEOSCOPE ( AUDIOSCOPE | _ )

_ can be used to indicate that a particular component should not be recorded.

Steps

Assuming audio data and video data have been recorded into a log file named video.tide or separate files audio.tide and video.tide, this example demonstrates converting the log file(s) into a video container file with synchronized audio and video streams.

  1. Merge audio and video data

    In this step, audio and video recordings from separate files are synchronized and the merged data is stored in a new file. Assuming the separate audio and video data is stored in files named audio.tide and video.tide respectively, the following command performs the merging and stores the result in a file called merged.tide:

    $ bag-merge -o merged.tide audio.tide video.tide
    

    Note

    This step is only required when audio and video data have been recorded into separate log file s.

  2. Start the recording pipeline

    $ ./record_ogv.sh video.ogv /video/camera1 /audio/mic1
    

    Note

    This part of the example assumes a configuration that enables the Spread transport for a Spread daemon listening on port 4803 on localhost, see Common Environment Variables.

  3. Replay audio and video data from the log file using bag-play

    $ bag-play -r as-fast-as-possible video.tide 'spread://localhost:4803'
    

    Note

    The configuration specified via the URI (spread://localhost:4803 in this case) has to match the configuration of the GStreamer pipeline. See URIs for an explanation of the use of URIs in RSB and related projects.

GStreamer Pipeline

The following diagram contains a simplified illustration of a minimal GStreamer pipeline that can be used to generate video files from RSB event s containing audio and video data. The vorbisenc, theoraenc and oggmux elements can be replaced with different encoders and container multiplexers as required:

                                 ,~~~~,
                                /     \--->rsbaudiosrc--->vorbisenc---+
                                \     /                               v
audio-video.tide--->bag-play--->/ RSB \                             oggmux--->filesink
                                \     /                               ^
                                /     \--->rsbvideosrc--->theoraenc---+
                                `~~~~~'

The audio and video sources in the above diagram can be any components which publish suitable audio and video event s using RSB.