Felguk commited on
Commit
bcdcc4a
·
verified ·
1 Parent(s): dc26af6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import gradio as gr
2
- from moviepy.editor import VideoFileClip, concatenate_videoclips, AudioFileClip, vfx, fx
 
 
3
  import numpy as np
4
 
5
  # Function to adjust audio pitch
@@ -36,16 +38,24 @@ def apply_visual_effects(input_video_path, glitch_effect, mirror_effect, black_a
36
  video = video.fx(vfx.mirror_x) # Mirror reflection along X-axis
37
 
38
  if black_and_white:
39
- video = video.fx(vfx.blackwhite)
40
 
41
  if sepia:
42
- video = video.fl_image(lambda img: fx.color.sepia(img, intensity=1.0))
 
 
 
 
 
 
 
 
43
 
44
  if blur:
45
  video = video.fx(vfx.blur, blur_radius=5)
46
 
47
  if brightness != 0:
48
- video = video.fx(vfx.colorx, brightness)
49
 
50
  output_path = "temp_visual_effects.mp4"
51
  video.write_videofile(output_path, codec='libx264', audio_codec='aac')
 
1
  import gradio as gr
2
+ from moviepy.editor import VideoFileClip, concatenate_videoclips, AudioFileClip, vfx
3
+ from moviepy.video.fx.all import blackwhite, colorx # Import specific effects from fx.all
4
+ from moviepy.video.tools.drawing import color_gradient # For additional effects if needed
5
  import numpy as np
6
 
7
  # Function to adjust audio pitch
 
38
  video = video.fx(vfx.mirror_x) # Mirror reflection along X-axis
39
 
40
  if black_and_white:
41
+ video = video.fx(blackwhite)
42
 
43
  if sepia:
44
+ # Apply sepia effect using a custom function
45
+ def sepia_effect(img):
46
+ sepia_filter = np.array([[0.393, 0.769, 0.189],
47
+ [0.349, 0.686, 0.168],
48
+ [0.272, 0.534, 0.131]])
49
+ sepia_img = np.dot(img[...,:3], sepia_filter.T)
50
+ sepia_img = np.clip(sepia_img, 0, 255).astype(np.uint8)
51
+ return sepia_img
52
+ video = video.fl_image(sepia_effect)
53
 
54
  if blur:
55
  video = video.fx(vfx.blur, blur_radius=5)
56
 
57
  if brightness != 0:
58
+ video = video.fx(colorx, brightness)
59
 
60
  output_path = "temp_visual_effects.mp4"
61
  video.write_videofile(output_path, codec='libx264', audio_codec='aac')