Sign inSign up

imvickykumar999/youtube-stream

By imvickykumar999

•Updated 9 months ago

https://github.com/imvickykumar999/Efficient-24x7-Image

Image
Developer tools
Content management system
1

1.1K

imvickykumar999/youtube-stream repository overview

⁠Docker Hub - Pull and Run Guide

Optimized YouTube 24/7 streaming script that reduces costs from ~$2 to ~$0.20 by eliminating unnecessary video processing.

Cost Effective: 
    Optimized to run within the Railway free trial limit. You can stream 24/7 for up to a week before needing to upgrade your plan or switch accounts.

stream

graph

env

This guide explains how to pull and run the pre-built Docker image from Docker Hub⁠.

⁠Quick Start

⁠1. Pull the Image
docker pull imvickykumar999/youtube-stream:latest
⁠2. Run with Environment Variables
docker run -d --name youtube-stream \
  -e STREAM_KEY=your_youtube_stream_key_here \
  -e YouTube_ID=your_youtube_video_id_here \
  imvickykumar999/youtube-stream:latest
⁠3. Or Use a .env File

Create a .env file in your current directory:

STREAM_KEY=your_youtube_stream_key_here
YouTube_ID=your_youtube_video_id_here

Then run:

docker run -d --name youtube-stream \
  --env-file .env \
  imvickykumar999/youtube-stream:latest

⁠Detailed Instructions

⁠Prerequisites
  • Docker installed on your system
  • YouTube Live stream key (get it from YouTube Studio⁠)
  • YouTube video ID to stream
⁠Step-by-Step Guide
⁠Step 1: Pull the Latest Image
docker pull imvickykumar999/youtube-stream:latest

This will download the pre-built image from Docker Hub. You only need to do this once, or when you want to update to the latest version.

⁠Step 2: Get Your YouTube Credentials
  1. YouTube Stream Key:

  2. YouTube Video ID:

    • Extract the video ID from a YouTube URL
    • Example: For https://www.youtube.com/watch?v=oY7SfTpyRco, the ID is oY7SfTpyRco
⁠Step 3: Run the Container

Option A: Using Environment Variables (Direct)

docker run -d \
  --name youtube-stream \
  -e STREAM_KEY=qvfy-u9ar-1900-63qx-625y \
  -e YouTube_ID=oY7SfTpyRco \
  imvickykumar999/youtube-stream:latest

Option B: Using .env File (Recommended)

  1. Create a .env file:

    echo "STREAM_KEY=your_stream_key_here" > .env
    echo "YouTube_ID=your_video_id_here" >> .env
    
  2. Run the container:

    docker run -d \
      --name youtube-stream \
      --env-file .env \
      imvickykumar999/youtube-stream:latest
    
⁠Step 4: Monitor the Stream

View the container logs:

docker logs -f youtube-stream

Press Ctrl+C to exit the log view (this won't stop the container).

⁠Step 5: Check Container Status
docker ps

You should see youtube-stream in the list if it's running.

⁠Managing the Container
⁠Stop the Container
docker stop youtube-stream
⁠Start a Stopped Container
docker start youtube-stream
⁠Remove the Container
docker stop youtube-stream
docker rm youtube-stream

Or force remove (stops and removes in one command):

docker rm -f youtube-stream
⁠Restart the Container
docker restart youtube-stream
⁠Troubleshooting
⁠Container Exits Immediately

Check the logs to see what went wrong:

docker logs youtube-stream

Common issues:

  • Missing or invalid STREAM_KEY
  • Missing or invalid YouTube_ID
  • Network connectivity issues
⁠Update to Latest Version
docker pull imvickykumar999/youtube-stream:latest
docker stop youtube-stream
docker rm youtube-stream
docker run -d --name youtube-stream --env-file .env imvickykumar999/youtube-stream:latest
⁠View Resource Usage
docker stats youtube-stream

This shows real-time CPU, memory, and network usage.

⁠Docker Compose (Alternative)

Create a docker-compose.yml file:

version: '3.8'

services:
  youtube-stream:
    image: imvickykumar999/youtube-stream:latest
    container_name: youtube-stream
    env_file:
      - .env
    restart: unless-stopped

Then run:

docker-compose up -d

View logs:

docker-compose logs -f

Stop:

docker-compose down

⁠Image Details

  • Image: imvickykumar999/youtube-stream:latest
  • Base Image: Python 3.11-slim
  • Includes: FFmpeg, yt-dlp, python-dotenv
  • Size: ~500-600 MB (compressed)

⁠Features

  • ✅ Optimized for low CPU usage
  • ✅ Automatic video download from YouTube
  • ✅ 360p streaming support for cost efficiency
  • ✅ Infinite video loop
  • ✅ Keyframe optimization for YouTube Live compatibility

⁠Support

For issues or questions:

Tag summary

Content type

Image

Digest

sha256:494820e56…

Size

217 MB

Last updated

9 months ago

docker pull imvickykumar999/youtube-stream