Spanicin commited on
Commit
a1d40e7
·
verified ·
1 Parent(s): 50181c6

Update stream_server.py

Browse files
Files changed (1) hide show
  1. stream_server.py +11 -0
stream_server.py CHANGED
@@ -98,6 +98,17 @@ async def add_video(video_name: str):
98
  segment_counter += num_new_segments
99
 
100
  video_names.append(video_name)
 
 
 
 
 
 
 
 
 
 
 
101
  # Update concatenated playlist
102
  #await concatenate_playlists(video_names, HLS_DIR)
103
 
 
98
  segment_counter += num_new_segments
99
 
100
  video_names.append(video_name)
101
+ video_file_name = os.path.basename(video_name)
102
+ # Append .ts segments to the corresponding .m3u8 file
103
+ m3u8_file_path = HLS_DIR / f'{video_name}.m3u8'
104
+ # ts_files = sorted([f for f in os.listdir(HLS_DIR) if f.startswith('video_stream') and f.endswith('.ts')])
105
+
106
+ # Open the M3U8 file in append mode and write the new segments
107
+ with open(m3u8_file_path, 'a') as m3u8_file:
108
+ # for ts_file in ts_files[-num_new_segments:]:
109
+ m3u8_file.write(f"#EXTINF:3.000,\n") # Adjust duration as necessary
110
+ m3u8_file.write(f"/live_stream/{video_file_name}\n")
111
+
112
  # Update concatenated playlist
113
  #await concatenate_playlists(video_names, HLS_DIR)
114