简体   繁体   English

我想使用 moviepy 以 2 倍速度制作视频,但它使视频放大、放大

[英]i want to make video 2x speed using moviepy but its making videos zoom in,enlarge

I'm new to moviepy my requirement is to make a normal video into 2x.我是moviepy的新手,我的要求是将普通视频制作成2x。 All the videos are recorded on the phone and the videos which are not required any rotations are working fine.所有视频都记录在手机上,不需要任何旋转的视频都可以正常工作。 By the videos which are needed to be rotated even, I apply rotation or even just trying to write the outup is zoomed in with full screen here is the code通过甚至需要旋转的视频,我应用旋转甚至只是尝试编写输出全屏放大这里是代码

from moviepy.editor import VideoFileClip

from moviepy.audio import *

import moviepy.video.fx.all as vfx

clip = VideoFileClip("testingggg.mp4",audio=False) 

clip.size

#clip = clip.rotate(90) 

print("Duration of video : ", clip.duration)

print("Duration of video : ", clip.reader.fps)

clip = clip.speedx(2)

#clip = VideoFileClip("final.mp4",audio=False) 

#clip.size


clip.write_videofile("final.mp4", threads=4, audio_fps=44100,codec = 'libx264')

hope someone can help me here are some images so that u can get an idea on my issue希望有人可以帮助我这里有一些图片,以便您可以了解我的问题原始文件的图像 输出是这样的 Thank you谢谢

It's because your original_video is not 1920x1080.这是因为您的 original_video 不是 1920x1080。 you can use resize((1920, 1080)) to convert the Resolution to 1080p.您可以使用 resize((1920, 1080)) 将分辨率转换为 1080p。

clip1 = clip.speedx(0.5).resize([1920, 1080])

try those code:试试这些代码:


    
from moviepy.editor import *
import time as tt

# your fpath
fpath =  "C:\\Users\\Administrator\\Desktop\\crawl\\videos\\Cat doesn't finish Vegetables-736fiBMtADg\\Cat doesn't finish Vegetables-736fiBMtADg.mp4"

clip = VideoFileClip(fpath)
print('clip.size: ', clip.size)
# [720, 720]

print("Duration of video : ", clip.duration)
print("Duration of video : ", clip.reader.fps)

clip1 = clip.speedx(0.5).resize([1920, 1080])
print('clip1.size: ', clip.size)
# [1920, 1080]
print("Duration of clip1 : ", clip1.duration)
print("Duration of clip1 : ", clip1.reader.fps)


tmp_mp4 = '__temp__.mp4'        # temporary file

clip1.write_videofile(tmp_mp4)
tt.sleep(0.5)
os.system('explorer ' + tmp_mp4)    # open the file: tmp_mp4.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM