{"id":13508293,"url":"https://github.com/horgh/videostreamer","last_synced_at":"2025-04-09T13:04:48.294Z","repository":{"id":15222750,"uuid":"77756301","full_name":"horgh/videostreamer","owner":"horgh","description":"Stream video (e.g. RTSP) to an HTML5 video element (MP4)","archived":false,"fork":false,"pushed_at":"2022-03-10T01:08:07.000Z","size":55,"stargazers_count":268,"open_issues_count":9,"forks_count":59,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-10-19T07:04:01.000Z","etag":null,"topics":["ffmpeg","ffmpeg-libraries","golang","rtsp","rtsp-feed","streaming","streaming-video","video"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/horgh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-31T21:18:02.000Z","updated_at":"2024-10-11T06:57:53.000Z","dependencies_parsed_at":"2022-07-22T14:02:20.713Z","dependency_job_id":null,"html_url":"https://github.com/horgh/videostreamer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horgh%2Fvideostreamer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horgh%2Fvideostreamer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horgh%2Fvideostreamer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horgh%2Fvideostreamer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/horgh","download_url":"https://codeload.github.com/horgh/videostreamer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045230,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffmpeg","ffmpeg-libraries","golang","rtsp","rtsp-feed","streaming","streaming-video","video"],"created_at":"2024-08-01T02:00:50.980Z","updated_at":"2025-04-09T13:04:48.272Z","avatar_url":"https://github.com/horgh.png","language":"C","funding_links":[],"categories":["C","video"],"sub_categories":[],"readme":"# videostreamer\nvideostreamer provides a way to stream video from an input source to HTTP.\nIt remuxes a video input into an MP4 container which it streams to\nconnecting clients. This provides the ability to stream an input source\nthat may have limited connections (it opens at most one connection to the\ninput), is not accessible via HTTP, or is not easily embeddable in a\nwebsite.\n\n\n## Build requirements\n* ffmpeg libraries (libavcodec, libavformat, libavdevice, libavutil,\n  libswresample).\n  * It should work with versions 3.2.x or later.\n  * It does not work with 3.0.x or earlier as it depends on new APIs.\n  * I'm not sure whether it works with 3.1.x.\n* C compiler. Currently it requires a compiler with C11 support.\n* Go. It should work with any Go 1 version.\n\n\n## Installation\n* Install the build dependencies (including ffmpeg libraries and a C\n  compiler).\n  * On Debian/Ubuntu, these packages should include what you need:\n    `git-core pkg-config libavutil-dev libavcodec-dev libavformat-dev\n    libavdevice-dev`\n* Build the daemon.\n  * You need a working Go build environment.\n  * Run `go get github.com/horgh/videostreamer`\n  * This places the `videostreamer` binary at `$GOPATH/bin/videostreamer`.\n* Place index.html somewhere accessible. Update the `\u003cvideo\u003e` element src\n  attribute.\n* Run the daemon. Its usage output shows the possible flags. There is no\n  configuration file.\n\n## Running with docker-compose\n\n1. Copy the provided example environment file `.env.example`\n```shell\ncp .env.example .env\n```\n2. Edit the `.env` environment file with your config, especially the path towards your source input.\n\n3. Run the app with docker-compose\n```shell\ndocker-compose up\n# docker-compose up --build # if you wish to rebuild the docker image\n```\n\n4. Use your favorite browser to open the `index.html` and you're good!\n\n## Components\n* `videostreamer`: The daemon.\n* `index.html`: A small sample website with a `\u003cvideo\u003e` element which\n  demonstrates how to stream from the daemon.\n* `videostreamer.h`: A library using the ffmpeg libraries to read a video\n  input and remux and write to another format.\n* `cmd/remux_example`: A C program demonstrating using `videostreamer.h`.\n  It remuxes an RTSP input to an MP4 file.\n\n\n## Background\nA friend has a camera that publishes an RTSP feed containing h264 video. It\npermits a limited number of connections, and being RTSP is not easily\naccessible on the web, such as in an HTML5 `\u003cvideo\u003e` element. videostreamer\nsolves both of these problems. It reads the RTSP feed as input, remuxes the\nh264 video into an MP4 container, and streams it to HTTP clients. No matter\nhow many clients are streaming the video, videostreamer only opens one RTSP\nconnection.\n\nBrowsers support h264 in an MP4 container, so no transcoding is necessary.\nHowever, in order to stream the MP4, it is fragmented using libavformat's\n`frag_keyframe` option. For Firefox I also had to set the `empty_moov`\noption.\n\n\n# Difference from audiostreamer\nI have a project for streaming audio called\n[audiostreamer](https://github.com/horgh/audiostreamer). I wrote it before this\none, and seeing it was successful and gave me experience with the ffmpeg\nlibraries, I decided to build this too.\n\nInitially I was going to make one larger project to stream either video or audio\n(or both), but I found that video behaved a bit differently than audio.\nSpecifically, audiostreamer is able to create a single MP3 container and then\nstream that to clients, starting at any frame position. For the video container\nI wanted to use, I found this was not possible. First, I always needed to send\na header to each client, which meant I needed to keep the header around in some\nway to send to every client. I found that I could not gain access to the header\nfrom the libavformat API. Second, I was not able to read individual frames out\nand send them independently like I could do with MP3. This meant it was\nimpossible to know where in the MP4 container's output I could begin sending to\na new client when another client was already streaming.\n\nSince it became clear that I would have to structure the program quite\ndifferently, and I was happy with how audiostreamer was, I decided to build\nvideostreamer as a separate project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorgh%2Fvideostreamer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhorgh%2Fvideostreamer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorgh%2Fvideostreamer/lists"}