Moviepy slidein和slideout过渡

时间:2017-10-01 22:30:25

标签: python effects moviepy

我试图在视频片段之间使用幻灯片进出过渡而没有运气我只能使用这样的交叉渐变来使其工作:

 from moviepy.editor import VideoFileClip, concatenate_videoclips, vfx, afx, transfx, concatenate, 
 CompositeVideoClip

 delay = 1
 output = "out.mp4"
 clip1 = VideoFileClip("174_3.mp4")
 clip2 = VideoFileClip("174_4.mp4")
 clip3 = VideoFileClip("174_5.mp4")
 clip4 = VideoFileClip("174_6.mp4")


final = concatenate([clip1,
                 clip2.crossfadein(delay),
                 clip3.crossfadein(delay),
                 clip4.crossfadein(delay)],
         padding=-delay, method="compose")
final.write_videofile(output)

但是当我在https://github.com/Zulko/moviepy/blob/3d86a2c4cba6769528112765d964eaec273d7636/moviepy/video/compositing/transitions.py

上使用示例时
 from moviepy.editor import VideoFileClip, concatenate_videoclips, vfx, afx, transfx, concatenate, 
 CompositeVideoClip

 output = "out.mp4"
 clip1 = VideoFileClip("174_3.mp4")
 clip2 = VideoFileClip("174_4.mp4")
 clip3 = VideoFileClip("174_5.mp4")
 clip4 = VideoFileClip("174_6.mp4")

 clips = [clip1, clip2, clip3, clip4];
 CompositeVideoClip(clips)

 slided_clips = [clip.fx( transfx.slide_out, 1, 'bottom') for clip in clips]
 final_clip = concatenate( slided_clips, padding=-1)
 final_clip.write_videofile(output) 

这个结果是视频连接但根本没有过渡,请让我知道我做错了什么

1 个答案:

答案 0 :(得分:1)

请记住,moviepy中的大多数函数都不会修改对象,而是返回对象的修改后的浅表副本 - 因此行<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "job_database"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } if(isset($_POST['Get'])) { $jtitle = $_POST['jobtitle']; $location = $_POST['location']; $category = $_POST['categories']; //Query specified database for value $sql = "SELECT * FROM addjob where jtitle ='$jtitle' &and; location ='$location' &and; category ='$category' " ; $result = $conn->query($sql); } if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "jtitle: " . $row["jtitle"]. "location:" . $row["location"]. "category" . $row["category"]."<br>"; } } else { echo "0 results"; } $conn->close(); ?> 不会执行任何操作。

相反,你想做:

CompositeVideoclip(clips)

slided_clips = [CompositeVideoClip([clip.fx( transfx.slide_out, 1, 'bottom')]) for clip in clips]必须在CompositeVideoClip中的原因是因为它改变了剪辑的位置,因此需要在“框架”中将部分屏幕留空。这与slide_out仅适用于CompositeVideoClip的原因相同。