Este repositório contém um ecossistema completo de transmissão de vídeo e áudio em direto (streaming multicanais) baseado no protocolo RTMP. Utiliza o Docker para contentorizar o servidor de media Nginx e disponibiliza uma interface web (HTML/JavaScript) para a reprodução dos canais de Web TV e Radio TV em tempo real.
This repository contains a complete live video and audio streaming ecosystem (multi-channel streaming) based on the RTMP protocol. It uses Docker to containerize the Nginx media server and provides a web interface (HTML/JavaScript) to play Web TV and Radio TV channels in real time.
Clique abaixo para expandir as instruções no idioma de preferência:
🇵🇹 Português (Clique para expandir)
- Servidor RTMP/HLS: Docker com a imagem oficial
tiangolo/nginx-rtmp - Emissor (Input): OBS Studio (Instalado localmente na máquina de transmissão)
- Recetor/Player (Output): Interface Web nativa em HTML5 e JavaScript
Antes de iniciar o projeto, certifique-se de que tem as seguintes ferramentas instaladas:
- Docker
- Docker Compose
- OBS Studio
Abra o seu terminal, clone este projeto e suba os contentores:
# Clonar o projeto
git clone https://github.com/Lavbella/streaming.git
# Entrar na pasta correta do repositório
cd streaming
# Iniciar o ecossistema Docker (Primeira execução)
docker compose up -d --buildNota para arranques futuros (Sem Build): Se já realizou a build inicial e não fez alterações estruturais no código, pode iniciar o projeto de forma muito mais rápida omitindo o parâmetro de compilação:
docker compose up -dPara transmitir o ecrã, uma janela ou a imagem da sua câmara para o servidor Nginx-RTMP:
- Abra o OBS Studio.
- Aceda a Definições (Settings) > Transmissão (Stream).
- No campo Serviço (Service), selecione Personalizado... (Custom...).
- Preencha os campos exatamente com os seguintes dados:
- Servidor (Server):
rtmp://localhost/live - Chave de Transmissão (Stream Key):
teste
- Servidor (Server):
- Clique em Aplicar e depois em Iniciar Transmissão (Start Streaming). O OBS estabelecerá a ligação direta ao seu contentor Docker local.
Após iniciar a transmissão no OBS, abra o seu navegador de internet e aceda ao seguinte endereço:
A interface integrada em HTML e JavaScript irá carregar o leitor de vídeo correspondente, permitindo alternar entre as emissões e exibir o fluxo transmitido pelo OBS em tempo real.
O ambiente está configurado e isolado através do Docker Compose utilizando o seguinte mapeamento de portas:
- 1935:1935 -> Porta RTMP padrão utilizada para receber o fluxo de vídeo enviado pelo OBS Studio.
- 8080:80 -> Porta HTTP utilizada para servir os ficheiros da interface web e os fragmentos de vídeo gerados pelo servidor.
Caso necessite de inspecionar o tráfego, verificar problemas de ligação ou validar se o fluxo do OBS está a chegar corretamente ao Nginx, utilize os comandos de logs no terminal:
# Monitorizar os logs de todos os serviços em tempo real
docker compose logs -f
# Filtrar e monitorizar apenas os logs do servidor Nginx-RTMP
docker compose logs -f nginxPara encerrar a execução dos serviços e libertar as portas do sistema sem eliminar as imagens geradas, execute:
docker compose down🇬🇧 English (Click to expand)
- RTMP/HLS Server: Docker using the official
tiangolo/nginx-rtmpimage - Broadcaster (Input): OBS Studio (Installed locally on the streaming machine)
- Receiver/Player (Output): Native Web Interface using HTML5 and JavaScript
Before starting the project, make sure you have the following tools installed on your machine:
- Docker
- Docker Compose
- OBS Studio
Open your terminal, clone this project, and spin up the containers:
# Clone the project
git clone https://github.com/Lavbella/streaming.git
# Enter the correct repository folder
cd streaming
# Start the Docker ecosystem (First-time execution)
docker compose up -d --buildNote for future startups (Without Build): If you have already completed the initial build and haven't made any structural changes to the code, you can start the project much faster by omitting the compilation flag:
docker compose up -dTo stream your screen, a specific window, or your camera feed to the Nginx-RTMP server:
- Open OBS Studio.
- Go to Settings > Stream.
- In the Service dropdown, select Custom....
- Fill in the fields exactly with the following data:
- Server:
rtmp://localhost/live - Stream Key:
teste
- Server:
- Click Apply and then click Start Streaming. OBS will establish a direct connection to your local Docker container.
After starting the stream in OBS, open your web browser and navigate to the following address:
The built-in HTML and JavaScript interface will load the corresponding video player, allowing you to switch between broadcasts and view the live feed from OBS in real-time.
The environment is configured and isolated through Docker Compose using the following port mappings:
- 1935:1935 -> Default RTMP port used to receive the video stream sent by OBS Studio.
- 8080:80 -> HTTP port used to serve the web interface files and the video fragments generated by the server.
If you need to inspect traffic, troubleshoot connection issues, or verify that the OBS stream is reaching Nginx properly, run the log commands in your terminal:
# Monitor logs from all services simultaneously in real-time
docker compose logs -f
# Filter and monitor only the Nginx-RTMP server logs
docker compose logs -f nginxTo shut down the services and free up system ports without deleting the generated Docker images, run:
docker compose downProject developed by Lavbella.