I recently saw a Github project where the author wrote a script to automatically generate tiktok videos using Python, and it's getting a lot of buzz.
There are a lot of assembly line production videos on tiktok, many video bloggers earn a lot by this, I think it's quite interesting, here to share to everyone.
After taking a closer look at the project, the author mainly crawls video footage from game video sites, then intercepts interesting Q&A from reddit forums, and finally uses Python's MoviePy library to edit the video and stitch the collected material together.
This video production method almost no manual involvement, a day can edit hundreds of videos, you can first look at the author gives the case video effect.
Here comes the video editing library used by the author - MoviePy, a very classic video tool.
MoviePy is a Python module for video editing. It can be used for some basic operations (such as cutting, splicing, inserting titles), video compositing (i.e. non-linear editing), video processing and creating advanced effects. It can read and write to most common video formats, including MP4, GIF, etc.
For example, open a video：
Installing MoviePy can be done via PIP, but of course it will require some dependent libraries such as Numpy, imageio, Decorator, tqdm, etc., as well as FFMPEG software.
pip install moviepy
MoviePy is also very simple to use, its core object is the clip, providing a variety of functions to achieve complex operations on video.
You can go to MoviePy's official website to check the specific editing functions, which are very detailed
The interesting thing is that MoviePy can be combined with Matplotlib to make dynamic charts.
import matplotlib.pyplot as plt import numpy as np from moviepy.editor import VideoClip from moviepy.video.io.bindings import mplfig_to_npimage x = np.linspace(-2, 2, 200) duration = 2 fig, ax = plt.subplots() def make_frame(t): ax.clear() ax.plot(x, np.sinc(x**2) + np.sin(x + 2*np.pi/duration * t), lw=3) ax.set_ylim(-1.5, 2.5) return mplfig_to_npimage(fig) animation = VideoClip(make_frame, duration=duration) animation.write_gif('matplotlib.gif', fps=20)
Finally, you can go to study the code of the automation video on Github, their own with interesting material, you can mass produce video, there may be a great business opportunity.