Node-Media-Server icon indicating copy to clipboard operation
Node-Media-Server copied to clipboard

Files deleted after the streaming finishes

Open tradingstratagem opened this issue 4 years ago • 8 comments

I noticed that all the files are deleted after the streaming has been stopped. The code is part of the core and it doesn't seem to be avoided.

Can anyone give me some suggestions on how to avoid this? (Ok I can fork and change this behaviours, but I'ld prefer to avoid this)

tradingstratagem avatar May 12 '20 14:05 tradingstratagem

You can remove the option to delete the segments from the task

{  
		app: 'live',  
		ac: 'aac',  
		hls: true,  
		hlsFlags: '[hls_time=10:hls_list_size=0_**:hls_flags=delete_segments**_]',
		dash: false,  
		dashFlags: '[f=dash:window_size=3:extra_window_size=5]'  
	  }

phprad avatar May 13 '20 18:05 phprad

it doesn't work, here is the code that it is executed when the process exits:

this.ffmpeg_exec.on('close', (code) => {
      Logger.log('[Transmuxing end] ' + this.conf.streamPath);
      this.emit('end');
      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);
            }
          })
        }
      });
    });

tradingstratagem avatar May 13 '20 18:05 tradingstratagem

yes, all files deleted. I can see during streaming files (index.m3u8 and index0.ts , index1.ts...) creates and after transmusing all files deleted. https://github.com/illuspas/Node-Media-Server/blob/efc5ef8ffd169e6a914a266a2d07da825ced9734/node_trans_session.js#L89

RupamShaw avatar May 24 '20 15:05 RupamShaw

I noticed that all the files are deleted after the streaming has been stopped. The code is part of the core and it doesn't seem to be avoided.

Can anyone give me some suggestions on how to avoid this? (Ok I can fork and change this behaviours, but I'ld prefer to avoid this)

@tradingstratagem mp4: true, mp4Flags: '[movflags=faststart]' add two lines of code to your config in tasks: eg: trans: { ffmpeg: '/usr/bin/ffmpeg', tasks: [ { ...yours, mp4: true, mp4Flags: '[movflags=faststart]' } ] }

HealerNguyen avatar Jul 21 '20 05:07 HealerNguyen

I noticed that all the files are deleted after the streaming has been stopped. The code is part of the core and it doesn't seem to be avoided.

Can anyone give me some suggestions on how to avoid this? (Ok I can fork and change this behaviours, but I'ld prefer to avoid this)

I know that its been a long time since the last reply but I want to know: did you find any solutions for this? I'm stuck with the same problem because the player I'm using in the front end will wait for "EXT-X-ENDLIST" in the index.m3u8 but it's not included at any time.

perinazzoo avatar Oct 07 '20 11:10 perinazzoo

No, at the end I gave up and I wrote my own implementation

joepsyko avatar Oct 07 '20 12:10 joepsyko

I can save file as .mp4 video after stream finish, my stream is still using .m3u8 while stream run. This is my config for my company's project (using nuxt and vue-video-player for frontend), it run without error Screenshot_20201007-192545~2

HealerNguyen avatar Oct 07 '20 12:10 HealerNguyen

fs.unlinkSync(ouPath + '/' + filename); I have commented this code, hls files remain as it is bit i can't able to play those files after streaming ends.

We want hls to be played even after streaming is finished

gigabyteservice avatar Jul 03 '21 20:07 gigabyteservice