Shinkai (Shinkai v0.3.0)

View Source

Media server for Elixir.

Configuration

Shinkai can be configured via a YAML file. By default, it looks for the configuration file at shinkai.yml relative to the current working directory. You can override this by setting the SHINKAI_CONFIG_PATH environment variable or by configuring the :config_path option in the :shinkai application environment.

The following configuration options are available:

Server

To configure the http server responsible for serving HLS streams.

  • :enabled (boolean/0) - Enable or disable http(s) server The default value is true.

  • :port (:socket.port_number/0) - http port The default value is 8888.

  • :certfile - https certificate The default value is nil.

  • :keyfile - https private key certificate The default value is nil.

    config :shinkai, :server,
      enabled: true,
      port: 8888,
      certfile: server.crt,
      keyfile: server.key
    server:
      enabled: true          # Enable or disable the HTTP server (default: true)
      port: 8888             # Port number for the HTTP server (default: 8888)
      certfile: server.crt   # Path to the SSL certificate file (optional)
      keyfile: server.key    # Path to the SSL key file (optional)

HLS

To configure HLS streaming options.

  • :storage_dir (String.t/0) - Directory to store HLS segments The default value is "/tmp/shinkai/hls".

  • :max_segments (non_neg_integer/0) - Max segments to keep in live playlists The default value is 7.

  • :segment_duration (non_neg_integer/0) - Segment duration in milliseconds The default value is 2000.

  • :part_duration (non_neg_integer/0) - Part duration in milliseconds for low-latency HLS The default value is 300.

  • :segment_type - Type of segments to generate, either :fmp4, :mpeg_ts or :low_latency The default value is :fmp4.

    config :shinkai, :hls,
      max_segments: 7,
      part_duration: 500,
      segment_type: :mpeg_ts
    hls:
      storage_dir: "/path/to/hls/storage"  # Directory to store HLS segments (default: "/tmp/shinkai/hls")
      max_segments: 7                      # Maximum number of segments to keep (default: 7)
      segment_duration: 2000               # Segment duration in milliseconds (default: 2000)
      part_duration: 500                   # Part duration in milliseconds (default: 500)
      segment_type: "fmp4"                 # Type of segments to generate, either "fmp4" or "mpeg_ts" or "low_latency" (default: "fmp4")

RTMP

To configure the RTMP server.

  • :enabled (boolean/0) - Enable or disable rtmp The default value is true.

  • :port (:socket.port_number/0) - RTMP listening port The default value is 1935.

    config :shinkai, :rtmp,
      enabled: true,
      port: 1935
    rtmp:
      enabled: true          # Enable or disable the RTMP server (default: true)
      port: 1935             # Port number for the RTMP server (default: 1935)

RTSP

To configure the RTSP server.

  • :enabled (boolean/0) - Enable or disable rtsp The default value is true.

  • :port (:socket.port_number/0) - RTSP listening port The default value is 8554.

    config :shinkai, :rtsp,
      enabled: true,
      port: 8554
    rtsp:
      enabled: true          # Enable or disable the RTSP server (default: true)
      port: 8554             # Port number for the RTSP server (default: 8554)

Paths

To configure media source paths. Each source should have a unique alphanumeric ID.

  paths:
    camera1:
      source: "rtsp://example.com/stream1"
    camera2:
      source: "rtsp://example.com/stream2"
    camera3:
      source: "rtmp://example.com/live/stream3"