illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.95k stars 1.52k forks source link

how to transcode a stream to multiple bitrate? #353

Open Ashpreet27 opened 4 years ago

Ashpreet27 commented 4 years ago

Ok so my problem is how to transcode on fly to multiple bitrate(HLS)? is there any sample code?

Ahmed-Bhouri commented 4 years ago

hello, I'm currently looking for the same thing, I found out this Issue is duplicated check #337. @Ashpreet27 if that helped let me know

hthetiot commented 4 years ago

Fixed by 20b8415b5254a74597b0393ab3cb19abaa96b19d can be closed.

ghost commented 4 years ago

This is great! But I'm unsure how to consume the HLS stream when using the new fission server. When I try to hit /live/STREAM_KEY/index.m3u8, nothing is there, and the directory is empty on my server. Here's my config, if anyone has any ideas I would greatly appreciate it.

{
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    mediaroot: './media',
    allow_origin: '*'
  },
  fission: {
    ffmpeg: process.env.FFMPEG_PATH || '/usr/bin/ffmpeg',
    tasks: [
      {
        rule: "live/*",
        model: [
          {
            ab: "128k",            
            vb: "1500k",
            vs: "720x1280",
            vf: "30",          },
          {
            ab: "64k",
            vb: "1000k",
            vs: "480x854",
            vf: "24",
          },
          {
            ab: "32k",
            vb: "600k",
            vs: "360x640",
            vf: "20",
          },
        ]
      },
    ]
  }
}

everything looks good when the stream connects:

0|index  | 7/21/2020 21:05:05 14600 [INFO] Node Media Server v2.2.2
0|index  | 7/21/2020 21:05:05 14600 [INFO] Node Media Rtmp Server started on port: 1935
0|index  | 7/21/2020 21:05:05 14600 [INFO] Node Media Http Server started on port: 8000     
0|index  | 7/21/2020 21:05:05 14600 [INFO] Node Media WebSocket Server started on port: 8000
0|index  | 7/21/2020 21:05:05 14600 [INFO] Node Media Fission Server started, MediaRoot: ./media, ffmpeg version: 4.3-2~18.04.york0
0|index  | 7/21/2020 21:05:14 14600 [INFO] [rtmp connect] id=YTKNNOKY ip=::ffff:71.86.208.34 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; FMSc/1.0)","swfUrl":"rtmp://aflive.app/live","tcUrl":"rtmp://aflive.app/live"}
0|index  | 7/21/2020 21:05:14 14600 [INFO] [rtmp publish] New stream. id=YTKNNOKY streamPath=/live/AFLIVE streamId=1
0|index  | 7/21/2020 21:05:15 14600 [INFO] [rtmp connect] id=PL1FJTTG ip=::ffff:127.0.0.1 app=live args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:1935/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
0|index  | 7/21/2020 21:05:15 14600 [INFO] [rtmp play] Join stream. id=PL1FJTTG streamPath=/live/AFLIVE  streamId=1 
0|index  | 7/21/2020 21:05:16 14600 [INFO] [rtmp publish] Handle audio. id=YTKNNOKY streamPath=/live/AFLIVE sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
0|index  | 7/21/2020 21:05:16 14600 [INFO] [rtmp publish] Handle video. id=YTKNNOKY streamPath=/live/AFLIVE frame_type=1 codec_id=7 codec_name=H264 1280x720
0|index  | 7/21/2020 21:05:16 14600 [INFO] [rtmp connect] id=2KGD5OBS ip=::ffff:127.0.0.1 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf58.45.100)","tcUrl":"rtmp://127.0.0.1:1935/live"}
0|index  | 7/21/2020 21:05:16 14600 [INFO] [rtmp publish] New stream. id=2KGD5OBS streamPath=/live/AFLIVE_1280 streamId=1
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp connect] id=RBWPBZKU ip=::ffff:127.0.0.1 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf58.45.100)","tcUrl":"rtmp://127.0.0.1:1935/live"}
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] New stream. id=RBWPBZKU streamPath=/live/AFLIVE_854 streamId=1
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp connect] id=JMSCITPW ip=::ffff:127.0.0.1 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf58.45.100)","tcUrl":"rtmp://127.0.0.1:1935/live"}
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] New stream. id=JMSCITPW streamPath=/live/AFLIVE_640 streamId=1
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] Handle video. id=2KGD5OBS streamPath=/live/AFLIVE_1280 frame_type=1 codec_id=7 codec_name=H264 720x1280
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] Handle audio. id=2KGD5OBS streamPath=/live/AFLIVE_1280 sound_format=10 sound_type=2 
sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] Handle video. id=RBWPBZKU streamPath=/live/AFLIVE_854 frame_type=1 codec_id=7 codec_name=H264 480x854
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] Handle audio. id=RBWPBZKU streamPath=/live/AFLIVE_854 sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] Handle video. id=JMSCITPW streamPath=/live/AFLIVE_640 frame_type=1 codec_id=7 codec_name=H264 360x640
0|index  | 7/21/2020 21:05:17 14600 [INFO] [rtmp publish] Handle audio. id=JMSCITPW streamPath=/live/AFLIVE_640 sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
MuhammadChandra19 commented 3 years ago

any updates about this issue?