Git Product home page Git Product logo

videostreamer's Introduction

videostreamer provides a way to stream video from an input source to HTTP. It remuxes a given video input into an MP4 container which it then streams to any connecting clients. This provides the ability to stream an input source that may have limited connections, is not accessible via HTTP, or is not easily embeddable in a website.

Background

A friend has a camera that publishes an RTSP feed containing h264 video. It permits a limited number of connections, and being RTSP is not easily accessible on the web, such as in a regular HTML5 <video> element. videostreamer solves both of these problems. It reads the RTSP feed as input, remuxes the h264 video into an MP4 container, and streams it to HTTP clients. No matter how many clients are streaming the video, videostreamer only opens one RTSP connection.

Happily, browsers support h264 in an MP4 container, so no transcoding is necessary. However, in order to stream the MP4, it is fragmented using libavformat's frag_keyframe option. I found that for Firefox I also had to set the empty_moov option.

Difference from audiostreamer

I have a project for streaming audio called audiostreamer. I wrote it before this one, and seeing it was successful and gave me experience with the ffmpeg libraries, I decided to build this too.

Initially I was going to make one larger project to stream either video or audio (or both), but I found that video behaved a bit differently than audio. Specifically, audiostreamer is able to create a single MP3 container and then stream that to clients, starting at any frame position. For the video container I wanted to use, I found this was not possible. First, I always needed to send a header to each client, which meant I needed to keep the header around in some way to send to every client. I found that I could not gain access to the header from the libavformat API. Second, I was not able to read individual frames out and send them independently like I could do with MP3. This meant it was impossible to know where in the MP4 container's output I could begin sending to a new client when another client was already streaming.

Since it became clear that I would have to structure the program quite differently, and I was happy with how audiostreamer was, I decided to build videostreamer as a separate project.

Requirements

  • ffmpeg (libavcodec, libavformat, libavdevice, libavutil, libswresample). I developed using 3.2.2. On Debian this is in the package libavutil-dev.
  • C compiler. I developed using gcc 6.2.1.
  • Go. I developed using 1.7.3.

Installation

  • go get github.com/horgh/videostreamer
  • go build
  • Place index.html somewhere accessible. Update the <video> element src attribute.
  • Run the daemon. Its usage output shows the possible flags. There is no configuration file.

Components

  • videostreamer: A daemon. The main component of the project.
  • index.html: A small sample website with a <video> element which demonstrates how to stream from the daemon.
  • videostreamer.h: A library using the ffmpeg libraries to read a video input and remux and write to another format.
  • cmd/remux_example: A C program demonstrating using videostreamer.h. It remuxes from a given RTSP input to an MP4 file.

videostreamer's People

Contributors

horgh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.