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

Prevent deletion’s of .m3u8 after the stream ends #509

Open gigabyteservice opened 2 years ago

gigabyteservice commented 2 years ago

Prevent deletion’s of .m3u8 after the stream ends We want to make playback after the streaming is over the these .m3u8 files are important so how can I prevent from deleting.

pream912 commented 2 years ago

in node_trans_session.js file, comment out the following lines

// fs.readdir(ouPath, function (err, files) { // if (!err) { // files.forEach((filename) => { // if (filename.endsWith('.ts') // || filename.endsWith('.m3u8') // || filename.endsWith('.mpd') // || filename.endsWith('.m4s') // || filename.endsWith('.tmp')) { // // fs.unlinkSync(ouPath + '/' + filename); // } // }); // } // });

lewatt23 commented 2 years ago

Hello @gigabyteservice found a solution ? apart that from @pream912 ? facing the same issue.

gigabyteservice commented 1 year ago

@pream912 it's same as deleting fs.unlinkSync(ouPath + '/' + filename); files stays but it can only last 2 sec of video no whole video. this is really important for many people do you have any idea how to save hls files after finishing the stream? @illuspas

pream912 commented 1 year ago

set hlsFlags to change playlist type. trans: { ffmpeg: '/usr/bin/ffmpeg', tasks: [ { app: 'live', hls: true, hlsFlags: '[hls_time=5:hls_list_size=3:hls_playlist_type=event]', } ] }

P.S: remove hls_flags=delete_segments if its there already.

gigabyteservice commented 1 year ago
trans: {
    ffmpeg: '/usr/bin/ffmpeg',
    tasks: [
      {
        app: 'live', // or other
        hls: true,
        hlsFlags: '[hls_time=1:hls_list_size=2:hls_playlist_type=event]',
        dash: true,
        dashFlags: '[f=dash:window_size=3:extra_window_size=5]',
        mp4: true,
        mp4Flags: '[movflags=frag_keyframe+empty_moov]',
        'websocket-flv': true,
      },
    ],
  },

even after following your config, still it's not working. this new config changes not even saving the files while commenting this line // fs.unlinkSync(ouPath + '/' + filename); at least saving the file but video is not playing. @pream912