Video Recorder: video-storage and video-streamer-cpu

Video Recorder is an optional part of the FindFace Server. It works in the following way:

  • The video-storage service implements video chunk management. It takes video chunks from the video-worker component, puts them into the storage (upload), and writes their meta-information and whereabouts to the MongoDB database. By request, it issues info about existing video chunks and Websocket-links to the corresponding streams. These links are further used by video-streamer-cpu to deliver the video to a user for viewing and downloading.

  • After receiving an API request, this service extracts the requested video chunks from video-storage and video-worker (only the last chunk if it’s not yet recorded to the storage). Then it merges the video chunks into a one-piece video and delivers it to a user for viewing and downloading using WebSocket.

Configure Video Recorder

  1. The video-storage configuration is done through environment variables or command line flags. You can also use a video-storage.yaml configuration file and find its default content here.

    When configuring video-storage, refer to the following parameters:

    Command line flags

    Type

    Description

    -chunk-storage-localfs-directory

    string

    The directory to store files.

    -chunk-storage-s3-access-key

    string

    Access key for the object storage.

    -chunk-storage-s3-bucket-name

    string

    S3 storage bucket name.

    -chunk-storage-s3-endpoint

    string

    S3 compatible object storage endpoint.

    -chunk-storage-s3-operation-timeout

    int

    Storage operations (Get, Put, Delete) timeout in seconds (default 30).

    -chunk-storage-s3-public-url

    string

    Storage public url.

    -chunk-storage-s3-region

    string

    Storage region.

    -chunk-storage-s3-secret-access-key

    string

    Secret key for the object storage.

    -chunk-storage-s3-secure

    If true API requests will be secure (HTTPS), and insecure (HTTP) otherwise (default true).

    -chunk-storage-type

    string

    Chunk storage type: inmemory, localfs, webdav, s3 (default inmemory).

    -chunk-storage-webdav-keepalive

    duration

    Keep-alive connection timeout (default 24h0m0s).

    -chunk-storage-webdav-max-idle-conns-per-host

    int

    Max idle keep-alive connections per host (default 20).

    -chunk-storage-webdav-timeouts-connect

    duration

    chunk-storage-webdav-timeouts-connect (default 5s).

    -chunk-storage-webdav-timeouts-idle-connection

    duration

    chunk-storage-webdav-timeouts-idle-connection (default 10s).

    -chunk-storage-webdav-timeouts-overall

    duration

    chunk-storage-webdav-timeouts-overall (default 35s).

    -chunk-storage-webdav-timeouts-response-header

    duration

    chunk-storage-webdav-timeouts-response-header (default 30s).

    -chunk-storage-webdav-trace

    Enable HTTP tracing (extremely verbose, slows everything down considerably).

    -chunk-storage-webdav-upload-url

    string

    Webdav storage URL (default http://127.0.0.1:3333/uploads/video_storage).

    -config

    string

    A path to a config file.

    -config-template

    Output config template and exit.

    -debug

    Enable debug logging.

    -external-address

    string

    Used to access video-storage via external links (default http://127.0.0.1:18611/).

    -help

    Print help information.

    -listen

    string

    IP:port to listen on (default :18611).

    -meta-storage-database

    string

    meta-storage-database (default video-storage).

    -meta-storage-mongo-uri

    string

    meta-storage-mongo-uri (default mongodb://127.0.0.1).

    -meta-storage-timings-connect

    duration

    meta-storage-timings-connect (default 3s).

    -streamer-endpoints

    value

    List of streamer endpoint URLs (default 127.0.0.1:9000).

    The format of environment variable for flag -my-flag is CFG_MY_FLAG.

    Priority:

    1. Defaults from source code (lowest priority).

    2. Configuration file.

    3. Environment variables.

    4. Command line.

  2. The video-streamer-cpu configuration is done through environment variables or command line flags, or through the video-streamer-cpu.yaml configuration file. You can find its default content here.

    When configuring video-streamer-cpu, refer to the following parameters:

    Command line flags

    Type

    Description

    -h, --help

    {bool}

    Display this help and exit (env: CFG_HELP).

    -c, --config

    {string}

    A path to a config file (env: CFG_CONFIG).

    -C, --config-template

    {bool}

    Echo default config to stdout (env: CFG_CONFIG_TEMPLATE).

    --config-template-format

    {string}

    config-template output format (yaml/env/ini) (env: CFG_CONFIG_TEMPLATE_FORMAT).

    --streamer-port

    {number}

    Streamer port (env: CFG_STREAMER_PORT).

    --streamer-max-backpressure

    {number}

    Max backpressure for client connection (bytes) (env: CFG_STREAMER_MAX_BACKPRESSURE).

    --streamer-io-buffer-size

    {number}

    Muxer’s io buffer size (bytes) (env: CFG_STREAMER_IO_BUFFER_SIZE).

    --video-storage-url

    {string}

    video-storage REST-api url (env: CFG_VIDEO_STORAGE_URL).

    --video-storage-timeout

    {double}

    video-storage api requests timeout, seconds (env: CFG_VIDEO_STORAGE_TIMEOUT).

    --cache-dir

    {string}

    Absolute path to the temporary chunk storage folder (env: CFG_CACHE_DIR).