0

I've setup a local RTMP media server with the node-media-server library. It receives media-stream from Streamlabs. I can access it with the localhost link easily and it works without any issue.

const NodeMediaServer = require("node-media-server");

const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60,
  },
  http: {
    port: 8000,
    allow_origin: "*",
  },
};

var nms = new NodeMediaServer(config);
nms.run();

In this way I can only view the live stream. But what if I wanted to go back 10 seconds in the video? As the video is not stored, it is not possible. Is there any way I can achieve it?

Ajit Kumar
  • 367
  • 1
  • 10
  • 35

1 Answers1

0

To save files for playback you first need to install ffmpeg package using npm. You can use this one https://www.npmjs.com/package/@ffmpeg/ffmpeg

Then add this in your config:

trans: {
            ffmpeg: ffmpeg_d.path,
            tasks: [
                {
                app: 'live',
                mp4: true,
                mp4Flags: '[movflags=frag_keyframe+empty_moov]',
                }
            ]
        }

 http: {
              port: 8020,
              webroot: './public',
              mediaroot: './media',
              allow_origin: '*'
            },

A media folder will be added in your root project where you will find streamed video file for playback use.

wb_99
  • 3
  • 3
  • @ajit-kumar let me know if your problem still exists or accept the answer if it is solved, please. – wb_99 Jan 09 '23 at 14:21