Artificial-superintelligence commited on
Commit
3531315
·
verified ·
1 Parent(s): cd153ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -55,9 +55,6 @@ def gradio_interface():
55
  start_time_input = gr.Number(label="Start Time (seconds)", value=0, interactive=True)
56
  end_time_input = gr.Number(label="End Time (seconds)", value=10, interactive=True)
57
 
58
- # File output for downloaded video
59
- output_file = gr.File(label="Download Cropped Video")
60
-
61
  # Status message for user feedback
62
  status_message = gr.Textbox(label="Status", placeholder="Processing...", interactive=False)
63
 
@@ -68,10 +65,10 @@ def gradio_interface():
68
  def process_video(url, start_time, end_time):
69
  status_message.value = "Downloading video..."
70
  video_path = download_video(url)
71
- if video_path:
72
  status_message.value = "Cropping video..."
73
  cropped_video_path = crop_video(video_path, start_time, end_time)
74
- if cropped_video_path and os.path.exists(cropped_video_path):
75
  return cropped_video_path, "Done! You can download your video below."
76
  else:
77
  status_message.value = "Error cropping video."
@@ -79,6 +76,8 @@ def gradio_interface():
79
  status_message.value = "Error downloading video. Please check the URL."
80
  return None, status_message.value
81
 
 
 
82
  process_btn.click(process_video, inputs=[url_input, start_time_input, end_time_input], outputs=[output_file, status_message])
83
 
84
  return demo
 
55
  start_time_input = gr.Number(label="Start Time (seconds)", value=0, interactive=True)
56
  end_time_input = gr.Number(label="End Time (seconds)", value=10, interactive=True)
57
 
 
 
 
58
  # Status message for user feedback
59
  status_message = gr.Textbox(label="Status", placeholder="Processing...", interactive=False)
60
 
 
65
  def process_video(url, start_time, end_time):
66
  status_message.value = "Downloading video..."
67
  video_path = download_video(url)
68
+ if isinstance(video_path, str) and os.path.exists(video_path):
69
  status_message.value = "Cropping video..."
70
  cropped_video_path = crop_video(video_path, start_time, end_time)
71
+ if isinstance(cropped_video_path, str) and os.path.exists(cropped_video_path):
72
  return cropped_video_path, "Done! You can download your video below."
73
  else:
74
  status_message.value = "Error cropping video."
 
76
  status_message.value = "Error downloading video. Please check the URL."
77
  return None, status_message.value
78
 
79
+ # Output the cropped video and status message
80
+ output_file = gr.File(label="Download Cropped Video")
81
  process_btn.click(process_video, inputs=[url_input, start_time_input, end_time_input], outputs=[output_file, status_message])
82
 
83
  return demo