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

Is it possible to restream to Youtube? #196

Open
durygus opened this issue Apr 30, 2019 · 36 comments
Open

Is it possible to restream to Youtube? #196

durygus opened this issue Apr 30, 2019 · 36 comments

Comments

@durygus
Copy link

durygus commented Apr 30, 2019

No description provided.

@parthibd
Copy link

parthibd commented May 1, 2019

Please check the readme .

@durygus
Copy link
Author

durygus commented May 1, 2019

Thanks, I can't do it, although I tried many configuration options in relay mode. And how would you do it?

@durygus
Copy link
Author

durygus commented May 1, 2019

Where do I have to specify the "stream name / key" that Google broadcasts authenticates?

@durygus
Copy link
Author

durygus commented May 1, 2019

Here is how I did it:

  1. My Node-Media-Server config:
    const config = {
    logType: 3,

rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 30,
ping_timeout: 60
},
http: {
port: 8000,
mediaroot: './media',
allow_origin: '*'
},

relay: {
ffmpeg: '/usr/local/bin/ffmpeg',
tasks: [
{
app: 'live',
mode: 'push',
edge: 'rtmp://a.rtmp.youtube.com/live2',
name: '{secret stream name/key from Youtube Stream Now}',
}
]
}
};

  1. Lanched a video stream:
    ffmpeg -re -i ~/Downloads/temp/Ma\ Long\ Forehand\ and\ Backhand\ Technique.mp4 -c copy -f flv rtmp://192.168.31.230/live/

  2. Console output:
    5/1/2019 11:06:48 31572 [INFO] Node Media Server v2.1.0
    5/1/2019 11:06:49 31572 [INFO] Node Media Rtmp Server started on port: 1935
    5/1/2019 11:06:49 31572 [INFO] Node Media Http Server started on port: 8000
    5/1/2019 11:06:49 31572 [INFO] Node Media WebSocket Server started on port: 8000
    5/1/2019 11:06:49 31572 [INFO] Node Media Relay Server started
    5/1/2019 11:13:20 31572 [INFO] [rtmp connect] id=BHTK17JL ip=::ffff:192.168.31.216 app=live args={"app":"live","type":"nonprivate","tcUrl":"rtmp://192.168.31.230/live"}
    5/1/2019 11:13:20 31572 [INFO] [rtmp publish] New stream. id=BHTK17JL streamPath=/live/ streamId=1
    5/1/2019 11:13:20 31572 [FFDEBUG] -fflags,nobuffer,-i,rtmp://127.0.0.1:1935/live/,-c,copy,-f,flv,rtmp://a.rtmp.youtube.com/live2/
    5/1/2019 11:13:20 31572 [INFO] [Relay dynamic push] start BHTK17JL rtmp://127.0.0.1:1935/live/ to rtmp://a.rtmp.youtube.com/live2/
    5/1/2019 11:13:20 31572 [INFO] [rtmp publish] Handle video. id=BHTK17JL streamPath=/live/ frame_type=1 codec_id=7 codec_name=H264 1280x720
    5/1/2019 11:13:20 31572 [INFO] [rtmp publish] Handle audio. id=BHTK17JL streamPath=/live/ sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
    5/1/2019 11:13:20 31572 [FFDEBUG] FF输出:ffmpeg version N-91148-g8557a0940e Copyright (c) 2000-2018 the FFmpeg developers
    built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
    configuration:
    5/1/2019 11:13:20 31572 [FFDEBUG] FF输出: libavutil 56. 18.102 / 56. 18.102
    libavcodec 58. 19.102 / 58. 19.102
    libavformat 58. 16.100 / 58. 16.100
    libavdevice 58. 4.100 / 58. 4.100
    libavfilter 7. 24.100 / 7. 24.100
    libswscale 5. 2.100 / 5. 2.100
    libswresample 3. 2.100 / 3. 2.100
    5/1/2019 11:13:20 31572 [INFO] [rtmp connect] id=GS4LBHCY 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}
    5/1/2019 11:13:21 31572 [INFO] [rtmp play] Join stream. id=GS4LBHCY streamPath=/live/ streamId=1
    5/1/2019 11:13:23 31572 [FFDEBUG] FF输出:Input #0, flv, from 'rtmp://127.0.0.1:1935/live/':
    Metadata:
    major_brand : mp42
    5/1/2019 11:13:23 31572 [FFDEBUG] FF输出: minor_version : 0
    compatible_brands: isommp42
    encoder : Lavf58.20.100
    Duration: 00:00:00.00, start: 0.040000, bitrate: N/A
    Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 125 kb/s
    Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 815 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
    5/1/2019 11:13:23 31572 [FFDEBUG] FF输出:rtmp://a.rtmp.youtube.com/live2/: Input/output error
    5/1/2019 11:13:23 31572 [INFO] [rtmp play] Close stream. id=GS4LBHCY streamPath=/live/ streamId=1
    5/1/2019 11:13:23 31572 [INFO] [rtmp disconnect] id=GS4LBHCY
    5/1/2019 11:13:23 31572 [INFO] [Relay end] id= BHTK17JL

