Configuration file examples

Updated: April 19, 2023

This section provides sample configuration files that illustrate how plugins can be configured to read, encode, and output audio or video streams with specific settings and formats, for both RTP and RTSP means of access.

Note: The JSON objects and fields that apply to each plugin are fully described in the next section. Here, we explain the use cases supported and plugin configurations defined by each file.

Audio streaming controlled with RTSP

This first example defines an mm-stream instance for delivering audio on demand (through RTSP).

All configuration objects must begin with the uuid field to identify the exact plugin used. We define the mm-stream-input-audio.so object to make the audio input plugin read data from the preferred PCM capture device, in mono (one channel), at the standard CD sampling rate (44.1 kHz), with 16 bits per sample. The audio data are retrieved from libasound in 4k fragments.

{ // begin configuration
    "mm-stream-input-audio.so" : {
        "uuid" : "d1f3b9c7-6c21-4bef-bc93-88a0a90bbe08",
        "audio" : {
            "device_name" : "pcmPreferredc",
            "fragment_size" : 4096,
            "audio_settings": {
                "channels" : 1,
                "samplerate" : 44100,
                "bitspersample" : 16,
                "source_filter_method" : 0,
                "codec" : { "pcm" : {} }
            }
        }
    },

For plugins with data sources (which is all of them except the input-reading ones), their configurations must each contain a plugins object with uuid fields identifying these sources. In our example, the mm-stream-processor-openmaxal.so object specifies the input plugin's UUID in the only entry in its plugins object, because the media-processing plugin uses the input plugin as its source.

In addition to identifying the data source, the configuration assigns a priority of 20 for the thread that runs the media-processing plugin, and AAC encoding for the output MPEG Transport Stream (TS) container. The audio is output by default at 24,000 bps, but the codec supports a variable bitrate. The codec is also configured to use the Low Complexity (LC) profile for the AAC encoding and the Audio Data Transport Stream (ADTS) standard for formatting the data in the output container.

    "mm-stream-processor-openmaxal.so" : {
        "uuid" : "9705042c-0088-461a-8df8-c6b5395871c5",
        "plugins" : [
            { "uuid" : "d1f3b9c7-6c21-4bef-bc93-88a0a90bbe08" }
        ],
        "priority" : 20,
        "ts" : {
            "audio_settings" : {
                "bitrate" : 24000,
                "codec" : {
                    "aac" : {
                        "rate_control" : "variable",
                        "level_setting" : "lc",
                        "stream_format" : "mp4adts"
                    }
                }
            }
        }
    },

The only fields in the mm-stream-output-rtp.so object are for naming the UUIDs of the output plugin and its data source (i.e., the media-processing plugin). The mm-stream-server-rtsp.so object has these same fields as well as additional ones that enable the server's processing of RTSP commands and that name the IP address, port number, and server path to which clients can send those commands.

    "mm-stream-output-rtp.so" : {
        "uuid" : "cea89f41-97e3-409e-a427-7117f952f8a6",
        "plugins" : [
            { "uuid" : "9705042c-0088-461a-8df8-c6b5395871c5" }
        ]
    },

    "mm-stream-server-rtsp.so" : {
        "uuid" : "9f4a348c-fa34-479c-b10b-c7103986c84f",
        "address" : "0.0.0.0:8554",
        "streams" : [
            {
                "enabled" : true,
                "path" : "/audio",
                "plugins" : [
                    { "uuid" : "cea89f41-97e3-409e-a427-7117f952f8a6" }
                ]
            }
        ]
    }
} // end configuration

File streaming over RTP

The following example defines an mm-stream instance that reads a media file from local storage and sends its audio and video components in an RTP stream to a specific IP address and port.

The mm-stream-input-file.so object tells the file input plugin to read an MP4 file from an NFS share drive and use six buffers for blitting. The audio is read in stereo (two channels), at a rate of 48 kHz with 16 bits per sample. The input video frames are 1280 x 720 pixels, with no rotation, and are read at a rate of 24 Hz. The video codec is configured for raw video with NV12 color format.

