Spanicin commited on
Commit
eddd7de
·
verified ·
1 Parent(s): cf036a0

Update stream_server.py

Browse files
Files changed (1) hide show
  1. stream_server.py +3 -2
stream_server.py CHANGED
@@ -13,6 +13,7 @@ HLS_DIR.mkdir(exist_ok=True)
13
  # Keep track of video names added to the queue
14
  video_names = []
15
  segment_counter = 1
 
16
  segment_lock = asyncio.Lock()
17
 
18
  def is_valid_path(video_name):
@@ -82,7 +83,7 @@ async def add_video(video_name, output_path, audio_duration):
82
  Returns:
83
  dict: Success message.
84
  """
85
-
86
  print((HLS_DIR / f'{video_name}.m3u8').exists())
87
  if not (HLS_DIR / f'{video_name}.m3u8').exists():
88
  async with segment_lock:
@@ -99,7 +100,6 @@ async def add_video(video_name, output_path, audio_duration):
99
 
100
  video_names.append(video_name)
101
  segment_duration = 3
102
- total_processed_duration = 0
103
  full_segments = int(audio_duration // segment_duration)
104
  remaining_duration = audio_duration % segment_duration
105
 
@@ -135,6 +135,7 @@ async def add_video(video_name, output_path, audio_duration):
135
  if total_processed_duration == video_duration:
136
  with open(output_path, 'a') as m3u8_file:
137
  m3u8_file.write("#EXT-X-ENDLIST\n")
 
138
 
139
  return {"message": f'"{video_name}" added to the streaming queue.'}
140
 
 
13
  # Keep track of video names added to the queue
14
  video_names = []
15
  segment_counter = 1
16
+ total_processed_duration = 0
17
  segment_lock = asyncio.Lock()
18
 
19
  def is_valid_path(video_name):
 
83
  Returns:
84
  dict: Success message.
85
  """
86
+ global total_processed_duration
87
  print((HLS_DIR / f'{video_name}.m3u8').exists())
88
  if not (HLS_DIR / f'{video_name}.m3u8').exists():
89
  async with segment_lock:
 
100
 
101
  video_names.append(video_name)
102
  segment_duration = 3
 
103
  full_segments = int(audio_duration // segment_duration)
104
  remaining_duration = audio_duration % segment_duration
105
 
 
135
  if total_processed_duration == video_duration:
136
  with open(output_path, 'a') as m3u8_file:
137
  m3u8_file.write("#EXT-X-ENDLIST\n")
138
+ total_processed_duration = 0
139
 
140
  return {"message": f'"{video_name}" added to the streaming queue.'}
141