@durygus durygus changed the title Is it possible to restream on Youtube? Is it possible to restream to Youtube? May 1, 2019
@parthibd
Copy link

parthibd commented May 2, 2019

Can you please format the console output ?

@parthibd
Copy link

parthibd commented May 2, 2019

Can you try the config like this


relay: {
  ffmpeg: '/usr/local/bin/ffmpeg',
  tasks: [
    {
      app: 'live',
      mode: 'push',
      edge: 'rtmp://a.rtmp.youtube.com/live2/<stream_key>',
    }
  ]
}

without the <>

@parthibd
Copy link

parthibd commented May 2, 2019

Because in rtmp://a.rtmp.youtube.com/live2/: Input/output error the stream key is missing . So please try out my solution and let me know if it works .

@parthibd
Copy link

parthibd commented May 2, 2019

Maybe we should add one more key in the relay config to substitute for the stream key ? Can you make a pull request with this feature ?

@durygus
Copy link
Author

durygus commented May 2, 2019

Thanks for the help, but for some reason, the NMS inserts the symbol "/" at the end of the URL, and perhaps because of this, Youtube does not accept the content:

5/2/2019 08:13:00 5238 [INFO] Node Media Server v2.1.0
5/2/2019 08:13:00 5238 [INFO] Node Media Rtmp Server started on port: 1935
5/2/2019 08:13:00 5238 [INFO] Node Media Http Server started on port: 8000
5/2/2019 08:13:00 5238 [INFO] Node Media WebSocket Server started on port: 8000
5/2/2019 08:13:00 5238 [INFO] Node Media Relay Server started
5/2/2019 08:13:21 5238 [INFO] [rtmp connect] id=1S8T3UZU ip=::ffff:192.168.31.216 app=youtube args={"app":"youtube","type":"nonprivate","tcUrl":"rtmp://192.168.31.230/youtube"}
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] New stream. id=1S8T3UZU streamPath=/youtube/ streamId=1
5/2/2019 08:13:21 5238 [FFDEBUG] -fflags,nobuffer,-i,rtmp://127.0.0.1:1935/youtube/,-c,copy,-f,flv,rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/
5/2/2019 08:13:21 5238 [INFO] [Relay dynamic push] start 1S8T3UZU rtmp://127.0.0.1:1935/youtube/ to rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] Handle video. id=1S8T3UZU streamPath=/youtube/ frame_type=1 codec_id=7 codec_name=H264 1280x720
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] Handle audio. id=1S8T3UZU streamPath=/youtube/ sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
5/2/2019 08:13:21 5238 [FFDEBUG] FF输出:ffmpeg version N-91148-g8557a0940e Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration:

5/2/2019 08:13:21 5238 [FFDEBUG] FF输出: libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.102 / 58. 19.102
libavformat 58. 16.100 / 58. 16.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 24.100 / 7. 24.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100

