idFishWithCat commited on
Commit
b480e77
·
verified ·
1 Parent(s): 4f46b63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -18
app.py CHANGED
@@ -7,18 +7,18 @@ import numpy as np
7
  import os
8
  import time
9
 
10
-
11
  # 设置umask确保新创建的文件有正确的权限
12
  os.umask(0o022)
13
 
14
 
15
- def subliminal_insert(video_path,
16
- frame_img_path,
17
- interval_frames,
18
- duration_frames,
19
- output_dir,
20
- alpha=0.5, # 添加透明度参数
21
- progress=None):
 
22
  """
23
  将特定帧按间隔植入视频流中
24
  """
@@ -73,9 +73,9 @@ def subliminal_insert(video_path,
73
  v = ffmpeg.filter(
74
  [input_video, input_image],
75
  'overlay',
76
- enable=f'if(lt(mod(n,{interval_frames}),{duration_frames}),1,0)',
77
- alpha=alpha
78
- )
79
 
80
  # 检查输入视频是否有音频流
81
  has_audio = any(s['codec_type'] == 'audio'
@@ -158,12 +158,13 @@ def subliminal_insert(video_path,
158
  pass
159
 
160
 
161
- def process_video(video_input,
162
- frame_input,
163
- interval,
164
- duration,
165
- alpha=0.5, # 添加透明度参数
166
- progress=gr.Progress()):
 
167
  """
168
  处理视频和图片输入
169
  """
@@ -215,7 +216,8 @@ def process_video(video_input,
215
  raise Exception(f"图片处理失败: {str(e)}")
216
 
217
  output_path = subliminal_insert(video_temp, frame_temp, int(interval),
218
- int(duration), output_dir, alpha, progress)
 
219
 
220
  print(f"处理完成,输出文件: {output_path}")
221
  return output_path
 
7
  import os
8
  import time
9
 
 
10
  # 设置umask确保新创建的文件有正确的权限
11
  os.umask(0o022)
12
 
13
 
14
+ def subliminal_insert(
15
+ video_path,
16
+ frame_img_path,
17
+ interval_frames,
18
+ duration_frames,
19
+ output_dir,
20
+ alpha=0.5, # 添加透明度参数
21
+ progress=None):
22
  """
23
  将特定帧按间隔植入视频流中
24
  """
 
73
  v = ffmpeg.filter(
74
  [input_video, input_image],
75
  'overlay',
76
+ enable=
77
+ f'if(lt(mod(n,{interval_frames}),{duration_frames}),1,0)',
78
+ alpha=alpha)
79
 
80
  # 检查输入视频是否有音频流
81
  has_audio = any(s['codec_type'] == 'audio'
 
158
  pass
159
 
160
 
161
+ def process_video(
162
+ video_input,
163
+ frame_input,
164
+ interval,
165
+ duration,
166
+ alpha=0.5, # 添加透明度参数
167
+ progress=gr.Progress()):
168
  """
169
  处理视频和图片输入
170
  """
 
216
  raise Exception(f"图片处理失败: {str(e)}")
217
 
218
  output_path = subliminal_insert(video_temp, frame_temp, int(interval),
219
+ int(duration), output_dir, alpha,
220
+ progress)
221
 
222
  print(f"处理完成,输出文件: {output_path}")
223
  return output_path