laitimes

Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

author:Mr. Data Yang

Using AI hosting to mass-produce original entertainment commentary videos? That's right.

At present, most of the entertainment news introduction videos in the self-media account are automatically produced by the machine, and I also made a set of python simulator Baidu AI structures, and this script is optimized in many places compared to the previous version.

For the flow of reading and watching, let's take a figure to illustrate that this is completely dependent on luck, and both sides can change qualitatively.

Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

The current version is version 1.15 with limited functionality, and the script will continue to be updated on the basis of updating the algorithm in the future. Here are the general production ideas and methods and the original questions you want to ask.

Since no one looks at the technology in a serious way, let's make such a good try.

Let's take a look at a demo video first, and if you like it, read on.

Video loading...

Hardware and software, skill requirements

  • The CPU is preferably I7-8750 or above, or the overall production will be very slow
  • Python version 3.6 or later
  • The Moviepy module does not support GPUs for the time being, so the graphics card is good or bad
  • Need to be able to write crawlers, grab video footage.
  • You need to master the regular method of article washing, otherwise the video content cannot be done
  • It is necessary to master the regular window system operation, otherwise some operations of clipping cannot be completed
  • Need to be able to operate the Moviepy module, will not see the corresponding introduction and operation methods in my column
  • 1-N mobile phone numbers are required to apply for free API use of Baidu AI
  • Patience is required

Basic preparation

Cover video creation material

The cover of the video needs to be customized according to your own preferences, and the picture is on the line. Images can be made directly into videos.

Fixed templates, modify the template cover according to your own situation.

You have to ask how this is done? Just use PPT.

Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Do you ask the portrait to buckle itself?

No need to really use, a line of python code is directly deducted by the algorithm and then put on the PPT.

For that simple, how to do it read the other articles in my column.

Video background production footage

Includes opening animations of the video, content playback clips, own watermarks and end videos.

Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

After the material is ready, start the code to click out the video.

Processes and code

# -*- coding: utf-8 -*-
import librosa
import requests
from gerapy_auto_extractor.extractors import *
import os
import csv
import glob
import urllib.parse
import numpy as np
# from skimage import transform as tf
from moviepy.editor import *
from moviepy.video.tools.drawing import color_gradient
from random import choice

font_path = './font/kaiti.ttf' # 加载字体配置文件
log_path  = "logs/生成过内容的记录表单.csv" # 文件保存路径

# 自定义处理数据函数
from EveryWebsitFuction import *
from WordProcess import *
from AudioProcess import *
from ImageProcess import * 
from VideoProcess import *
from FileProcess import  *           

Crawl the basic information of the article

# 需要一键转换的文章链接
Url = "https://haopinang.com/27793.html"
# 提取站点信息用于爬虫脚本
WebSite = urllib.parse.urlsplit(Url).netloc
# 用爬虫extract_detail提取文章的标题
Title = extract_detail(requests.get(Url,headers=headers,proxies=proxies,verify=False).text)["title"]
# 构建文章制作信息日志
data_row = [WebSite,Title,Url]
write_csv(log_path, data_row)           
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Crawl the body, title, and image of an article

# 访问该页面
response = requests.get(Url,headers=headers,proxies=proxies,verify=False)
# 根据固定的方法获取标题、正文、图片link
if WebSite == "haopinang.com":
    title,content,imglist = haopinang(response)           

The text needs to be processed by itself to avoid sensitive words

Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Image cropping

It is to grab the image in the article to generate the material, and then crop it to the size of the video.

# 判断如果没有该数据的文件夹就创建
dirs = 'materials/' + title + "/web_jpg/"
if not os.path.exists(dirs):
    os.makedirs(dirs)
imglist = RequestGetImage(title) + imglist # 将浏览器百度搜索的素材和文章中的素材整理在一起

# 保存图片并按比例裁剪
i = 1
jpg_list = [] # 用于保存图片的文件名成
for url in imglist:   #读取并保存到本地
    html = requests.get(url,headers=headers,proxies=proxies,verify=False)
    # 将抓取的图片保存到web_jpg
    with open('materials/'+ title + "/web_jpg/" + str(i) + ".jpg", 'wb') as file:
        file.write(html.content)
    file.close()
    CutImage(i,title) # 裁剪 (与去水印二选一)
#     CleanLogo(i,title,240) # 去水印
    ChangeImage(i,title) # 裁剪图片
    jpg_list.append("{}.jpg".format(i))
    i += 1           
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Audio and subtitle processing

Convert content to voice playback using apis, or read it yourself. I'm lazy anyway.

# 获取字幕行数和字幕
word_len , strs = clean_word(title + content)
# 去除无用的空list避免报错
strs_list = strs.split("\n")
strs_list = [i for i in strs_list if i != ""] 
#生成MP3文件
StrToMp3(title,content)
# 获取MP3时长
mp3_duration = librosa.get_duration(filename='materials/'+ title + "/data/" +  title + '.mp3')           
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Delete invalid images

It can be ignored that some article pictures have too low pixels to affect the quality of the film.

Generate cover images, videos

The cover images that were originally made were converted into videos.

# 这里要自己选择一张图片改名cover.jpg
MakeCoverImage(title)           
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Synthesis of all materials

cover_mp4 = "./materials/" + title + "/data/cover.mp4"  # 合成的封面
strat_mp4 = "./materials_base/start.mp4"  # 自制片头
end_mp4 = "./materials_base/end.mp4"  # 自制片尾
logo_path = "materials_base/logo.png" # 自制水印

CompositeVideo(title,mp3_duration,jpg_list,font_path,strs_list,logo_path,cover_mp4,strat_mp4,end_mp4)           
Original entertainment commentary video one-click generation? It doesn't matter if you don't edit the software, AI is fully managed

Git source code

Welcome to the stars, support is my motivation to move forward.

At present, the contribution is version 1.0, and more than 1000 likes are directly released to everyone version 1.15.

#Automation##Short video production##python入门 #