5/2/2019 08:13:21 5238 [INFO] [rtmp connect] id=65ADIACS ip=::ffff:127.0.0.1 app=youtube args={"app":"youtube","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:1935/youtube","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
5/2/2019 08:13:21 5238 [INFO] [rtmp play] Join stream. id=65ADIACS streamPath=/youtube/ streamId=1
5/2/2019 08:13:23 5238 [FFDEBUG] FF输出:Input #0, flv, from 'rtmp://127.0.0.1:1935/youtube/':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf58.20.100
Duration: 00:00:00.00, start: 0.033000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1813 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc

5/2/2019 08:13:24 5238 [FFDEBUG] FF输出:rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/: Input/output error

5/2/2019 08:13:24 5238 [INFO] [rtmp play] Close stream. id=65ADIACS streamPath=/youtube/ streamId=1
5/2/2019 08:13:24 5238 [INFO] [rtmp disconnect] id=65ADIACS
5/2/2019 08:13:24 5238 [INFO] [Relay end] id= 1S8T3UZU

Tell me, please, how I can format the console output more readable?

@parthibd
Copy link

parthibd commented May 2, 2019

ffmpeg has one option -loglevel . It must be set to make ffmpeg spit out more readable info .

@parthibd
Copy link

parthibd commented May 2, 2019

Thanks for the help, but for some reason, the NMS inserts the symbol "/" at the end of the URL, and perhaps because of this, Youtube does not accept the content:

5/2/2019 08:13:00 5238 [INFO] Node Media Server v2.1.0
5/2/2019 08:13:00 5238 [INFO] Node Media Rtmp Server started on port: 1935
5/2/2019 08:13:00 5238 [INFO] Node Media Http Server started on port: 8000
5/2/2019 08:13:00 5238 [INFO] Node Media WebSocket Server started on port: 8000
5/2/2019 08:13:00 5238 [INFO] Node Media Relay Server started
5/2/2019 08:13:21 5238 [INFO] [rtmp connect] id=1S8T3UZU ip=::ffff:192.168.31.216 app=youtube args={"app":"youtube","type":"nonprivate","tcUrl":"rtmp://192.168.31.230/youtube"}
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] New stream. id=1S8T3UZU streamPath=/youtube/ streamId=1
5/2/2019 08:13:21 5238 [FFDEBUG] -fflags,nobuffer,-i,rtmp://127.0.0.1:1935/youtube/,-c,copy,-f,flv,rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/
5/2/2019 08:13:21 5238 [INFO] [Relay dynamic push] start 1S8T3UZU rtmp://127.0.0.1:1935/youtube/ to rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] Handle video. id=1S8T3UZU streamPath=/youtube/ frame_type=1 codec_id=7 codec_name=H264 1280x720
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] Handle audio. id=1S8T3UZU streamPath=/youtube/ sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
5/2/2019 08:13:21 5238 [FFDEBUG] FF输出:ffmpeg version N-91148-g8557a0940e Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration:

5/2/2019 08:13:21 5238 [FFDEBUG] FF输出: libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.102 / 58. 19.102
libavformat 58. 16.100 / 58. 16.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 24.100 / 7. 24.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100

5/2/2019 08:13:21 5238 [INFO] [rtmp connect] id=65ADIACS ip=::ffff:127.0.0.1 app=youtube args={"app":"youtube","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:1935/youtube","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
5/2/2019 08:13:21 5238 [INFO] [rtmp play] Join stream. id=65ADIACS streamPath=/youtube/ streamId=1
5/2/2019 08:13:23 5238 [FFDEBUG] FF输出:Input #0, flv, from 'rtmp://127.0.0.1:1935/youtube/':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf58.20.100
Duration: 00:00:00.00, start: 0.033000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1813 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc

5/2/2019 08:13:24 5238 [FFDEBUG] FF输出:rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/: Input/output error

5/2/2019 08:13:24 5238 [INFO] [rtmp play] Close stream. id=65ADIACS streamPath=/youtube/ streamId=1
5/2/2019 08:13:24 5238 [INFO] [rtmp disconnect] id=65ADIACS
5/2/2019 08:13:24 5238 [INFO] [Relay end] id= 1S8T3UZU

Tell me, please, how I can format the console output more readable?

No thats not the reason . The reason is that the stream key is missing

@parthibd
Copy link

parthibd commented May 2, 2019

5/2/2019 08:13:00 5238 [INFO] Node Media Server v2.1.0
5/2/2019 08:13:00 5238 [INFO] Node Media Rtmp Server started on port: 1935
5/2/2019 08:13:00 5238 [INFO] Node Media Http Server started on port: 8000
5/2/2019 08:13:00 5238 [INFO] Node Media WebSocket Server started on port: 8000
5/2/2019 08:13:00 5238 [INFO] Node Media Relay Server started
5/2/2019 08:13:21 5238 [INFO] [rtmp connect] id=1S8T3UZU ip=::ffff:192.168.31.216 app=youtube args={"app":"youtube","type":"nonprivate","tcUrl":"rtmp://192.168.31.230/youtube"}
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] New stream. id=1S8T3UZU streamPath=/youtube/ streamId=1
5/2/2019 08:13:21 5238 [FFDEBUG] -fflags,nobuffer,-i,rtmp://127.0.0.1:1935/youtube/,-c,copy,-f,flv,rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/
5/2/2019 08:13:21 5238 [INFO] [Relay dynamic push] start 1S8T3UZU rtmp://127.0.0.1:1935/youtube/ to rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] Handle video. id=1S8T3UZU streamPath=/youtube/ frame_type=1 codec_id=7 codec_name=H264 1280x720
5/2/2019 08:13:21 5238 [INFO] [rtmp publish] Handle audio. id=1S8T3UZU streamPath=/youtube/ sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 44100 2ch
5/2/2019 08:13:21 5238 [FFDEBUG] FF输出:ffmpeg version N-91148-g8557a0940e Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration:

