当前位置: 首页>>代码示例>>Python>>正文


Python editor.CompositeVideoClip方法代码示例

本文整理汇总了Python中moviepy.editor.CompositeVideoClip方法的典型用法代码示例。如果您正苦于以下问题:Python editor.CompositeVideoClip方法的具体用法?Python editor.CompositeVideoClip怎么用?Python editor.CompositeVideoClip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moviepy.editor的用法示例。


在下文中一共展示了editor.CompositeVideoClip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: movie_in_movie

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import CompositeVideoClip [as 别名]
def movie_in_movie(movie1_fname, movie2_fname, output_fname, pos=('right', 'bottom'), movie2_ratio=(1/3, 1/3),
                   margin=6, margin_color=(255, 255, 255), audio=False, fps=24, codec='libx264'):
    from moviepy import editor
    movie1 = editor.VideoFileClip(movie1_fname, audio=audio)
    w, h = movie1.size

    # THE PIANO FOOTAGE IS DOWNSIZED, HAS A WHITE MARGIN, IS
    # IN THE BOTTOM RIGHT CORNER
    movie2 = (editor.VideoFileClip(movie2_fname, audio=False).
             resize((w * movie2_ratio[0], h * movie2_ratio[1])).  # one third of the total screen
             margin(margin, color=margin_color).  # white margin
             margin(bottom=20, right=20, top=20, opacity=0).  # transparent
             set_pos(pos))

    final = editor.CompositeVideoClip([movie1, movie2])
    final.write_videofile(output_fname, fps=fps, codec=codec) 
开发者ID:pelednoam,项目名称:mmvt,代码行数:18,代码来源:movies_utils.py

示例2: add_text_to_movie

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import CompositeVideoClip [as 别名]
def add_text_to_movie(movie_fol, movie_name, out_movie_name, subs, fontsize=50, txt_color='red', font='Xolonium-Bold',
                      subs_delim=' ', bg_color=None):
    # Should install ImageMagick
    # For centos6: https://www.vultr.com/docs/install-imagemagick-on-centos-6
    # For centos7: http://helostore.com/blog/install-imagemagick-on-centos-7
    from moviepy import editor

    def annotate(clip, txt, txt_color=txt_color, fontsize=fontsize):
        """ Writes a text at the bottom of the clip. """
        # To make this code works the policy.xml should be editted
        #  identify -list policy
        # sudo gedit /etc/ImageMagick/policy.xml &
        # Put under comment the TEXT and LABEL lines
        txtclip = editor.TextClip(txt, fontsize=fontsize, color=txt_color)  # font=font
        # txtclip = txtclip.on_color((clip.w, txtclip.h + 6), color=(0, 0, 255), pos=(6, 'center'))
        cvc = editor.CompositeVideoClip([clip, txtclip.set_pos(('center', 'bottom'))])
        return cvc.set_duration(clip.duration)

    if isinstance(subs, str):
        subs = import_subs(movie_fol, subs, subs_delim)
    video = editor.VideoFileClip(op.join(movie_fol, movie_name))
    annotated_clips = [annotate(video.subclip(from_t, to_t), txt) for (from_t, to_t), txt in subs]
    final_clip = editor.concatenate_videoclips(annotated_clips)
    final_clip.write_videofile(op.join(movie_fol, out_movie_name)) 
开发者ID:pelednoam,项目名称:mmvt,代码行数:26,代码来源:movies_utils.py

