Spanicin commited on
Commit
699d3d4
·
verified ·
1 Parent(s): 66b3987

Update stream_server.py

Browse files
Files changed (1) hide show
  1. stream_server.py +17 -15
stream_server.py CHANGED
@@ -165,25 +165,27 @@ def generate_m3u8(video_duration, output_path,segment_duration=3):
165
  m3u8_content += f"#EXT-X-TARGETDURATION:{segment_duration}\n"
166
  m3u8_content += "#EXT-X-VERSION:4\n"
167
  m3u8_content += "#EXT-X-MEDIA-SEQUENCE:1\n"
 
 
 
 
168
 
169
- # Calculate the number of full segments and the remaining duration
170
-
171
- segment_duration = int(segment_duration)
172
- full_segments = int(video_duration // segment_duration)
173
- remaining_duration = video_duration % segment_duration
174
 
175
- # Add full segments to the playlist
176
- for i in range(full_segments):
177
- m3u8_content += f"#EXTINF:{segment_duration:.6f},\n"
178
- m3u8_content += f"/live_stream/video_stream{i + 1}.ts\n"
179
 
180
- # Add the remaining segment if there's any leftover duration
181
- if remaining_duration > 0:
182
- m3u8_content += f"#EXTINF:{remaining_duration:.6f},\n"
183
- m3u8_content += f"/live_stream/video_stream{full_segments + 1}.ts\n"
184
 
185
- # End the playlist
186
- m3u8_content += "#EXT-X-ENDLIST\n"
187
  with open(output_path, "w") as file:
188
  file.write(m3u8_content)
189
 
 
165
  m3u8_content += f"#EXT-X-TARGETDURATION:{segment_duration}\n"
166
  m3u8_content += "#EXT-X-VERSION:4\n"
167
  m3u8_content += "#EXT-X-MEDIA-SEQUENCE:1\n"
168
+ # m3u8_content += f"#EXTINF:{segment_duration:.6f},\n"
169
+ # m3u8_content += f"/live_stream/video_stream{i + 1}.ts\n"
170
+
171
+ # # Calculate the number of full segments and the remaining duration
172
 
173
+ # segment_duration = int(segment_duration)
174
+ # full_segments = int(video_duration // segment_duration)
175
+ # remaining_duration = video_duration % segment_duration
 
 
176
 
177
+ # # Add full segments to the playlist
178
+ # for i in range(full_segments):
179
+ # m3u8_content += f"#EXTINF:{segment_duration:.6f},\n"
180
+ # m3u8_content += f"/live_stream/video_stream{i + 1}.ts\n"
181
 
182
+ # # Add the remaining segment if there's any leftover duration
183
+ # if remaining_duration > 0:
184
+ # m3u8_content += f"#EXTINF:{remaining_duration:.6f},\n"
185
+ # m3u8_content += f"/live_stream/video_stream{full_segments + 1}.ts\n"
186
 
187
+ # # End the playlist
188
+ # m3u8_content += "#EXT-X-ENDLIST\n"
189
  with open(output_path, "w") as file:
190
  file.write(m3u8_content)
191