5/2/2019 08:13:21 5238 [FFDEBUG] FF输出: libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.102 / 58. 19.102
libavformat 58. 16.100 / 58. 16.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 24.100 / 7. 24.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100

5/2/2019 08:13:21 5238 [INFO] [rtmp connect] id=65ADIACS ip=::ffff:127.0.0.1 app=youtube args={"app":"youtube","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:1935/youtube","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
5/2/2019 08:13:21 5238 [INFO] [rtmp play] Join stream. id=65ADIACS streamPath=/youtube/ streamId=1
5/2/2019 08:13:23 5238 [FFDEBUG] FF输出:Input #0, flv, from 'rtmp://127.0.0.1:1935/youtube/':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf58.20.100
Duration: 00:00:00.00, start: 0.033000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1813 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc

5/2/2019 08:13:24 5238 [FFDEBUG] FF输出:rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/: Input/output error

5/2/2019 08:13:24 5238 [INFO] [rtmp play] Close stream. id=65ADIACS streamPath=/youtube/ streamId=1
5/2/2019 08:13:24 5238 [INFO] [rtmp disconnect] id=65ADIACS
5/2/2019 08:13:24 5238 [INFO] [Relay end] id= 1S8T3UZU

@parthibd
Copy link

parthibd commented May 2, 2019

Okay . The stream key is there . Can you give me the output of this

ffmpeg -loglevel debug -re -i <input> -f flv rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/

@parthibd
Copy link

parthibd commented May 2, 2019

Here you are streaming a file as input to simulate a livestream .

@durygus
Copy link
Author

durygus commented May 2, 2019

A very large log will get with the "-loglevel debug" key. Let's make it easier:

  1. With the symbol "/" at the end of the URL video broadcast does not work:
    MacBook-Pro:/ Vadim$ ffmpeg -re -i ~/Downloads/temp/Ma\ Long\ Forehand\ and\ Backhand\ Technique.mp4 -c copy -f flv rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/ -loglevel error
    RTMP_ReadPacket, failed to read RTMP packet header
    rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46/: Unknown error occurred

  2. Without the "/" symbol at the end of the URL, the video broadcast really works:
    MacBook-Pro:/ Vadim$ ffmpeg -re -i ~/Downloads/temp/Ma\ Long\ Forehand\ and\ Backhand\ Technique.mp4 -c copy -f flv rtmp://a.rtmp.youtube.com/live2/9qtz-mu76-7htf-ej46 -loglevel error

My qualification is not enough to correct the error in the code:
"Do not put the character "/" if it is not in the edge URL in the config."

@parthibd
Copy link

parthibd commented May 2, 2019

Okay . That sounds great . Can you make a pull request to fix this ?

@parthibd
Copy link

parthibd commented May 2, 2019

It seems ffmpeg is not normalizing the urls . But thats fine . I'll make a pull request fixing this ASAP .

@durygus
Copy link
Author

durygus commented May 2, 2019

Thank you so much!

@parthibd
Copy link

parthibd commented May 2, 2019

You're welcome . :)

@durygus
Copy link
Author

durygus commented May 15, 2019

@parthibd, is it ASAP time to come soon? :)

@NickGrant89
Copy link

@VadimGuslistov - I have a work around for this, if you still need a fix ?

@durygus
Copy link
Author

durygus commented May 27, 2019

Yes, I need it. Thank you very much!

@JohnTrabusca
Copy link

@VadimGuslistov - I have a work around for this, if you still need a fix ?

Hello do you mind sharing with me as well, I been trying to it on Facebook Live but I'm unable to do it, and I'm not sure what I'm doing wrong

@amon-talha
Copy link

Yes, I need it. Thank you very much!

Hello, I've got the same issue could you help me out if you've found the solution?

@amon-talha
Copy link

amon-talha commented Jul 17, 2019

I think I got a workaround, not sure if it's the correct way of doing it.

in the function onPostPublish in node_relay_server.js add a variable.
let newStream = stream.length ? /${stream} : stream
and change
conf.ouPath = hasApp ? ${conf.edge}/${stream}:${conf.edge}${streamPath};
to
conf.ouPath = hasApp ? ${conf.edge}${newStream}:${conf.edge}${streamPath};

could someone check it out if it's correct, please?

@cpanel10x
Copy link

cpanel10x commented Jul 18, 2019

I think I got a workaround, not sure if it's the correct way of doing it.

in the function onPostPublish in node_relay_server.js add a variable.
let newStream = stream.length ? /${stream} : stream
and change
conf.ouPath = hasApp ? ${conf.edge}/${stream}:${conf.edge}${streamPath};
to
conf.ouPath = hasApp ? ${conf.edge}${newStream}:${conf.edge}${streamPath};

