ziqiangao commited on
Commit
d6584d2
·
1 Parent(s): bc560eb

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -166,16 +166,22 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512):
166
 
167
  # Prepare parameters for each frame
168
  params = [(n, samples_array, cover_img, title, artist, dominant_color, width, height, fps, name, oscres) for n in range(num_frames)]
169
-
170
  try:
171
  with Pool(cpu_count()) as pool:
 
 
172
  # Use imap to get progress updates
173
  for _ in pool.imap_unordered(render_frame, params):
174
  iii += 1 # Increment frame count for progress
 
 
175
 
176
  except Exception as e:
177
  print('Ended in error: ' + traceback.format_exc())
178
-
 
 
179
  print('FFMPEG')
180
  ffmpeg_cmd = [
181
  "ffmpeg",
@@ -190,7 +196,6 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512):
190
  path+f'{name}.mp4' # Output MP4 filename
191
  ]
192
  subprocess.run(ffmpeg_cmd)
193
- gr.Interface.download(f"{name}.mp4")
194
 
195
  def gradio_interface(audio_file, output_name, fps=30, vidwidth=1280, vidheight=720, oscres=512):
196
  resolution = f"{vidwidth}x{vidheight}"
 
166
 
167
  # Prepare parameters for each frame
168
  params = [(n, samples_array, cover_img, title, artist, dominant_color, width, height, fps, name, oscres) for n in range(num_frames)]
169
+ p = gr.Progress()
170
  try:
171
  with Pool(cpu_count()) as pool:
172
+
173
+ num_frames = len(samples_array) // (11025 // fps)
174
  # Use imap to get progress updates
175
  for _ in pool.imap_unordered(render_frame, params):
176
  iii += 1 # Increment frame count for progress
177
+ p((iii,num_frames),desc="Rendering Frames")
178
+
179
 
180
  except Exception as e:
181
  print('Ended in error: ' + traceback.format_exc())
182
+ gr.Warning("Rendering had errored, program will continue")
183
+ p = gr.Progress()
184
+ p(0.5,desc="Finalizing Video")
185
  print('FFMPEG')
186
  ffmpeg_cmd = [
187
  "ffmpeg",
 
196
  path+f'{name}.mp4' # Output MP4 filename
197
  ]
198
  subprocess.run(ffmpeg_cmd)
 
199
 
200
  def gradio_interface(audio_file, output_name, fps=30, vidwidth=1280, vidheight=720, oscres=512):
201
  resolution = f"{vidwidth}x{vidheight}"