ut0mt8 / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
87 stars 32 forks source link

dash master manifest is not created #14

Closed yandirusdy closed 5 years ago

yandirusdy commented 5 years ago

I already managed to create multiple bitrate from rtmp source using ffmpeg command, but while hls is okay, everything works fine, our dash doesn't have .mpd manifest file which contains all bitrate, only have nested folder for each bitrate. what do we need to make main manifest file generated?

worker_processes  auto;
events {
    # Allows up to 1024 connections, can be adjusted
    worker_connections  1024;
}

# RTMP configuration
rtmp {
    server {
        listen 1935; # Listen on standard RTMP port
        chunk_size 4000; 

        # This application is to accept incoming stream
        application live {
            live on; # Allows live input

            # Once receive stream, transcode for adaptive streaming
            # This single ffmpeg command takes the input and transforms
            # the source into 4 different streams with different bitrate
            # and quality. P.S. The scaling done here respects the aspect
            # ratio of the input.
            exec ffmpeg -i rtmp://localhost/$app/$name -async 1 -vsync -1
                        -c:v libx264 -c:a copy -b:v 256k -b:a 32k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_low
                        -c:v libx264 -c:a copy -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_mid
                        -c:v libx264 -c:a copy -b:v 1024k -b:a 128k -vf "scale=960:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_high
                        -c:v libx264 -c:a copy -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/show/$name_hd720;
        }

        # This application is for splitting the stream into HLS fragments
        application show {
            live on; # Allows live input from above
            hls on; # Enable HTTP Live Streaming

        dash on;
        #dash_nested on;
        dash_repetition on;
        dash_path /home/jenkins/tmp/dash/;

            # Pointing this to an SSD is better as this involves lots of IO
            hls_path /home/jenkins/tmp/hls/;

            # Instruct clients to adjust resolution according to bandwidth
            hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
            hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
            hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
            hls_variant _hd720 BANDWIDTH=2048000 max; # High bitrate, HD 720p resolution

            dash_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
            dash_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
            dash_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
            dash_variant _hd720 BANDWIDTH=2048000 max; # High bitrate, HD 720p resolution
        }
    }
}

http {
    # See http://licson.net/post/optimizing-nginx-for-large-file-delivery/ for more detail
    # This optimizes the server for HLS fragment delivery
    sendfile off;
    tcp_nopush on;
    directio 512;

    # HTTP server required to serve the player and HLS fragments
    server {
        listen 80;

    location /dash {
            types {
                application/dash+xml mpd;
            }

            root /home/jenkins/tmp/;
            add_header Cache-Control no-cache; # Prevent caching of HLS fragments
            add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
            }

            root /home/jenkins/tmp/;
            add_header Cache-Control no-cache; # Prevent caching of HLS fragments
            add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
        }
    }
}

our result look like this

jenkins@srs-live-16:~/tmp$ ls dash/ | grep mpd
teststream_hd720.mpd
teststream_high.mpd
teststream_low.mpd
teststream_mid.mpd
 ls hls/
teststream.m3u8        
teststream_hd720-1.ts  
teststream_high-0.ts  
teststream_high.m3u8  
teststream_low-1.ts  
teststream_mid-0.ts  
teststream_mid.m3u8
teststream_hd720-0.ts  
teststream_hd720.m3u8  
teststream_high-1.ts  
teststream_low-0.ts   
teststream_low.m3u8  
teststream_mid-1.ts
ut0mt8 commented 5 years ago

Hello,

The syntax is different from HLS :

Quoting the doc :

dash_variant _low bandwidth="256000" width="320" height="180";
dash_variant _med bandwidth="832000" width="640" height="360";
dash_variant _hi bandwidth="1024000" width="1024" height="576" max;

Note the with, height keyword. Also not sure about the arg in MAJ. That said not sure about your problem, dig in the log.