could someone check it out if it's correct, please?

Its not work. My solution is replace all
hasApp ? ${conf.edge}/${stream}:${conf.edge}${streamPath};
to
'rtmp://a.rtmp.youtube.com/live2/<stream key>' lol

@NickGrant89
Copy link

NickGrant89 commented Jul 18, 2019 via email

@NickGrant89
Copy link

Hi All

To get this to work i removed ${stream} from the onPostPublish function .

onPostPublish(id, streamPath, args) {
if (!this.config.relay.tasks) {
return;
}
let regRes = //(.)/(.)/gi.exec(streamPath);
let [app, stream] = _.slice(regRes, 1);
let i = this.config.relay.tasks.length;
while (i--) {
let conf = this.config.relay.tasks[i];
let isPush = conf.mode === 'push';
if (isPush && app === conf.app) {
let hasApp = conf.edge.match(/rtmp://([^\/]+)/([^\/]+)/);
conf.ffmpeg = this.config.relay.ffmpeg;
conf.inPath = rtmp://127.0.0.1:${this.config.rtmp.port}${streamPath};
conf.ouPath = hasApp ? ${conf.edge} : ${conf.edge};
let session = new NodeRelaySession(conf);
session.id = id;
session.on('end', (id) => {
this.dynamicSessions.delete(id);
});
this.dynamicSessions.set(id, session);
session.run();
Logger.log('[Relay dynamic push] start', id, conf.inPath, ' to ', conf.ouPath);
}
}

}

Then within my relay config this is my setup and it works like a dream. i'm not sure if this is the correct way around but it works.

relay: {
ffmpeg: '/usr/local/bin/ffmpeg',
tasks: [
{
app: 'live',
mode: 'push',
edge: 'rtmp://a.rtmp.youtube.com/live2/<stream_key>',
}
]
}

@cpanel10x
Copy link

onPostPublish(id, streamPath, args) {
  if (!this.config.relay.tasks) {
  return;
  }
  let regRes = /\/(.*)\/(.*)/gi.exec(streamPath);
  let [app, stream] = _.slice(regRes, 1);
  let i = this.config.relay.tasks.length;
  while (i--) {
    let conf = this.config.relay.tasks[i];
    let isPush = conf.mode === 'push';
    if (isPush && app === conf.app) {
    let hasApp = conf.edge.match(/rtmp:\/\/([^\/]+)\/([^\/]+)/);
    conf.ffmpeg = this.config.relay.ffmpeg;
    conf.inPath = `rtmp://127.0.0.1:${this.config.rtmp.port}${streamPath}`;
    conf.ouPath = hasApp ? `${conf.edge}` : `${conf.edge}`;
    let session = new NodeRelaySession(conf);
    session.id = id;
    session.on('end', (id) => {
      this.dynamicSessions.delete(id);
    });
    this.dynamicSessions.set(id, session);
    session.run();
    Logger.log('[Relay dynamic push] start', id, conf.inPath, ' to ', conf.ouPath);
    }
  }

}

@cpanel10x
Copy link

cpanel10x commented Jul 27, 2019

Hi guys. That pull is great solution for fix that problem #210

@chrisspiegl
Copy link

This issue is most likely fixed by #210 by adding the appendName: false option to the relay config.

relay: {
    ffmpeg: "path/to/ffmpeg",
    tasks: [{
        app: "live",
        mode: "push",
        edge: "FULL RTMP URL THAT DON'T HAS TO BE MODIFIED",
        appendName: false
    }]
}

This issue probably can be closed when adding the appendName: false.

@shubhamkourav
Copy link

How to pass the dynamic stream key?

@shubhamkourav
Copy link

How to get the Stream path when disconnecting server

@chrisspiegl
Copy link

@kauravshubham Please open a new issue for whatever you are trying to achieve since this is not the topic that is being discussed here.

@kamal-hossain
Copy link

This issue is most likely fixed by #210 by adding the appendName: false option to the relay config.

relay: {
    ffmpeg: "path/to/ffmpeg",
    tasks: [{
        app: "live",
        mode: "push",
        edge: "FULL RTMP URL THAT DON'T HAS TO BE MODIFIED",
        appendName: false
    }]
}

This issue probably can be closed when adding the appendName: false.

For youtube:

NOTE: You need to add / after the main URL of rtmp.

Example: rtmp://a.rtmp.youtube.com/live1/jmhw-rgv0-uem7-6411-195h

@brtmvdl
Copy link

brtmvdl commented Jul 12, 2024

Following!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants