{"id":16296544,"url":"https://github.com/f1lt3r/tls-media-streaming-server","last_synced_at":"2025-06-16T19:08:12.658Z","repository":{"id":145878494,"uuid":"94165709","full_name":"F1LT3R/tls-media-streaming-server","owner":"F1LT3R","description":"A simple SSL web server with .mp4 video streaming support.","archived":false,"fork":false,"pushed_at":"2023-07-14T12:35:30.000Z","size":16325,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-12T12:57:51.532Z","etag":null,"topics":["byterange","media","nodejs-server","ssl","streaming","tls","video"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/F1LT3R.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-13T03:38:38.000Z","updated_at":"2023-06-27T23:26:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"b51e21bb-888e-4dd6-bca9-10a71ad9c91d","html_url":"https://github.com/F1LT3R/tls-media-streaming-server","commit_stats":null,"previous_names":["f1lt3r/tls-media-streaming-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/F1LT3R/tls-media-streaming-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Ftls-media-streaming-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Ftls-media-streaming-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Ftls-media-streaming-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Ftls-media-streaming-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/F1LT3R","download_url":"https://codeload.github.com/F1LT3R/tls-media-streaming-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Ftls-media-streaming-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260221379,"owners_count":22976864,"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":["byterange","media","nodejs-server","ssl","streaming","tls","video"],"created_at":"2024-10-10T20:23:07.414Z","updated_at":"2025-06-16T19:08:12.633Z","avatar_url":"https://github.com/F1LT3R.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TLS Media Streaming Server\n\nA simple SSL HTTP server with ByteRange MP4 video streaming support written in NodeJs.\n\nFeatures:\n\n- Uses an SSL certificate for HTTPS (PROD \u0026 DEV)\n- Redirects traffic from HTTP port 80 to HTTPS 443.\n- Can stream MP4 videos as byte ranges.\n- Can serve HTML pages, and a few content types like .css, jpg, .etc.\n\nNote: there are a few 0-byte files in this example. They are intentionally left blank, such as certificate files used to server a trusted HTTPS page. You should replace these with real content.\n\n## MP4 Playback Over 3G Networks\n\nThis server has been optimized to play back MP4 videos over an average 3G connection without stalling.\n\nIn testing, I am able to play video back with a stable 1-2 seconds of unplayed buffer in front of the play head.\n\nThe Byte Range has been optimized for playing h264 video at a size of 640 x 360 pixels, and a `-crf` quality of 26.\n\nI am encoding with `ffmpeg` like so:\n\n```shell\n# Within \".original/\" dir (not deployed):\nfor i in *.mp4; do ffmpeg -i \"$i\" -c:v libx264 -crf 26 -s 640x360 -c:a aac -movflags faststart \"../${i%.*}.mp4\"; done\n```\n\nVideos with this encoding target run slightly lower than an average of 275k bytes per second, or 2.2 million bits per second.\n\nYou can test your output videos the following way:\n\n```shell\nffprobe -v quiet -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 INPUT.MP4\n# 2123581\n```\n\nIf you plan to play media at a different rate, update the `maxChunk` variable in `server/index.js` accordingly:\n\n```\n# File: server/index.js\nconst maxChunk = 275000;\n```\n\n## Setup\n\n- `git clone git@github.com:f1lt3r/tls-media-server.git`\n- `cd tls-media-server`\n- `npm install`\n- `npm install -g htdigest` (encrypted user/pass generation w/ nonce)\n- `npm install -g pm2` (keep server alive)\n- `cp -r ./secrets-example ./secrets`\n- Populate your `./secrets` certificate files and htdigest file. \n- DEV: Create your Dev Env  SSL Certificates (see below)\n- PROD: Allow ports 80 and 443 in your firewall if you are in production\n- `htdigest ./secrets/htdigest Users \u003cNEW-USERNAME\u003e` (see Adding Users below)\n- PROD: Update your `DOMAIN`, `ENVIRONMENT` environment variables in `ecosystem.config.js`\n- Update your `SERVE` directory in `ecosystem.config.js`.\n- Start the server: `pm2 start ecosystem.config.js`\n\n## Create Dev Env SSL Certificate\n\n```shell\n# Create your cert pem \nopenssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365\n\n# You will be asked to fill out the following\nEnter PEM pass phrase: \u003cPASSWORD\u003e\nVerifying - Enter PEM pass phrase: \u003cPASSWORD\u003e\n-----\nYou are about to be asked to enter information that will be incorporated\ninto your certificate request.\nWhat you are about to enter is what is called a Distinguished Name or a DN.\nThere are quite a few fields but you can leave some blank\nFor some fields there will be a default value,\nIf you enter '.', the field will be left blank.\n-----\nCountry Name (2 letter code) [AU]:US\nState or Province Name (full name) [Some-State]:New York\nLocality Name (eg, city) []:New York\nOrganization Name (eg, company) [Internet Widgits Pty Ltd]:DEV.INC\nOrganizational Unit Name (eg, section) []: \u003cBLANK\u003e\nCommon Name (e.g. server FQDN or YOUR name) []:localhost\nEmail Address []:admin@dev.inc\n\n\n# Create your key pem file\nopenssl rsa -in keytmp.pem -out key.pem\n# You will see this password prompt:\n\n#Enter pass phrase for keytmp.pem: \u003cPASSWORD\u003e\n\n# Remove your temporary RSA key file\nrm keytmp.pem\n\n\n# Move your cert and key  to the .secrets folder\nmv cert.pem .secrets/DEV.crt.pem\nmv key.pem .secrets/DEV.key.pem\n```\n\n- Run the server.\n- Launch the browser at: https://localhost:8443/\n- Type `thisisunsafe` (Bypasses SSL cert in Chromium browsers)\n\n## Secrets\n\nThe `./secrets` directory contains things that you do not want to share publicly; like passwords, certificate keys and a source file to provide paths to secret files in your environment.\n\nFor example:\n\n- SSL Certification\n\t+ DEV Cert file\n\t+ DEV Key file\n\t+ CA Bundle file\n\t+ Key file\n\t+ Cert file\n- htdigest file (contains encrypted passwords)\n\n## Adding Users\n\nTo add a user to the `htdigest` file:\n\n```shell\n# It appears you MUST cd into the dir you are updating your htdigest file\ncd ./secrets\n# Digest file can be blank text file to start\n# Eg: htdigest ./secrets/example.com.htdigest Users \u003cusername\u003e\nhtdigest ./secrets/example.com.htdigest Users alice\n# You will be prompted for a password and confirmation\n```\n\n## Generating SSL Certificates for Production\n\nI am using NameCheap SSL, Ubuntu 18 and a Digital Ocean Droplet.\n\n```shell\nmkdir ~/.ssl\n\nopenssl req -new -newkey rsa:2048 -nodes -keyout \u003cDOMAIN.TLD\u003e.key -out \u003cDOMAIN.TLD\u003e.csr\n\n# Organization and Unit can be \"NA\"\n\n# YOU MUST leave Challenge Password and OptionalCompanyName empty!\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff1lt3r%2Ftls-media-streaming-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff1lt3r%2Ftls-media-streaming-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff1lt3r%2Ftls-media-streaming-server/lists"}