ut0mt8 / nginx-rtmp-module

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

Audio only representation #6

Closed nistvan86 closed 6 years ago

nistvan86 commented 7 years ago

I'm testing your module, but it seems it's not capable of handling audio only streaming with multiple representations. If i try to fool it and write some dummy width & height parameters, it only writes a single audio representation out (the one flagged with "max").

My config:

events {
    worker_connections  1024;
}

error_log  logs/error.log  info;
user root;

# RTMP configuration
rtmp {
    server {
        listen 1935;

        application live {
            live on;

            exec /usr/local/bin/ffmpeg -i rtmp://localhost/$app/$name -async 1
                        -vn -ar 32000 -c:a libfdk_aac -profile:a aac_he_v2 -b:a 22k -f flv rtmp://localhost/show/$name_low
                        -vn -ar 32000 -c:a libfdk_aac -profile:a aac_he -b:a 56k -f flv rtmp://localhost/show/$name_mobile
                        -vn -ar 44100 -c:a libfdk_aac -cutoff 16000 -b:a 128k -f flv rtmp://localhost/show/$name_standard
                        -vn -ar 44100 -c:a libfdk_aac -cutoff 20000 -b:a 256k -f flv rtmp://localhost/show/$name_hq
                        -f flv rtmp://localhost/show/$name_src 2>>/tmp/log;
        }

        application show {
            live on;
            dash on;
            dash_nested on;

            dash_cleanup on;
            dash_fragment 2;
            dash_playlist_length 120;
            dash_variant _low bandwidth="22000" width="1" height="1";
            dash_variant _mobile bandwidth="56000" width="2" height="2";
            dash_variant _standard bandwidth="128000" width="3" height="3";
            dash_variant _hq bandwidth="256000" width="4" height="4" max;

            dash_path /tmp/nginx/dash/;
        }
    }
}

http {
    server {
        listen 8080;

        location /dash {
            alias /tmp/nginx/dash;
            add_header Cache-Control no-cache;
            add_header Access-Control-Allow-Origin *;
        }
    }
}

The resulting variant mpd file looks like this:

<?xml version="1.0"?>
<MPD
    type="dynamic"
    xmlns="urn:mpeg:dash:schema:mpd:2011"
    availabilityStartTime="2017-07-29T13:08:58Z"
    publishTime="2017-07-29T13:08:58Z"
    minimumUpdatePeriod="PT2.021S"
    minBufferTime="PT2.000S"
    timeShiftBufferDepth="P0Y00M00DT0H02M01.208S"
    suggestedPresentationDelay="PT5.042S"
    profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff-live:2011"
    xmlns:xsi="http://www.w3.org/2011/XMLSchema-instance"
    xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd">
  <Period start="PT0S" id="dash">
    <AdaptationSet
        id="2"
        startWithSAP="1"
        segmentAlignment="true">
      <AudioChannelConfiguration
          schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
          value="1"/>
      <Representation
          id="demo_hq_AAC"
          mimeType="audio/mp4"
          codecs="mp4a.40.2"
          audioSamplingRate="44100"
          bandwidth="250000">
        <SegmentTemplate
            presentationTimeOffset="0"
            timescale="1000"
            media="demo_hq/$Time$.m4a"
            initialization="demo_hq/init.m4a">
          <SegmentTimeline>
             <S t="240396" d="2020"/>
             <S t="242416" d="2020"/>
             <S t="244436" d="2020"/>
             <S t="246456" d="2020"/>
             <S t="248476" d="2020"/>
             <S t="250496" d="2021"/>
             <S t="252517" d="2020"/>
             <S t="254537" d="2020"/>
             <S t="256557" d="2020"/>
             <S t="258577" d="2020"/>
             <S t="260597" d="2020"/>
             <S t="262617" d="2020"/>
             <S t="264637" d="2021"/>
             <S t="266658" d="2020"/>
             <S t="268678" d="2020"/>
             <S t="270698" d="2020"/>
             <S t="272718" d="2020"/>
             <S t="274738" d="2020"/>
             <S t="276758" d="2020"/>
             <S t="278778" d="2020"/>
             <S t="280798" d="2021"/>
             <S t="282819" d="2020"/>
             <S t="284839" d="2020"/>
             <S t="286859" d="2020"/>
             <S t="288879" d="2020"/>
             <S t="290899" d="2020"/>
             <S t="292919" d="2020"/>
             <S t="294939" d="2021"/>
             <S t="296960" d="2020"/>
             <S t="298980" d="2020"/>
             <S t="301000" d="2020"/>
             <S t="303020" d="2020"/>
             <S t="305040" d="2020"/>
             <S t="307060" d="2020"/>
             <S t="309080" d="2021"/>
             <S t="311101" d="2020"/>
             <S t="313121" d="2020"/>
             <S t="315141" d="2020"/>
             <S t="317161" d="2020"/>
             <S t="319181" d="2020"/>
             <S t="321201" d="2020"/>
             <S t="323221" d="2020"/>
             <S t="325241" d="2021"/>
             <S t="327262" d="2020"/>
             <S t="329282" d="2020"/>
             <S t="331302" d="2020"/>
             <S t="333322" d="2020"/>
             <S t="335342" d="2020"/>
             <S t="337362" d="2020"/>
             <S t="339382" d="2021"/>
             <S t="341403" d="2020"/>
             <S t="343423" d="2020"/>
             <S t="345443" d="2020"/>
             <S t="347463" d="2020"/>
             <S t="349483" d="2020"/>
             <S t="351503" d="2020"/>
             <S t="353523" d="2021"/>
             <S t="355544" d="2020"/>
             <S t="357564" d="2020"/>
             <S t="359584" d="2020"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>
ut0mt8 commented 7 years ago

Yep this fork is not able to handle different audio representation but only video one. (this is the principal use case). That said, it will be really easy to make this working (10 lines of code I think). If I had I will look at it but this is unlikely to happen...

nistvan86 commented 7 years ago

In the meantime I've tried nginx-ts-module and it works perfectly for this use case.