mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 08:27:22 +08:00
dev
This commit is contained in:
parent
4c6d8d615e
commit
5f6e933fbb
0
CHANGELOG.md
Normal file
0
CHANGELOG.md
Normal file
389
README-en.md
389
README-en.md
@ -1,389 +0,0 @@
|
||||
<div align="center">
|
||||
<h1 align="center">MoneyPrinterTurbo 💸</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/stargazers"><img src="https://img.shields.io/github/stars/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="Stargazers"></a>
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/issues"><img src="https://img.shields.io/github/issues/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="Issues"></a>
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/network/members"><img src="https://img.shields.io/github/forks/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="Forks"></a>
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/blob/main/LICENSE"><img src="https://img.shields.io/github/license/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="License"></a>
|
||||
</p>
|
||||
|
||||
<h3>English | <a href="README.md">简体中文</a></h3>
|
||||
|
||||
<div align="center">
|
||||
<a href="https://trendshift.io/repositories/8731" target="_blank"><img src="https://trendshift.io/api/badge/repositories/8731" alt="harry0703%2FMoneyPrinterTurbo | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||
</div>
|
||||
|
||||
Simply provide a <b>topic</b> or <b>keyword</b> for a video, and it will automatically generate the video copy, video
|
||||
materials, video subtitles, and video background music before synthesizing a high-definition short video.
|
||||
|
||||
### WebUI
|
||||
|
||||

|
||||
|
||||
### API Interface
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
## Special Thanks 🙏
|
||||
|
||||
Due to the **deployment** and **usage** of this project, there is a certain threshold for some beginner users. We would
|
||||
like to express our special thanks to
|
||||
|
||||
**RecCloud (AI-Powered Multimedia Service Platform)** for providing a free `AI Video Generator` service based on this
|
||||
project. It allows for online use without deployment, which is very convenient.
|
||||
|
||||
- Chinese version: https://reccloud.cn
|
||||
- English version: https://reccloud.com
|
||||
|
||||

|
||||
|
||||
## Thanks for Sponsorship 🙏
|
||||
|
||||
Thanks to Picwish https://picwish.com for supporting and sponsoring this project, enabling continuous updates and maintenance.
|
||||
|
||||
Picwish focuses on the **image processing field**, providing a rich set of **image processing tools** that extremely simplify complex operations, truly making image processing easier.
|
||||
|
||||

