Socket
Socket
Sign inDemoInstall

github.com/tomclegg/streamserve

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/tomclegg/streamserve

Streamserve is a live media streaming server: it reads data from a pipe and distributes it to many HTTP clients. In general: PCM audio: MP3 audio: Show all options: Unlike general-purpose web servers, streamserve it suitable when: 1. The process supplying the data stream is expensive. For example, you want to encode media on the fly and send it to 100 clients, but you can't run 100 encoding processes at once. 2. It's acceptable for a given client (a) to start receiving data mid-stream, and (b) if it has been receiving data too slowly, to skip some data segments to catch up with everyone else. (For this to work, the server must understand enough about the data stream format to interrupt and resume at appropriate positions.) 3. Clients are expected to read data at the same speed data is received from the source. By default, streamserve listens for connections at port 80 on all network interfaces. Note: Use 'sudo setcap cap_net_bind_service=+ep [...]/bin/streamserve' if you want to listen on port 80 or another privileged port. Don't run streamserve as root. Specify an IP address and port number: Specify a port number, listen on all interfaces: Choose any unused port (can be useful for testing): Default: Input data is split into frames. When a client first connects, it starts receiving data at a frame boundary. When a client is receiving data too slowly and skips some of the stream, the skipped part starts and ends at frame boundaries. The raw filter chunks its input into fixed-size blocks. It pays no attention to the data content. The mp3 filter accepts physical MP3 frames. It skips past input data that doesn't look like MP3 frames. The -frame-bytes argument is a maximum: it must be big enough to hold the biggest frame. Data from the input FIFO is read into a fixed-size ring buffer, with a static number of frames. The size of the buffer determines how far a client can fall behind before it catches up by skipping part of the stream. The buffer size is given in frames. This is a 1048576-byte buffer: Maximum client lag is determined by the source buffer argument and the actual frame sizes: If using -filter=mp3, the above example will skip frames when a client lags behind by 1024 mp3 frames (not 1048576 bytes). You can control streamserve's behaviour when a data source closes, and when it becomes idle (no clients are connected). Keep reading data even when no clients are connected: Close the FIFO when no clients are connected: If the input FIFO reaches EOF or encounters an error, reopen it and keep reading. If the input FIFO reaches EOF or encounters an error, disconnect all clients and exit. Limit CPU usage. The default is to use as many threads as you have CPU cores. Disconnect clients after a specified number of bytes. Limit how fast the input is read. (This is meant for testing. You could also use it to serve static content from a regular file as if it were a live stream, although a regular static file server would probably be a better choice.) Speed is given in bytes per second. The default is to read data as fast as the input FIFO supplies it.


Version published

Readme

Source

streamserve

Efficiently distribute media streams to http clients.

  • Release status: alpha
  • Documentation (same as at godoc.org)
  • TODO
  • AGPLv3

Install binary package (linux amd64):

  • Download a deb, rpm, or tar.bz2 from the Releases page
  • Install it with dpkg, rpm, or tar

Install from source (assuming you have the Go tools installed and $GOPATH/bin is in your PATH):

go get github.com/tomclegg/streamserve

Run:

streamserve -address :44100 \
            -source-buffer 40 \
            -frame-bytes 44100 \
            -reopen \
            -close-idle=false \
            -exec arecord -f cd --file-type raw

streamserve -address :6464 \
            -content-type audio/mpeg \
            -source-buffer 1000 \
            -frame-bytes 300 \
            -frame-filter mp3 \
            -reopen \
            -close-idle \
            -exec sh -c 'curl -sS localhost:44100 | lame -r -h -b 64 -a -m l - -'

Features / design goals

  • Fast. Laptop should handle 1000 clients easily.
  • Small. Use well under 1GB RAM when serving 10 streams to 10K clients.
  • Stream sort-of-streamable formats like mp3.
  • Drop frames when clients are too slow.
  • Keep clients online while sources fail and resume.

FAQs

Last updated on 03 May 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc