![](/img/trans.png)
[英]i tried to make video editor which takes videos from pc using moviepy python but i am facing some issues and i am new to this
[英]i want to make video 2x speed using moviepy but its making videos zoom in,enlarge
我是moviepy的新手,我的要求是將普通視頻制作成2x。 所有視頻都記錄在手機上,不需要任何旋轉的視頻都可以正常工作。 通過甚至需要旋轉的視頻,我應用旋轉甚至只是嘗試編寫輸出全屏放大這里是代碼
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')
這是因為您的 original_video 不是 1920x1080。 您可以使用 resize((1920, 1080)) 將分辨率轉換為 1080p。
clip1 = clip.speedx(0.5).resize([1920, 1080])
試試這些代碼:
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.