|
||||
|
||||
## Features 🎯
|
||||
|
||||
- [x] Complete **MVC architecture**, **clearly structured** code, easy to maintain, supports both `API`
|
||||
and `Web interface`
|
||||
- [x] Supports **AI-generated** video copy, as well as **customized copy**
|
||||
- [x] Supports various **high-definition video** sizes
|
||||
- [x] Portrait 9:16, `1080x1920`
|
||||
- [x] Landscape 16:9, `1920x1080`
|
||||
- [x] Supports **batch video generation**, allowing the creation of multiple videos at once, then selecting the most
|
||||
satisfactory one
|
||||
- [x] Supports setting the **duration of video clips**, facilitating adjustments to material switching frequency
|
||||
- [x] Supports video copy in both **Chinese** and **English**
|
||||
- [x] Supports **multiple voice** synthesis, with **real-time preview** of effects
|
||||
- [x] Supports **subtitle generation**, with adjustable `font`, `position`, `color`, `size`, and also
|
||||
supports `subtitle outlining`
|
||||
- [x] Supports **background music**, either random or specified music files, with adjustable `background music volume`
|
||||
- [x] Video material sources are **high-definition** and **royalty-free**, and you can also use your own **local materials**
|
||||
- [x] Supports integration with various models such as **OpenAI**, **Moonshot**, **Azure**, **gpt4free**, **one-api**, **Qwen**, **Google Gemini**, **Ollama**, **DeepSeek**, **ERNIE**, **Pollinations** and more
|
||||
|
||||
### Future Plans 📅
|
||||
|
||||
- [ ] GPT-SoVITS dubbing support
|
||||
- [ ] Optimize voice synthesis using large models for more natural and emotionally rich voice output
|
||||
- [ ] Add video transition effects for a smoother viewing experience
|
||||
- [ ] Add more video material sources, improve the matching between video materials and script
|
||||
- [ ] Add video length options: short, medium, long
|
||||
- [ ] Support more voice synthesis providers, such as OpenAI TTS
|
||||
- [ ] Automate upload to YouTube platform
|
||||
|
||||
## Video Demos 📺
|
||||
|
||||
### Portrait 9:16
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> How to Add Fun to Your Life </th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> What is the Meaning of Life</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/a84d33d5-27a2-4aba-8fd0-9fb2bd91c6a6"></video></td>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/112c9564-d52b-4472-99ad-970b75f66476"></video></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Landscape 16:9
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> What is the Meaning of Life</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> Why Exercise</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/346ebb15-c55f-47a9-a653-114f08bb8073"></video></td>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/271f2fae-8283-44a0-8aa0-0ed8f9a6fa87"></video></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## System Requirements 📦
|
||||
|
||||
- Recommended minimum 4 CPU cores or more, 4G of memory or more, GPU is not required
|
||||
- Windows 10 or MacOS 11.0, and their later versions
|
||||
|
||||
## Quick Start 🚀
|
||||
|
||||
### Run in Google Colab
|
||||
Want to try MoneyPrinterTurbo without setting up a local environment? Run it directly in Google Colab!
|
||||
|
||||
[](https://colab.research.google.com/github/harry0703/MoneyPrinterTurbo/blob/main/docs/MoneyPrinterTurbo.ipynb)
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
Google Drive (v1.2.6): https://drive.google.com/file/d/1HsbzfT7XunkrCrHw5ncUjFX8XX4zAuUh/view?usp=sharing
|
||||
|
||||
After downloading, it is recommended to **double-click** `update.bat` first to update to the **latest code**, then double-click `start.bat` to launch
|
||||
|
||||
After launching, the browser will open automatically (if it opens blank, it is recommended to use **Chrome** or **Edge**)
|
||||
|
||||
### Other Systems
|
||||
|
||||
One-click startup packages have not been created yet. See the **Installation & Deployment** section below. It is recommended to use **docker** for deployment, which is more convenient.
|
||||
|
||||
## Installation & Deployment 📥
|
||||
|
||||
### Prerequisites
|
||||
|
||||
#### ① Clone the Project
|
||||
|
||||
```shell
|
||||
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
```
|
||||
|
||||
#### ② Modify the Configuration File
|
||||
|
||||
- Copy the `config.example.toml` file and rename it to `config.toml`
|
||||
- Follow the instructions in the `config.toml` file to configure `pexels_api_keys` and `llm_provider`, and according to
|
||||
the llm_provider's service provider, set up the corresponding API Key
|
||||
|
||||
### Docker Deployment 🐳
|
||||
|
||||
#### ① Launch the Docker Container
|
||||
|
||||
If you haven't installed Docker, please install it first https://www.docker.com/products/docker-desktop/
|
||||
If you are using a Windows system, please refer to Microsoft's documentation:
|
||||
|
||||
1. https://learn.microsoft.com/en-us/windows/wsl/install
|
||||
2. https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers
|
||||
|
||||
```shell
|
||||
cd MoneyPrinterTurbo
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
> Note:The latest version of docker will automatically install docker compose in the form of a plug-in, and the start command is adjusted to `docker compose up `
|
||||
|
||||
#### ② Access the Web Interface
|
||||
|
||||
Open your browser and visit http://0.0.0.0:8501
|
||||
|
||||
#### ③ Access the API Interface
|
||||
|
||||
Open your browser and visit http://0.0.0.0:8080/docs Or http://0.0.0.0:8080/redoc
|
||||
|
||||
### Manual Deployment 📦
|
||||
|
||||
#### ① Create a Python Virtual Environment
|
||||
|
||||
It is recommended to create a Python virtual environment using [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
|
||||
|
||||
```shell
|
||||
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
cd MoneyPrinterTurbo
|
||||
conda create -n MoneyPrinterTurbo python=3.11
|
||||
conda activate MoneyPrinterTurbo
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
#### ② Install ImageMagick
|
||||
|
||||
###### Windows:
|
||||
|
||||
- Download https://imagemagick.org/script/download.php Choose the Windows version, make sure to select the **static library** version, such as ImageMagick-7.1.1-32-Q16-x64-**static**.exe
|
||||
- Install the downloaded ImageMagick, **do not change the installation path**
|
||||
- Modify the `config.toml` configuration file, set `imagemagick_path` to your actual installation path
|
||||
|
||||
###### MacOS:
|
||||
|
||||
```shell
|
||||
brew install imagemagick
|
||||
````
|
||||
|
||||
###### Ubuntu
|
||||
|
||||
```shell
|
||||
sudo apt-get install imagemagick
|
||||
```
|
||||
|
||||
###### CentOS
|
||||
|
||||
```shell
|
||||
sudo yum install ImageMagick
|
||||
```
|
||||
|
||||
#### ③ Launch the Web Interface 🌐
|
||||
|
||||
Note that you need to execute the following commands in the `root directory` of the MoneyPrinterTurbo project
|
||||
|
||||
###### Windows
|
||||
|
||||
```bat
|
||||
webui.bat
|
||||
```
|
||||
|
||||
###### MacOS or Linux
|
||||
|
||||
```shell
|
||||
sh webui.sh
|
||||
```
|
||||
|
||||
After launching, the browser will open automatically
|
||||
|
||||
#### ④ Launch the API Service 🚀
|
||||
|
||||
```shell
|
||||
python main.py
|
||||
```
|
||||
|
||||
After launching, you can view the `API documentation` at http://127.0.0.1:8080/docs and directly test the interface
|
||||
online for a quick experience.
|
||||
|
||||
## Voice Synthesis 🗣
|
||||
|
||||
A list of all supported voices can be viewed here: [Voice List](./docs/voice-list.txt)
|
||||
|
||||
2024-04-16 v1.1.2 Added 9 new Azure voice synthesis voices that require API KEY configuration. These voices sound more realistic.
|
||||
|
||||
## Subtitle Generation 📜
|
||||
|
||||
Currently, there are 2 ways to generate subtitles:
|
||||
|
||||
- **edge**: Faster generation speed, better performance, no specific requirements for computer configuration, but the
|
||||
quality may be unstable
|
||||
- **whisper**: Slower generation speed, poorer performance, specific requirements for computer configuration, but more
|
||||
reliable quality
|
||||
|
||||
You can switch between them by modifying the `subtitle_provider` in the `config.toml` configuration file
|
||||
|
||||
It is recommended to use `edge` mode, and switch to `whisper` mode if the quality of the subtitles generated is not
|
||||
satisfactory.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> 1. In whisper mode, you need to download a model file from HuggingFace, about 3GB in size, please ensure good internet connectivity
|
||||
> 2. If left blank, it means no subtitles will be generated.
|
||||
|
||||
> Since HuggingFace is not accessible in China, you can use the following methods to download the `whisper-large-v3` model file
|
||||
|
||||
Download links:
|
||||
|
||||
- Baidu Netdisk: https://pan.baidu.com/s/11h3Q6tsDtjQKTjUu3sc5cA?pwd=xjs9
|
||||
- Quark Netdisk: https://pan.quark.cn/s/3ee3d991d64b
|
||||
|
||||
After downloading the model, extract it and place the entire directory in `.\MoneyPrinterTurbo\models`,
|
||||
The final file path should look like this: `.\MoneyPrinterTurbo\models\whisper-large-v3`
|
||||
|
||||
```
|
||||
MoneyPrinterTurbo
|
||||
├─models
|
||||
│ └─whisper-large-v3
|
||||
│ config.json
|
||||
│ model.bin
|
||||
│ preprocessor_config.json
|
||||
│ tokenizer.json
|
||||
│ vocabulary.json
|
||||
```
|
||||
|
||||
## Background Music 🎵
|
||||
|
||||
Background music for videos is located in the project's `resource/songs` directory.
|
||||
> The current project includes some default music from YouTube videos. If there are copyright issues, please delete
|
||||
> them.
|
||||
|
||||
## Subtitle Fonts 🅰
|
||||
|
||||
Fonts for rendering video subtitles are located in the project's `resource/fonts` directory, and you can also add your
|
||||
own fonts.
|
||||
|
||||
## Common Questions 🤔
|
||||
|
||||
### ❓RuntimeError: No ffmpeg exe could be found
|
||||
|
||||
Normally, ffmpeg will be automatically downloaded and detected.
|
||||
However, if your environment has issues preventing automatic downloads, you may encounter the following error:
|
||||
|
||||
```
|
||||
RuntimeError: No ffmpeg exe could be found.
|
||||
Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
|
||||
```
|
||||
|
||||
In this case, you can download ffmpeg from https://www.gyan.dev/ffmpeg/builds/, unzip it, and set `ffmpeg_path` to your
|
||||
actual installation path.
|
||||
|
||||
```toml
|
||||
[app]
|
||||
# Please set according to your actual path, note that Windows path separators are \\
|
||||
ffmpeg_path = "C:\\Users\\harry\\Downloads\\ffmpeg.exe"
|
||||
```
|
||||
|
||||
### ❓ImageMagick is not installed on your computer
|
||||
|
||||
[issue 33](https://github.com/harry0703/MoneyPrinterTurbo/issues/33)
|
||||
|
||||
1. Follow the `example configuration` provided `download address` to
|
||||
install https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-30-Q16-x64-static.exe, using the static library
|
||||
2. Do not install in a path with Chinese characters to avoid unpredictable issues
|
||||
|
||||
[issue 54](https://github.com/harry0703/MoneyPrinterTurbo/issues/54#issuecomment-2017842022)
|
||||
|
||||
For Linux systems, you can manually install it, refer to https://cn.linux-console.net/?p=16978
|
||||
|
||||
Thanks to [@wangwenqiao666](https://github.com/wangwenqiao666) for their research and exploration
|
||||
|
||||
### ❓ImageMagick's security policy prevents operations related to temporary file @/tmp/tmpur5hyyto.txt
|
||||
|
||||
You can find these policies in ImageMagick's configuration file policy.xml.
|
||||
This file is usually located in /etc/ImageMagick-`X`/ or a similar location in the ImageMagick installation directory.
|
||||
Modify the entry containing `pattern="@"`, change `rights="none"` to `rights="read|write"` to allow read and write operations on files.
|
||||
|
||||
### ❓OSError: [Errno 24] Too many open files
|
||||
|
||||
This issue is caused by the system's limit on the number of open files. You can solve it by modifying the system's file open limit.
|
||||
|
||||
Check the current limit:
|
||||
|
||||
```shell
|
||||
ulimit -n
|
||||
```
|
||||
|
||||
If it's too low, you can increase it, for example:
|
||||
|
||||
```shell
|
||||
ulimit -n 10240
|
||||
```
|
||||
|
||||
### ❓Whisper model download failed, with the following error
|
||||
|
||||
LocalEntryNotfoundEror: Cannot find an appropriate cached snapshotfolderfor the specified revision on the local disk and
|
||||
outgoing trafic has been disabled.
|
||||
To enablerepo look-ups and downloads online, pass 'local files only=False' as input.
|
||||
|
||||
or
|
||||
|
||||
An error occured while synchronizing the model Systran/faster-whisper-large-v3 from the Hugging Face Hub:
|
||||
An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the
|
||||
specified revision on the local disk. Please check your internet connection and try again.
|
||||
Trying to load the model directly from the local cache, if it exists.
|
||||
|
||||
Solution: [Click to see how to manually download the model from netdisk](#subtitle-generation-)
|
||||
|
||||
## Feedback & Suggestions 📢
|
||||
|
||||
- You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or
|
||||
a [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls).
|
||||
|
||||
## License 📝
|
||||
|
||||
Click to view the [`LICENSE`](LICENSE) file
|
||||
|
||||
## Star History
|
||||
|
||||
[](https://star-history.com/#harry0703/MoneyPrinterTurbo&Date)
|
||||
345
README.md
345
README.md
@ -1,105 +1,75 @@
|
||||
<div align="center">
|
||||
<h1 align="center">MoneyPrinterTurbo 💸</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/stargazers"><img src="https://img.shields.io/github/stars/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="Stargazers"></a>
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/issues"><img src="https://img.shields.io/github/issues/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="Issues"></a>
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/network/members"><img src="https://img.shields.io/github/forks/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="Forks"></a>
|
||||
<a href="https://github.com/harry0703/MoneyPrinterTurbo/blob/main/LICENSE"><img src="https://img.shields.io/github/license/harry0703/MoneyPrinterTurbo.svg?style=for-the-badge" alt="License"></a>
|
||||
</p>
|
||||
<br>
|
||||
<h3>简体中文 | <a href="README-en.md">English</a></h3>
|
||||
<div align="center">
|
||||
<a href="https://trendshift.io/repositories/8731" target="_blank"><img src="https://trendshift.io/api/badge/repositories/8731" alt="harry0703%2FMoneyPrinterTurbo | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||
</div>
|
||||
<br>
|
||||
只需提供一个视频 <b>主题</b> 或 <b>关键词</b> ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。
|
||||
<br>
|
||||
|
||||
<h4>Web界面</h4>
|
||||
Simply provide a <b>topic</b> or <b>keyword</b> for a video, and it will automatically generate the video copy, video
|
||||
materials, video subtitles, and video background music before synthesizing a high-definition short video.
|
||||
|
||||

|
||||
### WebUI
|
||||
|
||||
<h4>API界面</h4>
|
||||

|
||||
|
||||
### API Interface
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
## 特别感谢 🙏
|
||||
## Features 🎯
|
||||
|
||||
由于该项目的 **部署** 和 **使用**,对于一些小白用户来说,还是 **有一定的门槛**,在此特别感谢
|
||||
**录咖(AI智能 多媒体服务平台)** 网站基于该项目,提供的免费`AI视频生成器`服务,可以不用部署,直接在线使用,非常方便。
|
||||
- [x] Complete **MVC architecture**, **clearly structured** code, easy to maintain, supports both `API`
|
||||
and `Web interface`
|
||||
- [x] Supports **AI-generated** video copy, as well as **customized copy**
|
||||
- [x] Supports various **high-definition video** sizes
|
||||
- [x] Portrait 9:16, `1080x1920`
|
||||
- [x] Landscape 16:9, `1920x1080`
|
||||
- [x] Supports **batch video generation**, allowing the creation of multiple videos at once, then selecting the most
|
||||
satisfactory one
|
||||
- [x] Supports setting the **duration of video clips**, facilitating adjustments to material switching frequency
|
||||
- [x] Supports video copy in both **Chinese** and **English**
|
||||
- [x] Supports **multiple voice** synthesis, with **real-time preview** of effects
|
||||
- [x] Supports **subtitle generation**, with adjustable `font`, `position`, `color`, `size`, and also
|
||||
supports `subtitle outlining`
|
||||
- [x] Supports **background music**, either random or specified music files, with adjustable `background music volume`
|
||||
- [x] Video material sources are **high-definition** and **royalty-free**, and you can also use your own **local materials**
|
||||
- [x] Supports integration with various models such as **OpenAI**, **Moonshot**, **Azure**, **gpt4free**, **one-api**, **Qwen**, **Google Gemini**, **Ollama**, **DeepSeek**, **ERNIE**, **Pollinations** and more
|
||||
|
||||
- 中文版:https://reccloud.cn
|
||||
- 英文版:https://reccloud.com
|
||||
### Future Plans 📅
|
||||
|
||||

|
||||
- [ ] GPT-SoVITS dubbing support
|
||||
- [ ] Optimize voice synthesis using large models for more natural and emotionally rich voice output
|
||||
- [ ] Add video transition effects for a smoother viewing experience
|
||||
- [ ] Add more video material sources, improve the matching between video materials and script
|
||||
- [ ] Add video length options: short, medium, long
|
||||
- [ ] Support more voice synthesis providers, such as OpenAI TTS
|
||||
- [ ] Automate upload to YouTube platform
|
||||
|
||||
## 感谢赞助 🙏
|
||||
## Video Demos 📺
|
||||
|
||||
感谢佐糖 https://picwish.cn 对该项目的支持和赞助,使得该项目能够持续的更新和维护。
|
||||
|
||||
佐糖专注于**图像处理领域**,提供丰富的**图像处理工具**,将复杂操作极致简化,真正实现让图像处理更简单。
|
||||
|
||||

|
||||
|
||||
## 功能特性 🎯
|
||||
|
||||
- [x] 完整的 **MVC架构**,代码 **结构清晰**,易于维护,支持 `API` 和 `Web界面`
|
||||
- [x] 支持视频文案 **AI自动生成**,也可以**自定义文案**
|
||||
- [x] 支持多种 **高清视频** 尺寸
|
||||
- [x] 竖屏 9:16,`1080x1920`
|
||||
- [x] 横屏 16:9,`1920x1080`
|
||||
- [x] 支持 **批量视频生成**,可以一次生成多个视频,然后选择一个最满意的
|
||||
- [x] 支持 **视频片段时长** 设置,方便调节素材切换频率
|
||||
- [x] 支持 **中文** 和 **英文** 视频文案
|
||||
- [x] 支持 **多种语音** 合成,可 **实时试听** 效果
|
||||
- [x] 支持 **字幕生成**,可以调整 `字体`、`位置`、`颜色`、`大小`,同时支持`字幕描边`设置
|
||||
- [x] 支持 **背景音乐**,随机或者指定音乐文件,可设置`背景音乐音量`
|
||||
- [x] 视频素材来源 **高清**,而且 **无版权**,也可以使用自己的 **本地素材**
|
||||
- [x] 支持 **OpenAI**、**Moonshot**、**Azure**、**gpt4free**、**one-api**、**通义千问**、**Google Gemini**、**Ollama**、**DeepSeek**、 **文心一言**, **Pollinations** 等多种模型接入
|
||||
- 中国用户建议使用 **DeepSeek** 或 **Moonshot** 作为大模型提供商(国内可直接访问,不需要VPN。注册就送额度,基本够用)
|
||||
|
||||
|
||||
### 后期计划 📅
|
||||
|
||||
- [ ] GPT-SoVITS 配音支持
|
||||
- [ ] 优化语音合成,利用大模型,使其合成的声音,更加自然,情绪更加丰富
|
||||
- [ ] 增加视频转场效果,使其看起来更加的流畅
|
||||
- [ ] 增加更多视频素材来源,优化视频素材和文案的匹配度
|
||||
- [ ] 增加视频长度选项:短、中、长
|
||||
- [ ] 支持更多的语音合成服务商,比如 OpenAI TTS
|
||||
- [ ] 自动上传到YouTube平台
|
||||
|
||||
## 视频演示 📺
|
||||
|
||||
### 竖屏 9:16
|
||||
### Portrait 9:16
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> 《如何增加生活的乐趣》</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> 《金钱的作用》<br>更真实的合成声音</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> 《生命的意义是什么》</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> How to Add Fun to Your Life </th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> What is the Meaning of Life</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/a84d33d5-27a2-4aba-8fd0-9fb2bd91c6a6"></video></td>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/af2f3b0b-002e-49fe-b161-18ba91c055e8"></video></td>
|
||||
<td align="center"><video src="https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/112c9564-d52b-4472-99ad-970b75f66476"></video></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### 横屏 16:9
|
||||
### Landscape 16:9
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji>《生命的意义是什么》</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji>《为什么要运动》</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> What is the Meaning of Life</th>
|
||||
<th align="center"><g-emoji class="g-emoji" alias="arrow_forward">▶️</g-emoji> Why Exercise</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -110,86 +80,79 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## 配置要求 📦
|
||||
## System Requirements 📦
|
||||
|
||||
- 建议最低 CPU **4核** 或以上,内存 **4G** 或以上,显卡非必须
|
||||
- Windows 10 或 MacOS 11.0 以上系统
|
||||
- Recommended minimum 4 CPU cores or more, 4G of memory or more, GPU is not required
|
||||
- Windows 10 or MacOS 11.0, and their later versions
|
||||
|
||||
## New updates and features will be released in the [changelog](CHANGELOG.md) file
|
||||
|
||||
## 快速开始 🚀
|
||||
## Quick Start 🚀
|
||||
|
||||
### 在 Google Colab 中运行
|
||||
免去本地环境配置,点击直接在 Google Colab 中快速体验 MoneyPrinterTurbo
|
||||
### Run in Google Colab
|
||||
Want to try MoneyPrinterTurbo without setting up a local environment? Run it directly in Google Colab!
|
||||
|
||||
[](https://colab.research.google.com/github/harry0703/MoneyPrinterTurbo/blob/main/docs/MoneyPrinterTurbo.ipynb)
|
||||
|
||||
|
||||
### Windows一键启动包
|
||||
### Windows
|
||||
|
||||
下载一键启动包,解压直接使用(路径不要有 **中文**、**特殊字符**、**空格**)
|
||||
Google Drive (v1.2.6): https://drive.google.com/file/d/1HsbzfT7XunkrCrHw5ncUjFX8XX4zAuUh/view?usp=sharing
|
||||
|
||||
- 百度网盘(v1.2.6): https://pan.baidu.com/s/1wg0UaIyXpO3SqIpaq790SQ?pwd=sbqx 提取码: sbqx
|
||||
- Google Drive (v1.2.6): https://drive.google.com/file/d/1HsbzfT7XunkrCrHw5ncUjFX8XX4zAuUh/view?usp=sharing
|
||||
After downloading, it is recommended to **double-click** `update.bat` first to update to the **latest code**, then double-click `start.bat` to launch
|
||||
|
||||
下载后,建议先**双击执行** `update.bat` 更新到**最新代码**,然后双击 `start.bat` 启动
|
||||
After launching, the browser will open automatically (if it opens blank, it is recommended to use **Chrome** or **Edge**)
|
||||
|
||||
启动后,会自动打开浏览器(如果打开是空白,建议换成 **Chrome** 或者 **Edge** 打开)
|
||||
### Other Systems
|
||||
|
||||
## 安装部署 📥
|
||||
One-click startup packages have not been created yet. See the **Installation & Deployment** section below. It is recommended to use **docker** for deployment, which is more convenient.
|
||||
|
||||
### 前提条件
|
||||
## Installation & Deployment 📥
|
||||
|
||||
- 尽量不要使用 **中文路径**,避免出现一些无法预料的问题
|
||||
- 请确保你的 **网络** 是正常的,VPN需要打开`全局流量`模式
|
||||
### Prerequisites
|
||||
|
||||
#### ① 克隆代码
|
||||
#### ① Clone the Project
|
||||
|
||||
```shell
|
||||
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
```
|
||||
|
||||
#### ② 修改配置文件(可选,建议启动后也可以在 WebUI 里面配置)
|
||||
#### ② Modify the Configuration File
|
||||
|
||||
- 将 `config.example.toml` 文件复制一份,命名为 `config.toml`
|
||||
- 按照 `config.toml` 文件中的说明,配置好 `pexels_api_keys` 和 `llm_provider`,并根据 llm_provider 对应的服务商,配置相关的
|
||||
API Key
|
||||
- Copy the `config.example.toml` file and rename it to `config.toml`
|
||||
- Follow the instructions in the `config.toml` file to configure `pexels_api_keys` and `llm_provider`, and according to
|
||||
the llm_provider's service provider, set up the corresponding API Key
|
||||
|
||||
### Docker部署 🐳
|
||||
### Docker Deployment 🐳
|
||||
|
||||
#### ① 启动Docker
|
||||
#### ① Launch the Docker Container
|
||||
|
||||
如果未安装 Docker,请先安装 https://www.docker.com/products/docker-desktop/
|
||||
If you haven't installed Docker, please install it first https://www.docker.com/products/docker-desktop/
|
||||
If you are using a Windows system, please refer to Microsoft's documentation:
|
||||
|
||||
如果是Windows系统,请参考微软的文档:
|
||||
|
||||
1. https://learn.microsoft.com/zh-cn/windows/wsl/install
|
||||
2. https://learn.microsoft.com/zh-cn/windows/wsl/tutorials/wsl-containers
|
||||
1. https://learn.microsoft.com/en-us/windows/wsl/install
|
||||
2. https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers
|
||||
|
||||
```shell
|
||||
cd MoneyPrinterTurbo
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
> 注意:最新版的docker安装时会自动以插件的形式安装docker compose,启动命令调整为docker compose up
|
||||
> Note:The latest version of docker will automatically install docker compose in the form of a plug-in, and the start command is adjusted to `docker compose up `
|
||||
|
||||
#### ② 访问Web界面
|
||||
#### ② Access the Web Interface
|
||||
|
||||
打开浏览器,访问 http://0.0.0.0:8501
|
||||
Open your browser and visit http://0.0.0.0:8501
|
||||
|
||||
#### ③ 访问API文档
|
||||
#### ③ Access the API Interface
|
||||
|
||||
打开浏览器,访问 http://0.0.0.0:8080/docs 或者 http://0.0.0.0:8080/redoc
|
||||
Open your browser and visit http://0.0.0.0:8080/docs Or http://0.0.0.0:8080/redoc
|
||||
|
||||
### 手动部署 📦
|
||||
### Manual Deployment 📦
|
||||
|
||||
> 视频教程
|
||||
#### ① Create a Python Virtual Environment
|
||||
|
||||
- 完整的使用演示:https://v.douyin.com/iFhnwsKY/
|
||||
- 如何在Windows上部署:https://v.douyin.com/iFyjoW3M
|
||||
|
||||
#### ① 创建虚拟环境
|
||||
|
||||
建议使用 [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) 创建 python 虚拟环境
|
||||
It is recommended to create a Python virtual environment using [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
|
||||
|
||||
```shell
|
||||
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
|
||||
@ -199,30 +162,35 @@ conda activate MoneyPrinterTurbo
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
#### ② 安装好 ImageMagick
|
||||
#### ② Install ImageMagick
|
||||
|
||||
- Windows:
|
||||
- 下载 https://imagemagick.org/script/download.php 选择Windows版本,切记一定要选择 **静态库** 版本,比如
|
||||
ImageMagick-7.1.1-32-Q16-x64-**static**.exe
|
||||
- 安装下载好的 ImageMagick,**注意不要修改安装路径**
|
||||
- 修改 `配置文件 config.toml` 中的 `imagemagick_path` 为你的 **实际安装路径**
|
||||
###### Windows:
|
||||
|
||||
- MacOS:
|
||||
```shell
|
||||
brew install imagemagick
|
||||
````
|
||||
- Ubuntu
|
||||
```shell
|
||||
sudo apt-get install imagemagick
|
||||
```
|
||||
- CentOS
|
||||
```shell
|
||||
sudo yum install ImageMagick
|
||||
```
|
||||
- Download https://imagemagick.org/script/download.php Choose the Windows version, make sure to select the **static library** version, such as ImageMagick-7.1.1-32-Q16-x64-**static**.exe
|
||||
- Install the downloaded ImageMagick, **do not change the installation path**
|
||||
- Modify the `config.toml` configuration file, set `imagemagick_path` to your actual installation path
|
||||
|
||||
#### ③ 启动Web界面 🌐
|
||||
###### MacOS:
|
||||
|
||||
注意需要到 MoneyPrinterTurbo 项目 `根目录` 下执行以下命令
|
||||
```shell
|
||||
brew install imagemagick
|
||||
````
|
||||
|
||||
###### Ubuntu
|
||||
|
||||
```shell
|
||||
sudo apt-get install imagemagick
|
||||
```
|
||||
|
||||
###### CentOS
|
||||
|
||||
```shell
|
||||
sudo yum install ImageMagick
|
||||
```
|
||||
|
||||
#### ③ Launch the Web Interface 🌐
|
||||
|
||||
Note that you need to execute the following commands in the `root directory` of the MoneyPrinterTurbo project
|
||||
|
||||
###### Windows
|
||||
|
||||
@ -236,50 +204,54 @@ webui.bat
|
||||
sh webui.sh
|
||||
```
|
||||
|
||||
启动后,会自动打开浏览器(如果打开是空白,建议换成 **Chrome** 或者 **Edge** 打开)
|
||||
After launching, the browser will open automatically
|
||||
|
||||
#### ④ 启动API服务 🚀
|
||||
#### ④ Launch the API Service 🚀
|
||||
|
||||
```shell
|
||||
python main.py
|
||||
```
|
||||
|
||||
启动后,可以查看 `API文档` http://127.0.0.1:8080/docs 或者 http://127.0.0.1:8080/redoc 直接在线调试接口,快速体验。
|
||||
After launching, you can view the `API documentation` at http://127.0.0.1:8080/docs and directly test the interface
|
||||
online for a quick experience.
|
||||
|
||||
## 语音合成 🗣
|
||||
## Voice Synthesis 🗣
|
||||
|
||||
所有支持的声音列表,可以查看:[声音列表](./docs/voice-list.txt)
|
||||
A list of all supported voices can be viewed here: [Voice List](./docs/voice-list.txt)
|
||||
|
||||
2024-04-16 v1.1.2 新增了9种Azure的语音合成声音,需要配置API KEY,该声音合成的更加真实。
|
||||
2024-04-16 v1.1.2 Added 9 new Azure voice synthesis voices that require API KEY configuration. These voices sound more realistic.
|
||||
|
||||
## 字幕生成 📜
|
||||
## Subtitle Generation 📜
|
||||
|
||||
当前支持2种字幕生成方式:
|
||||
Currently, there are 2 ways to generate subtitles:
|
||||
|
||||
- **edge**: 生成`速度快`,性能更好,对电脑配置没有要求,但是质量可能不稳定
|
||||
- **whisper**: 生成`速度慢`,性能较差,对电脑配置有一定要求,但是`质量更可靠`。
|
||||
- **edge**: Faster generation speed, better performance, no specific requirements for computer configuration, but the
|
||||
quality may be unstable
|
||||
- **whisper**: Slower generation speed, poorer performance, specific requirements for computer configuration, but more
|
||||
reliable quality
|
||||
|
||||
可以修改 `config.toml` 配置文件中的 `subtitle_provider` 进行切换
|
||||
You can switch between them by modifying the `subtitle_provider` in the `config.toml` configuration file
|
||||
|
||||
建议使用 `edge` 模式,如果生成的字幕质量不好,再切换到 `whisper` 模式
|
||||
It is recommended to use `edge` mode, and switch to `whisper` mode if the quality of the subtitles generated is not
|
||||
satisfactory.
|
||||
|
||||
> 注意:
|
||||
> Note:
|
||||
>
|
||||
> 1. In whisper mode, you need to download a model file from HuggingFace, about 3GB in size, please ensure good internet connectivity
|
||||
> 2. If left blank, it means no subtitles will be generated.
|
||||
|
||||
1. whisper 模式下需要到 HuggingFace 下载一个模型文件,大约 3GB 左右,请确保网络通畅
|
||||
2. 如果留空,表示不生成字幕。
|
||||
> Since HuggingFace is not accessible in China, you can use the following methods to download the `whisper-large-v3` model file
|
||||
|
||||
> 由于国内无法访问 HuggingFace,可以使用以下方法下载 `whisper-large-v3` 的模型文件
|
||||
Download links:
|
||||
|
||||
下载地址:
|
||||
- Baidu Netdisk: https://pan.baidu.com/s/11h3Q6tsDtjQKTjUu3sc5cA?pwd=xjs9
|
||||
- Quark Netdisk: https://pan.quark.cn/s/3ee3d991d64b
|
||||
|
||||
- 百度网盘: https://pan.baidu.com/s/11h3Q6tsDtjQKTjUu3sc5cA?pwd=xjs9
|
||||
- 夸克网盘:https://pan.quark.cn/s/3ee3d991d64b
|
||||
|
||||
模型下载后解压,整个目录放到 `.\MoneyPrinterTurbo\models` 里面,
|
||||
最终的文件路径应该是这样: `.\MoneyPrinterTurbo\models\whisper-large-v3`
|
||||
After downloading the model, extract it and place the entire directory in `.\MoneyPrinterTurbo\models`,
|
||||
The final file path should look like this: `.\MoneyPrinterTurbo\models\whisper-large-v3`
|
||||
|
||||
```
|
||||
MoneyPrinterTurbo
|
||||
MoneyPrinterTurbo
|
||||
├─models
|
||||
│ └─whisper-large-v3
|
||||
│ config.json
|
||||
@ -289,81 +261,98 @@ MoneyPrinterTurbo
|
||||
│ vocabulary.json
|
||||
```
|
||||
|
||||
## 背景音乐 🎵
|
||||
## Background Music 🎵
|
||||
|
||||
用于视频的背景音乐,位于项目的 `resource/songs` 目录下。
|
||||
> 当前项目里面放了一些默认的音乐,来自于 YouTube 视频,如有侵权,请删除。
|
||||
Background music for videos is located in the project's `resource/songs` directory.
|
||||
> The current project includes some default music from YouTube videos. If there are copyright issues, please delete
|
||||
> them.
|
||||
|
||||
## 字幕字体 🅰
|
||||
## Subtitle Fonts 🅰
|
||||
|
||||
用于视频字幕的渲染,位于项目的 `resource/fonts` 目录下,你也可以放进去自己的字体。
|
||||
Fonts for rendering video subtitles are located in the project's `resource/fonts` directory, and you can also add your
|
||||
own fonts.
|
||||
|
||||
## 常见问题 🤔
|
||||
## Common Questions 🤔
|
||||
|
||||
### ❓RuntimeError: No ffmpeg exe could be found
|
||||
|
||||
通常情况下,ffmpeg 会被自动下载,并且会被自动检测到。
|
||||
但是如果你的环境有问题,无法自动下载,可能会遇到如下错误:
|
||||
Normally, ffmpeg will be automatically downloaded and detected.
|
||||
However, if your environment has issues preventing automatic downloads, you may encounter the following error:
|
||||
|
||||
```
|
||||
RuntimeError: No ffmpeg exe could be found.
|
||||
Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
|
||||
```
|
||||
|
||||
此时你可以从 https://www.gyan.dev/ffmpeg/builds/ 下载ffmpeg,解压后,设置 `ffmpeg_path` 为你的实际安装路径即可。
|
||||
In this case, you can download ffmpeg from https://www.gyan.dev/ffmpeg/builds/, unzip it, and set `ffmpeg_path` to your
|
||||
actual installation path.
|
||||
|
||||
```toml
|
||||
[app]
|
||||
# 请根据你的实际路径设置,注意 Windows 路径分隔符为 \\
|
||||
# Please set according to your actual path, note that Windows path separators are \\
|
||||
ffmpeg_path = "C:\\Users\\harry\\Downloads\\ffmpeg.exe"
|
||||
```
|
||||
|
||||
### ❓ImageMagick的安全策略阻止了与临时文件@/tmp/tmpur5hyyto.txt相关的操作
|
||||
### ❓ImageMagick is not installed on your computer
|
||||
|
||||
可以在ImageMagick的配置文件policy.xml中找到这些策略。
|
||||
这个文件通常位于 /etc/ImageMagick-`X`/ 或 ImageMagick 安装目录的类似位置。
|
||||
修改包含`pattern="@"`的条目,将`rights="none"`更改为`rights="read|write"`以允许对文件的读写操作。
|
||||
[issue 33](https://github.com/harry0703/MoneyPrinterTurbo/issues/33)
|
||||
|
||||
1. Follow the `example configuration` provided `download address` to
|
||||
install https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-30-Q16-x64-static.exe, using the static library
|
||||
2. Do not install in a path with Chinese characters to avoid unpredictable issues
|
||||
|
||||
[issue 54](https://github.com/harry0703/MoneyPrinterTurbo/issues/54#issuecomment-2017842022)
|
||||
|
||||
For Linux systems, you can manually install it, refer to https://cn.linux-console.net/?p=16978
|
||||
|
||||
Thanks to [@wangwenqiao666](https://github.com/wangwenqiao666) for their research and exploration
|
||||
|
||||
### ❓ImageMagick's security policy prevents operations related to temporary file @/tmp/tmpur5hyyto.txt
|
||||
|
||||
You can find these policies in ImageMagick's configuration file policy.xml.
|
||||
This file is usually located in /etc/ImageMagick-`X`/ or a similar location in the ImageMagick installation directory.
|
||||
Modify the entry containing `pattern="@"`, change `rights="none"` to `rights="read|write"` to allow read and write operations on files.
|
||||
|
||||
### ❓OSError: [Errno 24] Too many open files
|
||||
|
||||
这个问题是由于系统打开文件数限制导致的,可以通过修改系统的文件打开数限制来解决。
|
||||
This issue is caused by the system's limit on the number of open files. You can solve it by modifying the system's file open limit.
|
||||
|
||||
查看当前限制
|
||||
Check the current limit:
|
||||
|
||||
```shell
|
||||
ulimit -n
|
||||
```
|
||||
|
||||
如果过低,可以调高一些,比如
|
||||
If it's too low, you can increase it, for example:
|
||||
|
||||
```shell
|
||||
ulimit -n 10240
|
||||
```
|
||||
|
||||
### ❓Whisper 模型下载失败,出现如下错误
|
||||
### ❓Whisper model download failed, with the following error
|
||||
|
||||
LocalEntryNotfoundEror: Cannot find an appropriate cached snapshotfolderfor the specified revision on the local disk and
|
||||
outgoing trafic has been disabled.
|
||||
To enablerepo look-ups and downloads online, pass 'local files only=False' as input.
|
||||
|
||||
或者
|
||||
or
|
||||
|
||||
An error occured while synchronizing the model Systran/faster-whisper-large-v3 from the Hugging Face Hub:
|
||||
An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the
|
||||
specified revision on the local disk. Please check your internet connection and try again.
|
||||
Trying to load the model directly from the local cache, if it exists.
|
||||
|
||||
解决方法:[点击查看如何从网盘手动下载模型](#%E5%AD%97%E5%B9%95%E7%94%9F%E6%88%90-)
|
||||
Solution: [Click to see how to manually download the model from netdisk](#subtitle-generation-)
|
||||
|
||||
## 反馈建议 📢
|
||||
## Feedback & Suggestions 📢
|
||||
|
||||
- 可以提交 [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues)
|
||||
或者 [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls)。
|
||||
- You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or
|
||||
a [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls).
|
||||
|
||||
## 许可证 📝
|
||||
## License 📝
|
||||
|
||||
点击查看 [`LICENSE`](LICENSE) 文件
|
||||
Click to view the [`LICENSE`](LICENSE) file
|
||||
|
||||
## Star History
|
||||
|
||||
[](https://star-history.com/#harry0703/MoneyPrinterTurbo&Date)
|
||||
[](https://star-history.com/#harry0703/MoneyPrinterTurbo&Date)
|
||||
|
||||
@ -50,6 +50,9 @@ class SubClippedVideoClip:
|
||||
audio_codec = "aac"
|
||||
video_codec = "libx264"
|
||||
fps = 30
|
||||
video_preset = "medium"
|
||||
video_crf = "23"
|
||||
pixel_format = "yuv420p"
|
||||
|
||||
def close_clip(clip):
|
||||
if clip is None:
|
||||
@ -170,6 +173,9 @@ def combine_videos(
|
||||
|
||||
try:
|
||||
clip = VideoFileClip(subclipped_item.file_path).subclipped(subclipped_item.start_time, subclipped_item.end_time)
|
||||
clip = VideoFileClip(subclipped_item.file_path,
|
||||
target_resolution=(video_height, video_width),
|
||||
audio_fps=44100)
|
||||
clip_duration = clip.duration
|
||||
# Not all videos are same size, so we need to resize them
|
||||
clip_w, clip_h = clip.size
|
||||
@ -179,7 +185,7 @@ def combine_videos(
|
||||
logger.debug(f"resizing clip, source: {clip_w}x{clip_h}, ratio: {clip_ratio:.2f}, target: {video_width}x{video_height}, ratio: {video_ratio:.2f}")
|
||||
|
||||
if clip_ratio == video_ratio:
|
||||
clip = clip.resized(new_size=(video_width, video_height))
|
||||
clip = clip.resized(new_size=(video_width, video_height), method='lanczos')
|
||||
else:
|
||||
if clip_ratio > video_ratio:
|
||||
scale_factor = video_width / clip_w
|
||||
@ -219,8 +225,19 @@ def combine_videos(
|
||||
|
||||
# wirte clip to temp file
|
||||
clip_file = f"{output_dir}/temp-clip-{i+1}.mp4"
|
||||
clip.write_videofile(clip_file, logger=None, fps=fps, codec=video_codec)
|
||||
|
||||
#clip.write_videofile(clip_file, logger=None, fps=fps, codec=video_codec)
|
||||
clip.write_videofile(
|
||||
clip_file,
|
||||
logger=None,
|
||||
fps=fps,
|
||||
codec=video_codec,
|
||||
preset=video_preset,
|
||||
ffmpeg_params=[
|
||||
'-crf', video_crf,
|
||||
'-pix_fmt', pixel_format,
|
||||
'-movflags', '+faststart'
|
||||
]
|
||||
)
|
||||
close_clip(clip)
|
||||
|
||||
processed_clips.append(SubClippedVideoClip(file_path=clip_file, duration=clip.duration, width=clip_w, height=clip_h))
|
||||
@ -275,6 +292,14 @@ def combine_videos(
|
||||
merged_clip = concatenate_videoclips([base_clip, next_clip])
|
||||
|
||||
# save merged result to temp file
|
||||
#merged_clip.write_videofile(
|
||||
# filename=temp_merged_next,
|
||||
# threads=threads,
|
||||
# logger=None,
|
||||
# temp_audiofile_path=output_dir,
|
||||
# audio_codec=audio_codec,
|
||||
# fps=fps,
|
||||
#)
|
||||
merged_clip.write_videofile(
|
||||
filename=temp_merged_next,
|
||||
threads=threads,
|
||||
@ -282,6 +307,12 @@ def combine_videos(
|
||||
temp_audiofile_path=output_dir,
|
||||
audio_codec=audio_codec,
|
||||
fps=fps,
|
||||
preset=video_preset,
|
||||
ffmpeg_params=[
|
||||
'-crf', video_crf,
|
||||
'-pix_fmt', pixel_format,
|
||||
'-movflags', '+faststart'
|
||||
]
|
||||
)
|
||||
close_clip(base_clip)
|
||||
close_clip(next_clip)
|
||||
@ -472,6 +503,14 @@ def generate_video(
|
||||
logger.error(f"failed to add bgm: {str(e)}")
|
||||
|
||||
video_clip = video_clip.with_audio(audio_clip)
|
||||
#video_clip.write_videofile(
|
||||
# output_file,
|
||||
# audio_codec=audio_codec,
|
||||
# temp_audiofile_path=output_dir,
|
||||
# threads=params.n_threads or 2,
|
||||
# logger=None,
|
||||
# fps=fps,
|
||||
#)
|
||||
video_clip.write_videofile(
|
||||
output_file,
|
||||
audio_codec=audio_codec,
|
||||
@ -479,6 +518,12 @@ def generate_video(
|
||||
threads=params.n_threads or 2,
|
||||
logger=None,
|
||||
fps=fps,
|
||||
preset=video_preset,
|
||||
ffmpeg_params=[
|
||||
'-crf', video_crf,
|
||||
'-pix_fmt', pixel_format,
|
||||
'-movflags', '+faststart'
|
||||
]
|
||||
)
|
||||
video_clip.close()
|
||||
del video_clip
|
||||
@ -514,8 +559,13 @@ def preprocess_video(materials: List[MaterialInfo], clip_duration=4):
|
||||
# The zoom effect starts from the original size and gradually scales up to 120%.
|
||||
# t represents the current time, and clip.duration is the total duration of the clip (3 seconds).
|
||||
# Note: 1 represents 100% size, so 1.2 represents 120% size.
|
||||
#zoom_clip = clip.resized(
|
||||
# lambda t: 1 + (clip_duration * 0.03) * (t / clip.duration)
|
||||
#)
|
||||
|
||||
zoom_clip = clip.resized(
|
||||
lambda t: 1 + (clip_duration * 0.03) * (t / clip.duration)
|
||||
lambda t: 1 + (clip_duration * 0.03) * (t / clip.duration),
|
||||
method='lanczos'
|
||||
)
|
||||
|
||||
# Optionally, create a composite video clip containing the zoomed clip.
|
||||
|
||||
@ -3,5 +3,12 @@ set CURRENT_DIR=%CD%
|
||||
echo ***** Current directory: %CURRENT_DIR% *****
|
||||
set PYTHONPATH=%CURRENT_DIR%
|
||||
|
||||
rem set HF_ENDPOINT=https://hf-mirror.com
|
||||
rem Activate Python virtual environment if exists
|
||||
if exist "venv\Scripts\activate.bat" (
|
||||
call venv\Scripts\activate.bat
|
||||
)
|
||||
|
||||
rem Optional Hugging Face mirror setting
|
||||
rem set HF_ENDOINT=https://hf-mirror.com
|
||||
|
||||
streamlit run .\webui\Main.py --browser.gatherUsageStats=False --server.enableCORS=True
|
||||
Loading…
Reference in New Issue
Block a user