{ // begin configuration
    "mm-stream-input-file.so" : {
        "uuid" : "f342e14d-7476-4c4f-b64e-eaf31d231bd9",
        "file" : {
            "path" : "/nfs_share/Serenity_720p.mp4",
            "blitter_buffers" : 6,
            "audio_settings": {
                "channels" : 2,
                "samplerate" : 48000,
                "bitspersample" : 16,
                "codec" : { "pcm" : {} }
            },
            "video_settings": {
                "width" : 1280,
                "height" : 720,
                "rotation" : 0,
                "framerate" : 24 ,
                "codec" : {
                    "raw" : {
                        "color_format" : "nv12"
                    }
                }
            }
        }
    },

The mm-stream-processor-openmaxal.so object defines the same audio settings as in the first example—AAC encoding based on the LC profile, output formatting based on the ADTS standard, and a variable bitrate with a default of 24,000 bps. For the video settings, the bitrate is set to 5,000,000 bps, and H.264 encoding is used. The codec is configured to support a variable bitrate with a keyframe interval of 10, and use the baseline profile with an AVC-31 decoder performance level.

    "mm-stream-processor-openmaxal.so" : {
        "uuid" : "94b35e72-bc88-48e3-9864-329a9ada0d7f",
        "plugins" : [
            { "uuid" : "f342e14d-7476-4c4f-b64e-eaf31d231bd9" }
        ],
        "priority" : 20,
        "ts" : {
            "audio_settings" : {
                "bitrate" : 24000,
                "codec" : {
                    "aac" : {
                        "rate_control" : "variable",
                        "level_setting" : "lc",
                        "stream_format" : "mp4adts"
                    }
                }
            },
            "video_settings" : {
                "bitrate" : 5000000,
                "codec" : {
                    "h264" : {
                        "rate_control" : "variable",
                        "keyframe_interval" : 10,
                        "profile_setting" : "baseline",
                        "level_setting" : "avc_31"
                    }
                }
            }
        }
    },

The mm-stream-output-rtp.so and mm-stream-server-rtp.so objects name the UUIDs of their corresponding plugins and data sources. The latter object also specifies the IP addresses and ports used by the client for accessing the RTP stream and by the server as the destination. Here, the destination is a unicast address, so the RTP stream is sent to one client, but we could use a multicast address to deliver the content to all members of a multicast group.

    "mm-stream-output-rtp.so" : {
        "uuid" : "b8d59e4e-0d57-4709-89db-048b3c67a2f1",
        "plugins" : [
            { "uuid" : "94b35e72-bc88-48e3-9864-329a9ada0d7f" }
        ]
    },

    "mm-stream-server-rtp.so" : {
        "uuid" : "65de7d07-59af-47da-b9fa-d9bafd38c064",
        "plugins" : [
            {
                "uuid" : "b8d59e4e-0d57-4709-89db-048b3c67a2f1",
                "address" : "0.0.0.0:20000",
                "peer_address" : "10.122.33.97:10000"
            }
        ]
    }
} // end configuration

Streaming camera video in multiple formats to RTP and RTSP clients

This example defines multiple mm-stream instances for encoding camera video at bitrates suitable for 360p and 720p formats for RTSP clients and for 720p format for an RTP client.

The camera input plugin is configured, through the mm-stream-input-camera.so object, to read the feed from camera unit 1, allocate 8 buffers in the viewfinder window, and use the given settings for reading video. These settings specify a 1280 x 720 video input, with a 180° rotation and frame rate of 30 fps, for raw video with NV12 color format.