示例3: create_mtg_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import CompositeVideoClip [as 别名]
def create_mtg_gif(name, id, border):
    if border == 'm':   # Modern (post-8th Ed)
        card_upper_corner = (19, 38)
        gif_width = 202 - card_upper_corner[0]
        gif_height = 172 - card_upper_corner[1]
    elif border == 'c':   # Current (post-Magic 2015)
        card_upper_corner = (17, 34)
        gif_width = 204 - card_upper_corner[0]
        gif_height = 173 - card_upper_corner[1]
    else:   # Old (pre-8th Ed)
        card_upper_corner = (25, 30)
        gif_width = 196 - card_upper_corner[0]
        gif_height = 168 - card_upper_corner[1]

    mtg_card = Image.open(BytesIO(requests.get(get_mtg_image(id)).content))
    mtg_card = ImageClip(np.asarray(mtg_card)).resize((222, 310))

    get_giphy_gif(name)
    giphy_gif = (VideoFileClip('giphy_gif.mp4',
                               target_resolution=(gif_height, gif_width))
                 .set_pos(card_upper_corner)

                 )

    if giphy_gif.duration < 2:
        giphy_gif = giphy_gif.fx(loop, n=1+int(2 // giphy_gif.duration))

    mtg_gif = CompositeVideoClip([mtg_card, giphy_gif])
    mtg_gif = mtg_gif.set_start(0).set_duration(giphy_gif.duration)
    # mtg_gif.write_gif("mtg_gif.gif")
    mtg_gif.write_videofile("mtg_gif.mp4", codec='libx264',
                            bitrate=str(np.power(10, 7)), verbose=False,
                            progress_bar=False,
                            audio=False, ffmpeg_params=['-pix_fmt', 'yuv420p']) 
开发者ID:minimaxir,项目名称:magic-the-gifening,代码行数:36,代码来源:utils.py

示例4: edit_video

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import CompositeVideoClip [as 别名]
def edit_video(video):
  clips = [mp.VideoFileClip(video['file_or_url'])]

  for effect in video['effects']:
    clips.extend(get_effects(clips[0], effect))
 
  video = mp.CompositeVideoClip(clips)

  return video 
开发者ID:google,项目名称:starthinker,代码行数:11,代码来源:run.py

示例5: make_crab

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import CompositeVideoClip [as 别名]
def make_crab(self, t: str, u_id: int) -> bool:
        """Non blocking crab rave video generation from DankMemer bot

        https://github.com/DankMemer/meme-server/blob/master/endpoints/crab.py
        """
        fp = str(cog_data_path(self) / f"Verdana.ttf")
        clip = VideoFileClip(str(cog_data_path(self)) + "/template.mp4")
        # clip.volume(0.5)
        text = TextClip(t[0], fontsize=48, color="white", font=fp)
        text2 = (
            TextClip("____________________", fontsize=48, color="white", font=fp)
            .set_position(("center", 210))
            .set_duration(15.4)
        )
        text = text.set_position(("center", 200)).set_duration(15.4)
        text3 = (
            TextClip(t[1], fontsize=48, color="white", font=fp)
            .set_position(("center", 270))
            .set_duration(15.4)
        )

        video = CompositeVideoClip(
            [clip, text.crossfadein(1), text2.crossfadein(1), text3.crossfadein(1)]
        ).set_duration(15.4)
        video = video.volumex(0.1)
        video.write_videofile(
            str(cog_data_path(self)) + f"/{u_id}crabrave.mp4",
            threads=1,
            preset="superfast",
            verbose=False,
            logger=None,
            temp_audiofile=str(cog_data_path(self) / f"{u_id}crabraveaudio.mp3")
            # ffmpeg_params=["-filter:a", "volume=0.5"]
        )
        clip.close()
        video.close()
        return True 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:39,代码来源:crabrave.py

示例6: add_text_example

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import CompositeVideoClip [as 别名]
def add_text_example(movie):
    from moviepy import editor
    # A CLIP WITH A TEXT AND A BLACK SEMI-OPAQUE BACKGROUND
    txt = editor.TextClip("V. Zulkoninov - Ukulele Sonata", font='Amiri-regular',
                   color='white', fontsize=24)

    txt_col = txt.on_color(size=(movie.w + txt.w, txt.h - 10),
                           color=(0, 0, 0), pos=(6, 'center'), col_opacity=0.6)

    # THE TEXT CLIP IS ANIMATED.
    # I am *NOT* explaining the formula, understands who can/want.
    w, h = movie.size
    txt_mov = txt_col.set_pos(lambda t: (max(w / 30, int(w - 0.5 * w * t)),
                                         max(5 * h / 6, int(100 * t))))

    # FINAL ASSEMBLY
    final = editor.CompositeVideoClip([ukulele, txt_mov, piano])
    final.subclip(0, 5).write_videofile("../../ukulele.avi", fps=24, codec='libx264')


# import tempfile, os
# tempfile_fd, tempfilename = tempfile.mkstemp(suffix='.png', dir='/home/npeled/temp')
# os.close(tempfile_fd)
# temptxt_fd, temptxt = tempfile.mkstemp(suffix='.txt', dir='/home/npeled/temp')
# os.write(temptxt_fd, bytes(txt, 'UTF8'))
# os.close(temptxt_fd) 
开发者ID:pelednoam,项目名称:mmvt,代码行数:28,代码来源:movies_utils.py


注:本文中的moviepy.editor.CompositeVideoClip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。