Cloud Native 7 min read

Deploy a Dockerized Nginx‑RTMP Live Stream with Watermark and Dual‑Cloud Splitting

This guide shows how to containerize an Nginx‑RTMP live‑streaming service with Docker, add customizable watermarks, and split the stream to two cloud providers—one with watermark and one without—using ffmpeg, SSL, and HLS playback.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Deploy a Dockerized Nginx‑RTMP Live Stream with Watermark and Dual‑Cloud Splitting

The author packaged a live‑streaming system that supports stream splitting and watermarking into a Docker image for easy deployment.

Requirements: split a live stream to two cloud providers (one with watermark, one without) and deliver via HLS playback.

Components used:

Nginx 1.16.1 (compiled from source)

nginx‑rtmp‑module 1.2.1 (compiled from source)

ffmpeg 4.2.1 (compiled from source)

Pre‑configured nginx.conf with watermark image stored at /opt/images/logo.png Supports 1920×1080 resolution (other resolutions can be added by editing nginx.conf)

Deployment Steps

Install Docker (CentOS 7 example):

$ yum -y install docker
$ systemctl enable docker
$ systemctl start docker

Pull and run the Docker image:

$ docker pull ar414/nginx-rtmp-ffmpeg
$ docker run -it -d -p 1935:1935 -p 8080:80 --rm ar414/nginx-rtmp-ffmpeg

Push stream using the address format rtmp://<server ip>:1935/stream/$STREAM_NAME.

Add an SSL certificate inside the container and modify nginx.conf:

listen 443 ssl;
ssl_certificate /opt/certs/example.com.crt;
ssl_certificate_key /opt/certs/example.com.key;

Configure OBS:

Stream Type: Custom Streaming Server URL: rtmp://<server ip>:1935/stream Stream Key: ar414 Test playback with an HLS player (e.g., player.alicdn.com/aliplayer) or an RTMP player such as PotPlayer.

RTMP Configuration (excerpt from nginx.conf )

rtmp {
    server {
        listen 1935;
        chunk_size 4000;
        application stream {
            live on;
            exec ffmpeg -i rtmp://localhost:1935/stream/$name -i /opt/images/ar414.png \
                -filter_complex "overlay=10:10,split=1[ar414]" \
                -map '[ar414]' -map 0:a -s 1920x1080 -c:v libx264 -c:a aac -g 30 -r 30 -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost:1935/hls/$name_wm \
                -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1920x1080 -preset superfast -profile:v baseline rtmp://localhost:1935/hls/$name;
        }
        application hls {
            live on;
            hls on;
            hls_fragment 5;
            hls_path /opt/data/hls;
        }
    }
}

To push the stream to multiple cloud providers, duplicate the exec ffmpeg lines with the appropriate destination URLs (e.g., Tencent Cloud, Aliyun).

Watermark Position Options

Top‑left: overlay=10:10 Top‑right: overlay=main_w-overlay_w-10:10 Bottom‑left: overlay=10:main_h-overlay_h-10 Bottom‑right:

overlay=main_w-overlay_w-10:main_h-overlay_h-10

Overlay Parameters Explained

main_w

– video frame width (configured as 1920) main_h – video frame height (configured as 1080) overlay_w – watermark image width overlay_h – watermark image height

The complete configuration file is available at GitHub .

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerlive streamingWatermarkffmpeghlsRTMP
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.