{ // begin configuration
    "mm-stream-input-camera.so" : {
        "uuid" : "d1f3b9c7-6c21-4bef-bc93-88a0a90bbe08",
        "camera" : {
            "unit_id" : 1,
            "buffers" : 8,
            "video_settings": {
                "width" : 1280,
                "height" : 720,
                "rotation" : 180,
                "framerate" : 30 ,
                "codec" : {
                    "raw" : {
                        "color_format" : "nv12"
                    }
                }
            }
        }
    },

Because the same camera feed is to be sent to many clients, there's only one configuration for the input plugin. The media-processing plugin has multiple configurations, with slightly different names. The first such configuration is intended for a 720p encoding processor and uses the same H.264 codec settings as in the second example—5,000,000 bps by default but with support for a variable bitrate, a keyframe interval of 10, and baseline profile usage with an AVC-31 performance level.

To encapsulate the 720p video content into RTP packets, we define an output plugin configuration that names this same media-processing plugin configuration as its data source.

    "mm-stream-processor-openmaxal.so:720p" : {
        "uuid" : "9705042c-0088-461a-8df8-c6b5395871c5",
        "plugins" : [
            { "uuid" : "d1f3b9c7-6c21-4bef-bc93-88a0a90bbe08" }
        ],
        "priority" : 20,
        "ts" : {
            "video_settings" : {
                "width" : 1280,
                "height" : 720,
                "framerate" : 30,
                "bitrate" : 5000000,
                "codec" : {
                    "h264" : {
                        "rate_control" : "variable",
                        "keyframe_interval" : 10,
                        "profile_setting" : "baseline",
                        "level_setting" : "avc_31"
                    }
                }
            }
        }
    },

    "mm-stream-output-rtp.so:720p" : {
        "uuid" : "cea89f41-97e3-409e-a427-7117f952f8a6",
        "plugins" : [
            { "uuid" : "9705042c-0088-461a-8df8-c6b5395871c5" }
        ]
    },

We then define a plugin configuration for encoding the camera video with a 360p processor. To achieve this, we use a reduced bitrate of 1,000,000 bps, although the video dimensions and frame rate remain the same. To encapsulate the 360p video content into RTP packets, we need another output plugin configuration that names our second media-processing plugin configuration as its data source.

    "mm-stream-processor-openmaxal.so:360p" : {
        "uuid" : "fd72a4c4-bf90-4ff3-b38f-5480fd2d4911",
        "plugins" : [
            { "uuid" : "d1f3b9c7-6c21-4bef-bc93-88a0a90bbe08" }
        ],
        "priority" : 20,
        "ts" : {
            "video_settings" : {
                "width" : 1280,
                "height" : 720,
                "framerate" : 30,
                "bitrate" : 1000000,
                "codec" : {
                    "h264" : {
                        "rate_control" : "variable",
                        "keyframe_interval" : 10,
                        "profile_setting" : "baseline",
                        "level_setting" : "avc_31"
                    }
                }
            }
        }
    },

    "mm-stream-output-rtp.so:360p" : {
        "uuid" : "7898c9a4-c749-4485-a7e9-aaae92cf25a3",
        "plugins" : [
            { "uuid" : "fd72a4c4-bf90-4ff3-b38f-5480fd2d4911" }
        ]
    },

To make these 720p and 360p video streams available to remote clients, we can use one RTSP access plugin configuration that names the two previous output configurations as its data sources. The access plugin configuration also specifies the IP address, port number, and server paths to which clients can send RTSP commands; there are different paths for controlling the two different streams.

    "mm-stream-server-rtsp.so" : {
        "uuid" : "9f4a348c-fa34-479c-b10b-c7103986c84f",
        "address" : "0.0.0.0:8554",
        "streams" : [
            {
                "enabled" : true,
                "path" : "/camera/720p",
                "plugins" : [
                    { "uuid" : "cea89f41-97e3-409e-a427-7117f952f8a6" }
                ]
            },
            {
                "enabled" : true,
                "path" : "/camera/360p",
                "plugins" : [
                    { "uuid" : "7898c9a4-c749-4485-a7e9-aaae92cf25a3" }
                ]
            }
        ]
    },

To support continuous streaming, we must define a new media-processing plugin configuration that specifies a bitrate suitable for delivering 720p video content over RTP. For the remaining transport stream and other plugin settings, we use the same values as the two RTSP instances. We also define an output plugin configuration that uses our last media-processing configuration as its source.

    "mm-stream-processor-openmaxal.so:rtp_unicast" : {
        "uuid" : "9a342ed4-3576-4e36-9ac0-ff3670b6885a",
        "plugins" : [
            { "uuid" : "d1f3b9c7-6c21-4bef-bc93-88a0a90bbe08" }
        ],
        "priority" : 20,
        "ts" : {
            "video_settings" : {
                "width" : 1280,
                "height" : 720,
                "framerate" : 30,
                "bitrate" : 3000000,
                "codec" : {
                    "h264" : {
                        "rate_control" : "variable",
                        "keyframe_interval" : 10,
                        "profile_setting" : "baseline",
                        "level_setting" : "avc_31"
                    }
                }
            }
        }
    },

    "mm-stream-output-rtp.so:rtp_unicast" : {
        "uuid" : "13130440-a266-4162-ac9b-b70c7af8c5af",
        "plugins" : [
            { "uuid" : "9a342ed4-3576-4e36-9ac0-ff3670b6885a" }
        ]
    },

Finally, we define an RTP access configuration that specifies the IP address and port from which the client can access the camera feed, as well as the destination IP address and port for the stream.

    "mm-stream-server-rtp.so:rtp_unicast" : {
        "uuid" : "0f455a80-fdb1-47ac-b48b-8277cf5a358c",
        "plugins" : [
            {
                "uuid" : "13130440-a266-4162-ac9b-b70c7af8c5af",
                "address" : "0.0.0.0:20000",
                "peer_address" : "10.122.33.124:10000"
            }
        ]
    }
} // end configuration

Together, these plugin configurations create three independent mm-stream instances. The instances allow the server to concurrently stream the camera feed in two different video formats in response to RTSP commands, and the higher resolution format to a specific IP address of an RTP client.