Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from NGINX-RTMP, support HLS variant, multiple bitrate, HLS multi-bitrate #463

Closed
winlinvip opened this issue Aug 23, 2015 · 6 comments
Assignees
Labels
Feature It's a new feature. TransByAI Translated by AI/GPT. Won't fix We won't fix it.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented Aug 23, 2015

https://github.com/arut/nginx-rtmp-module/wiki/Directives#hls_variant
NGINX-RTMP matches several stream names and then generates a single HLS multi-bitrate stream.

TRANS_BY_GPT3

@winlinvip winlinvip added the Feature It's a new feature. label Aug 23, 2015
@winlinvip winlinvip modified the milestones: srs 3.0 release, srs 4.0 release Aug 23, 2015
@mbeacom
Copy link

mbeacom commented Jan 26, 2016

@winlinvip Is this something you're looking for contributions on or do you plan to write this yourself? Thanks for everything!

@winlinvip
Copy link
Member Author

Both are ok.

@jpransxdev
Copy link

This would be crazy useful. I stumbled upon SRS and was very excited but with no support for HLS variants SRS does not fit my use case :) Unfortunately am unable to contribute to this :(

@winlinvip
Copy link
Member Author

Plan in SRS4.

@jb-alvarado
Copy link
Contributor

jb-alvarado commented Jun 14, 2019

For people how needs this feature: you can realize this now already with srs:

  • prepare your defaultVhost with transcoding:
transcode live/stream {
        enabled     on;
        ffmpeg      /usr/local/bin/ffmpeg;
        engine half {
            enabled         on;
            iformat         live_flv;
            vfilter {
                v           quiet;
            }

            vcodec          libx264;
            vfps            25;
            vwidth          512;
            vheight         288;
            vprofile        main;
            vpreset         medium;

            vparams {
                crf         23;
                x264opts    keyint=50:min-keyint=50:no-scenecut;
                maxrate     650k;
                bufsize     1300k;
            }

            acodec          copy;
            oformat         flv;
            output          rtmp://localhost:1935/live/half;
        }
    }

    hls {
        enabled         on;
        hls_path        /var/www/srs/live;
        hls_fragment    6;
        hls_window      1800;
        hls_cleanup     on;
        hls_dispose     5;
        hls_m3u8_file   [stream]_hq.m3u8;
        hls_ts_file     [stream]_hq-[seq].ts;
    }
  • then add a second vhost for localhost and add there a new hls statement:
    hls {
        enabled         on;
        hls_path        /var/www/srs/live;
        hls_fragment    6;
        hls_window      1800;
        hls_cleanup     on;
        hls_dispose     5;
        hls_m3u8_file   [stream]_lq.m3u8;
        hls_ts_file     [stream]_lq-[seq].ts;
    }
  • then create a master.m3u8:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:YES
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:15
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2149280,CODECS="mp4a.40.2,avc1.64001f",RESOLUTION=1024x576,NAME="1024"
live/stream_hq.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=460560,CODECS="mp4a.40.5,avc1.420016",RESOLUTION=512x288,NAME="512"
live/half_lq.m3u8
  • set the correct BANDWIDTH

If you need more resolutions just add in transcode more outputs under vparams, maybe like this:

...
s           1024x576;
crf         23;
x264opts    keyint=50:min-keyint=50:no-scenecut;
maxrate     1300k;
bufsize     2600k;
f           flv;
c:a         copy;
y           rtmp://127.0.1.1:1935/live/big;
crf         23;
x264opts    keyint=50:min-keyint=50:no-scenecut;
maxrate     650k;
bufsize     1300k;
...

and add more vhosts.

Here is a working gist

@winlinvip
Copy link
Member Author

@jb-alvarado 👍 Thanks! It's a better solution to use FFMPEG to transcode RTMP to multiple HLS streams.

@winlinvip winlinvip self-assigned this Sep 25, 2021
@winlinvip winlinvip added the Won't fix We won't fix it. label Sep 25, 2021
@winlinvip winlinvip changed the title Migrate from NGINX-RTMP, support HLS variant, multiple bitrate, HLS多码率 Migrate from NGINX-RTMP, support HLS variant, multiple bitrate, HLS multi-bitrate Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature It's a new feature. TransByAI Translated by AI/GPT. Won't fix We won't fix it.
Projects
None yet
Development

No branches or pull requests

4 participants