How to add your own logo to a video with Python

Source: Internet
Author: User
Tags transparent image

Headline number: https://www.toutiao.com/c/user/4298580959/

If you have read my first two articles: "Video from the media people, also with what fast clip, love clip, a few lines of Python to do everything" and "video from the media:" A few lines of Python to do everything "installation method" will want to moviepy this goods still can do? It can be said that it supports a lot of functions, I will release the time behind. Although Moviepy supports features in some graphical software, it has the advantage of being simple to modify and batch-processed as a script. The first thing to say today is how to add your own logo to your video.

Get your logo ready first.

It's better to be transparent, so add it up and don't look abrupt. For example, the logo_sc.png is a transparent image.

Refer to the following code to handle

#!/usr/bin/python3

#-*-Coding:utf-8-*-

From moviepy.editor Import *

def convert (SRC, DST, T1=none, T2=none):

"' Src is the original video file name, DST is the video file name to output"

Print ("Start processing ...")

# t1,t2 is the clip start and end time to process the video

If not T1:T1 = 10

If not t2:t2 = 10

# Load Original video

Clip = Videofileclip (src)

# Clip Original Video

Clip = Clip.subclip (T1, CLIP.DURATION-T2)

# loading your own logo,logo_sc.png requires pre-preparation

Img_clip = Imageclip ("Logo_sc.png")

# put it in the upper left corner and show 20 seconds

Img_clip = Img_clip.set_pos (' Left ', ' top '). Set_duration (20)

# Overlay This logo on a clip-good video

Clip = Compositevideoclip ([clip, Img_clip])

# Output Video

Clip.to_videofile (DST, fps=24, Remove_temp=false)

Convert ("xxx video. mp4", "Output video. mp4", 10, 20)

View Effects

You can see my video "Tribute to the classic, Ford Mustang Bullitt Special Edition released, 500 6-speed manual V8 after drive."

How to add your own logo to a video with Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.