3
const ondata = (chunk) => {   

console.log(chunk) //Giving - Buffer 00 00 00 1c 66 74 79 70 64 61.......... 

Streaming(chunk,"rtmps://live-api-s.facebook.com:443/rtmp/FB-108963845678778")

//Streaming function is given below in the next Block};

}

i have a function named ondata which is continuously giving buffer data like this:-

( actually this a Chunk of .MP4 file.)

`<Buffer 00 00 00 1c 66 74 79 70 64 61 73 68 00 00 00 00 69 73 6f 36 61 76 63 31 6d 70 34 31 00 00 02 ca 6d 6f 6f 76 00 00 00 6c 6d 76 68 64 00 00 00 00 df e2 ... 16334 more bytes>`

`<Buffer 14 75 dd ea 7a 72 ef df 4f 24 cb 83 c3 85 a3 17 60 26 87 7a 74 0b 49 e4 6f 09 65 ae c8 6c 7d 0e 02 b1 6b 4a df 63 61 ab d9 44 22 62 3c f6 0d 8c c9 b7 ... 16334 more bytes>`

Now I want to stream this Chunk data to `RTMP Server using FFMPEG

so I doing this:-

const child_process = require('child_process');

 var Streaming = function (chunk, Rtmp_Uri) {

     ffmpeg_process = child_process.spawn('ffmpeg', \[
    
     '-re',
     '-i', \`${chunk}\`,  //Buffer 00 00 00 1c 66 74 79 70 64 61..........
     '-stream_loop','-1',
    '-f', 'flv',
     '-profile:v', 'baseline',
     '-pix_fmt', 'yuv420p',
     '-c:a', 'aac',
     '-acodec', 'mp3',
    '-ar', '44100',
     '-b:a', '128k',
     '-vcodec', 'libx264',
     '-bufsize', '600k',
     '-vb', '400k', 
    '-maxrate', '3000k',
     '-preset', 'ultrafast',
     '-r', '30',
     '-g', '30',
    Rtmp_Uri       //"rtmps://live-api-s.facebook.com:443/rtmp/FB-1089638456787788-0..
                      AbzJ3chy775fhjjjkW2";
 \]);
 return ffmpeg_process;

}

when I run this Streaming function nothing happens.

so can anyone tell me how to stream the Chunk data to the Rtmp server? or any FFmpeg command that stream Chunk data to rtmp server?

Thanks in Advance.

0 Answers0