@@ -46,10 +46,10 @@ class NodeTransSession extends EventEmitter {
46
46
}
47
47
if ( this . conf . hls ) {
48
48
this . conf . hlsFlags = this . conf . hlsFlags ? this . conf . hlsFlags : '' ;
49
- let hlsFileName = this . conf . name ? `${ this . conf . name } .m3u8` : 'index.m3u8' ;
50
- let mapHls = `[${ this . conf . hlsFlags } :hls_segment_filename=\'${ ouPath } /guaclive_${ this . conf . name || 'index' } _${ random } _%d.ts\']${ ouPath } /${ hlsFileName } |` ;
49
+ this . hlsFileName = this . conf . name ? `${ this . conf . name } .m3u8` : 'index.m3u8' ;
50
+ let mapHls = `[${ this . conf . hlsFlags } :hls_segment_filename=\'${ ouPath } /guaclive_${ this . conf . name || 'index' } _${ random } _%d.ts\']${ ouPath } /${ this . hlsFileName } |` ;
51
51
mapStr += mapHls ;
52
- Logger . log ( '[Transmuxing HLS] ' + this . conf . streamPath + ' to ' + ouPath + '/' + hlsFileName ) ;
52
+ Logger . log ( '[Transmuxing HLS] ' + this . conf . streamPath + ' to ' + ouPath + '/' + this . hlsFileName ) ;
53
53
}
54
54
if ( this . conf . dash ) {
55
55
this . conf . dashFlags = this . conf . dashFlags ? this . conf . dashFlags : '' ;
@@ -89,7 +89,7 @@ class NodeTransSession extends EventEmitter {
89
89
this . ffmpeg_exec . on ( 'close' , ( code ) => {
90
90
Logger . log ( '[Transmuxing end] ' + this . conf . streamPath ) ;
91
91
this . emit ( 'end' ) ;
92
- fs . readdir ( ouPath , function ( err , files ) {
92
+ fs . readdirSync ( ouPath , function ( err , files ) {
93
93
if ( ! err ) {
94
94
files . forEach ( ( filename ) => {
95
95
if ( filename . endsWith ( '.ts' )
@@ -101,9 +101,12 @@ class NodeTransSession extends EventEmitter {
101
101
|| filename . endsWith ( '.tmp' ) ) {
102
102
fs . unlinkSync ( ouPath + '/' + filename ) ;
103
103
}
104
- } )
104
+ } ) ;
105
105
}
106
- } ) ;
106
+ } ) ;
107
+ if ( this . conf . hls ) {
108
+ fs . writeFileSync ( ouPath + '/' + this . hlsFileName , '#EXTM3U\n' ) ;
109
+ }
107
110
} ) ;
108
111
}
109
112
@@ -112,4 +115,4 @@ class NodeTransSession extends EventEmitter {
112
115
}
113
116
}
114
117
115
- module . exports = NodeTransSession ;
118
+ module . exports = NodeTransSession ;
0 commit comments