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.89k stars 1.51k forks source link

How to record mp4 with dynamic name like streamKey_videoId #562

Open siddhantranjan opened 1 year ago

siddhantranjan commented 1 year ago

can anyone solve this issue please

siddhantranjan commented 1 year ago

@illuspas

tolew1 commented 1 year ago

Looks like you will have to modify the code yourself. I'm in the process of doing that because I see most questions go unanswered here. You will need to fork it and update the

src\node_trans_session.js around line 48

let mp4FileName = dateFormat('yyyy-mm-dd-HH-MM-ss') + '.mp4';

And try this

let mp4FileName = `${this.conf.streamName}_${this.conf.videoId}.mp4`;

then open src\node_trans_server.js

and around line 66 add this new line

conf.videoId = id;

Then run it from you own code. Hopefully that will help you.

I also don't like the mp4 name using the date and needed it to be the name of the streamkey/streamName.

Note: Github uses ticks to show things as code however, I had to use quote because the code actually contains ticks.