mfarre HF staff commited on
Commit
643a357
·
1 Parent(s): c43a83e
Files changed (1) hide show
  1. app.py +7 -22
app.py CHANGED
@@ -31,21 +31,6 @@ def format_duration(seconds: int) -> str:
31
  return f"{hours}:{minutes:02d}:{secs:02d}"
32
  return f"{minutes}:{secs:02d}"
33
 
34
- # def add_watermark(video_path: str, output_path: str):
35
- # watermark_text = "🤗 SmolVLM2 Highlight"
36
- # command = f"""ffmpeg -i {video_path} -vf \
37
- # "drawtext=text='{watermark_text}':fontcolor=white:fontsize=24:box=1:[email protected]:\
38
- # boxborderw=5:x=w-tw-10:y=h-th-10" \
39
- # -codec:a copy {output_path}"""
40
- # os.system(command)
41
- def add_watermark(video_path: str, output_path: str):
42
- watermark_text = "🤗 SmolVLM2 Highlight"
43
- command = f"""ffmpeg -i {video_path} -vf \
44
- "drawtext=text='{watermark_text}':fontfile=NotoColorEmoji.ttf:\
45
- fontcolor=white:fontsize=24:box=1:[email protected]:\
46
- boxborderw=5:x=w-tw-10:y=h-th-10" \
47
- -codec:a copy {output_path}"""
48
- os.system(command)
49
 
50
  @spaces.GPU
51
  def process_video(
@@ -69,15 +54,15 @@ def process_video(
69
 
70
  progress(0.4, desc="Detecting and extracting highlights...")
71
  with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as tmp_file:
72
- temp_output = tmp_file.name
73
 
74
- detector.create_highlight_video(video_path, temp_output)
75
 
76
- progress(0.9, desc="Adding watermark...")
77
- output_path = temp_output.replace('.mp4', '_watermark.mp4')
78
- add_watermark(temp_output, output_path)
79
 
80
- os.unlink(temp_output)
81
  progress(1.0, desc="Complete!")
82
 
83
  video_description = video_description[:500] + "..." if len(video_description) > 500 else video_description
@@ -133,7 +118,7 @@ def create_ui(examples_path: str):
133
 
134
  # Right column: Progress, Results and Analysis
135
  with gr.Column(scale=1):
136
- progress_bar = gr.Progress(elem_id="progress_bar")
137
 
138
  # Output video (initially hidden)
139
  output_video = gr.Video(
 
31
  return f"{hours}:{minutes:02d}:{secs:02d}"
32
  return f"{minutes}:{secs:02d}"
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  @spaces.GPU
36
  def process_video(
 
54
 
55
  progress(0.4, desc="Detecting and extracting highlights...")
56
  with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as tmp_file:
57
+ output_path = tmp_file.name
58
 
59
+ detector.create_highlight_video(video_path, output_path)
60
 
61
+ # progress(0.9, desc="Adding watermark...")
62
+ # output_path = temp_output.replace('.mp4', '_watermark.mp4')
63
+ # add_watermark(temp_output, output_path)
64
 
65
+ os.unlink(output_path)
66
  progress(1.0, desc="Complete!")
67
 
68
  video_description = video_description[:500] + "..." if len(video_description) > 500 else video_description
 
118
 
119
  # Right column: Progress, Results and Analysis
120
  with gr.Column(scale=1):
121
+ gr.Progress()
122
 
123
  # Output video (initially hidden)
124
  output_video = gr.Video(