Spanicin commited on
Commit
7818ba9
·
verified ·
1 Parent(s): 581abfa

Update stream_server.py

Browse files
Files changed (1) hide show
  1. stream_server.py +5 -0
stream_server.py CHANGED
@@ -126,6 +126,11 @@ async def add_video(video_name, output_path, audio_duration):
126
  m3u8_file.write(f"#EXTINF:{remaining_duration:.3f},\n")
127
  m3u8_file.write(f"{remaining_segment_path}\n")
128
 
 
 
 
 
 
129
  return {"message": f'"{video_name}" added to the streaming queue.'}
130
 
131
  async def concatenate_playlists(video_names, base_dir):
 
126
  m3u8_file.write(f"#EXTINF:{remaining_duration:.3f},\n")
127
  m3u8_file.write(f"{remaining_segment_path}\n")
128
 
129
+ # Add #EXT-X-ENDLIST only if there are no more videos to add
130
+ if remaining_duration > 0 or len(video_names) == segment_counter:
131
+ with open(output_path, 'a') as m3u8_file:
132
+ m3u8_file.write("#EXT-X-ENDLIST\n")
133
+
134
  return {"message": f'"{video_name}" added to the streaming queue.'}
135
 
136
  async def concatenate_playlists(video_names, base_dir):