dylan-plummer commited on
Commit
0df0393
·
1 Parent(s): 96b6525

trying to optimize hls download

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. hls_download.py +2 -2
app.py CHANGED
@@ -398,7 +398,7 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
398
  # ]
399
 
400
  gr.Examples(examples=[
401
- ['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_rd2FAyUo/vod', '2600', '2630'],
402
  #[os.path.join(os.path.dirname(__file__), "files", "train14.mp4")],
403
  #[os.path.join(os.path.dirname(__file__), "files", "train_17.mp4")],
404
  #[os.path.join(os.path.dirname(__file__), "files", "train13.mp4")],
 
398
  # ]
399
 
400
  gr.Examples(examples=[
401
+ ['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_rd2FAyUo/vod', '0', '30'],
402
  #[os.path.join(os.path.dirname(__file__), "files", "train14.mp4")],
403
  #[os.path.join(os.path.dirname(__file__), "files", "train_17.mp4")],
404
  #[os.path.join(os.path.dirname(__file__), "files", "train13.mp4")],
hls_download.py CHANGED
@@ -13,7 +13,7 @@ def download_clips(stream_url, out_dir, start_time, end_time, resize=True):
13
  output_file = os.path.join(out_dir, f"train_{len(os.listdir(out_dir))}.mp4")
14
  # output video at 30fps
15
  if resize:
16
- subprocess.run(['ffmpeg', '-i', stream_url,
17
  '-ss', str(start_time - 2),
18
  '-to', str(end_time + 2), # pad end time by a couple of seconds
19
  '-r', str(30),
@@ -23,7 +23,7 @@ def download_clips(stream_url, out_dir, start_time, end_time, resize=True):
23
  '-vf', 'scale=-2:360',
24
  '-c:a', 'copy', output_file])
25
  else:
26
- subprocess.run(['ffmpeg', '-i', stream_url,
27
  '-ss', str(start_time - 2),
28
  '-to', str(end_time + 2), # pad end time by a couple of seconds
29
  '-r', str(30),
 
13
  output_file = os.path.join(out_dir, f"train_{len(os.listdir(out_dir))}.mp4")
14
  # output video at 30fps
15
  if resize:
16
+ subprocess.run(['ffmpeg', '-f', 'hls', '-i', stream_url,
17
  '-ss', str(start_time - 2),
18
  '-to', str(end_time + 2), # pad end time by a couple of seconds
19
  '-r', str(30),
 
23
  '-vf', 'scale=-2:360',
24
  '-c:a', 'copy', output_file])
25
  else:
26
+ subprocess.run(['ffmpeg', '-f', 'hls', '-i', stream_url,
27
  '-ss', str(start_time - 2),
28
  '-to', str(end_time + 2), # pad end time by a couple of seconds
29
  '-r', str(30),