0

I hope to zoom a 4k video. The reason is simply I don't have a high resolution monitor.

from moviepy.editor import VideoFileClip
import moviepy.video.fx.all as vfx
clip = VideoFileClip(file_name)
resized_clip = clip .crop(clip, x1=0, y1=0, x2=1920, y2=1080)

It is the code I used to cut off the upper-right of 4k clip. This type of size modifying was worked for other sizes of video, but not worked for 4k. How can I fix it?

p.s. Not worked with error.

Chayan Bansal
  • 1,857
  • 1
  • 13
  • 23
Yong
  • 35
  • 1
  • 5
  • 2
    "not worked" isn't enough to go by. What happened, what didn't happen? Did you get an error? – AKX Jun 07 '21 at 15:46
  • In addition, you really shouldn't use Moviepy to crop a video just for display, since it'll require re-encoding the file; just do it in your player... – AKX Jun 07 '21 at 15:47

1 Answers1

1

You may use vfx.crop instead of clip.crop.

The correct syntax is:

clip = VideoFileClip(file_name)
resized_clip = vfx.crop(clip, x1=0, y1=0, x2=1920, y2=1080)
resized_clip.write_videofile("crop.mp4")

The following syntax also works:

clip = VideoFileClip(file_name)
clip.crop(x1=0, y1=0, x2=1920, y2=1080).write_videofile("crop.mp4")

Cropping the top left corner is not the best solution for reducing the resolution.

You are probably looking for resize:

clip = VideoFileClip(file_name)
clip.resize((1920, 1080)).write_videofile("resized.mp4")
Rotem
  • 30,366
  • 4
  • 32
  • 65