rosyvs commited on
Commit
040d75f
·
1 Parent(s): 6b0c12c

Add error handling messages using gr.Error and gr.Info in video processing functions

Browse files
Files changed (2) hide show
  1. app.py +5 -0
  2. utils.py +1 -0
app.py CHANGED
@@ -108,6 +108,7 @@ def trim_video_vtr(input_file, output_format):
108
 
109
  return output_file, log_file
110
  except Exception as e:
 
111
  return f"Error: {e}"
112
 
113
 
@@ -133,8 +134,10 @@ def trim_video_wt(input_file, input_transcript, output_format, start_time, end_t
133
 
134
  return output_file, output_transcript
135
  except Exception as e:
 
136
  return f"Error: {str(e)}"
137
 
 
138
  def sort_transcript_helper(input_transcript, output_transcript):
139
  # sort transcript
140
  print("start sorting transcript")
@@ -166,6 +169,7 @@ def trim_video(input_file, output_format, start_time, end_time):
166
 
167
  return output_file
168
  except Exception as e:
 
169
  return f"Error: {str(e)}"
170
 
171
  def convert_video(input_file, output_format):
@@ -185,6 +189,7 @@ def convert_video(input_file, output_format):
185
 
186
  return output_file
187
  except Exception as e:
 
188
  return f"Error: {str(e)}"
189
 
190
 
 
108
 
109
  return output_file, log_file
110
  except Exception as e:
111
+ gr.Error(f"Error: {str(e)}")
112
  return f"Error: {e}"
113
 
114
 
 
134
 
135
  return output_file, output_transcript
136
  except Exception as e:
137
+ gr.Error(f"Error: {str(e)}")
138
  return f"Error: {str(e)}"
139
 
140
+
141
  def sort_transcript_helper(input_transcript, output_transcript):
142
  # sort transcript
143
  print("start sorting transcript")
 
169
 
170
  return output_file
171
  except Exception as e:
172
+ gr.Error(f"Error: {str(e)}")
173
  return f"Error: {str(e)}"
174
 
175
  def convert_video(input_file, output_format):
 
189
 
190
  return output_file
191
  except Exception as e:
192
+ gr.Error(f"Error: {str(e)}")
193
  return f"Error: {str(e)}"
194
 
195
 
utils.py CHANGED
@@ -255,6 +255,7 @@ def convert_and_trim_video(media_in, media_out, start=None, end=None):
255
 
256
  # run the ffmpeg command
257
  logging.info(f"FFMPEG command: {' '.join(command)}")
 
258
  process = subprocess.run(command, capture_output=True, text=True)
259
  if process.returncode != 0:
260
  logging.info(f"FFMPEG error: {process.stderr}")
 
255
 
256
  # run the ffmpeg command
257
  logging.info(f"FFMPEG command: {' '.join(command)}")
258
+ gr.Info(f"FFMPEG command: {' '.join(command)}", visible=False)
259
  process = subprocess.run(command, capture_output=True, text=True)
260
  if process.returncode != 0:
261
  logging.info(f"FFMPEG error: {process.stderr}")