最近抖音剪映发布了图文生成视频功能,同时百家号也有这个功能,这个可以看做是一个开源的实现,一起看看它的原理吧~
一句话提示词 | 大模型生成文案 | 百家号生成视频效果 | MoneyPrinterTurbo生成视频效果 |
天空为什么是蓝色的? | 天空之所以呈现蓝色,是因为大气中的分子和小粒子会散射太阳光中的蓝色光线比其他颜色更多。这种现象称为“瑞利散射”。太阳光是由不同颜色的光线组成的,这些颜色的光线混合在一起形成了白光。在地球的大气中,较短的波长,如蓝色和紫色,比较长的波长,如红色和橙色,更容易被散射。然而,我们的眼睛对蓝色光线的敏感度更高,因此我们看到的天空大部分时间都是蓝色的。此外,当太阳接近地平线时,光线需要穿越更多的大气层,这使得更多的蓝色和绿色光线被散射掉,留下的主要是红色和橙色,这就是为什么日落和日出时天空会呈现出红色或橙色的原因。 |
天空为什么是蓝色的?
|
天空为什么是蓝的MPT生成
|
一、项目说明
利用AI大模型,一键生成高清短视频:只需提供一个视频 主题 或 关键词 ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。
1.功能特性
-
完整的MVC架构,代码结构清晰,易于维护,支持
API
和Web界面
-
支持视频文案AI自动生成,也可以自定义文案
-
支持多种高清视频尺寸
-
竖屏 9:16,
1080x1920
-
横屏 16:9,
1920x1080
-
-
支持批量视频生成,可以一次生成多个视频,然后选择一个最满意的
-
支持视频片段时长设置,方便调节素材切换频率
-
支持中文和英文视频文案
-
支持多种语音合成
-
支持字幕生成,可以调整
字体
、位置
、颜色
、大小
,同时支持字幕描边
设置 -
支持背景音乐,随机或者指定音乐文件,可设置
背景音乐音量
-
视频素材来源高清,而且无版权
-
支持OpenAI、moonshot、Azure、gpt4free、one-api、通义千问、Google Gemini、Ollama等多种模型接入
2.后期计划
-
GPT-SoVITS 配音支持
-
优化语音合成,利用大模型,使其合成的声音,更加自然,情绪更加丰富
-
增加视频转场效果,使其看起来更加的流畅
-
增加更多视频素材来源,优化视频素材和文案的匹配度
-
增加视频长度选项:短、中、长
-
打包成一键启动包(Windows,macOS),方便使用
-
增加免费网络代理,让访问OpenAI和素材下载不再受限
-
可以使用自己的素材
-
朗读声音和背景音乐,提供实时试听
-
支持更多的语音合成服务商,比如 OpenAI TTS, Azure TTS
-
自动上传到YouTube平台
二.安装部署
1.安装
-
尽量不要使用 中文路径,避免出现一些无法预料的问题
-
请确保你的 网络 是正常的,VPN需要打开
全局流量
模式
① 克隆代码
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
② 修改配置文件
-
将
config.example.toml
文件复制一份,命名为config.toml
-
按照
config.toml
文件中的说明,配置好pexels_api_keys
和llm_provider
,并根据 llm_provider 对应的服务商,配置相关的 API Key
③ 配置大模型(LLM)
-
如果要使用
GPT-4.0
或GPT-3.5
,需要有OpenAI
的API Key
,如果没有,可以将llm_provider
设置为g4f
( 一个免费使用GPT的开源库 https://github.com/xtekky/gpt4free ,但是该免费的服务,稳定性较差,有时候可以用,有时候用不了) -
或者可以使用到 月之暗面 申请。注册就送 15元体验金,可以对话1500次左右。然后设置
llm_provider="moonshot"
和moonshot_api_key
-
也可以使用 通义千问,具体请看配置文件里面的注释说明
2.部署
① 创建虚拟环境
建议使用conda创建 python 虚拟环境
git clone https://github.com/harry0703/MoneyPrinterTurbo.git
cd MoneyPrinterTurbo
conda create -n MoneyPrinterTurbo python=3.10
conda activate MoneyPrinterTurbo
pip install -r requirements.txt
② 安装好 ImageMagick
Windows:
-
下载https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-29-Q16-x64-static.exe
-
安装下载好的 ImageMagick,注意不要修改安装路径
-
修改
配置文件 config.toml
中的imagemagick_path
为你的实际安装路径(如果安装的时候没有修改路径,直接取消注释即可)
MacOS:
brew install imagemagick
Ubuntu:
sudo apt-get install imagemagick
CentOS:
sudo yum install ImageMagick
③ 启动Web界面
注意需要到 MoneyPrinterTurbo 项目根目录
下执行以下命令
Windows:
conda activate MoneyPrinterTurbo
webui.bat
MacOS or Linux:
conda activate MoneyPrinterTurbo
sh webui.sh
启动后,会自动打开浏览器
④ 启动API服务
python main.py
启动后,可以查看API文档
http://127.0.0.1:8080/docs或者http://127.0.0.1:8080/redoc直接在线调试接口,快速体验
三.源码剖析
1.开发框架
-
UI:Streamlit • A faster way to build and share data apps
-
OpenAPI:FastAPI
2.参数解析
{
"video_subject": "string", ## 视频主题,必选
"video_script": "", ## 视频脚本,可以为空,为空则LLM生成
"video_terms": "string", ## 视频搜索词列表,英文,可以为空,为空则LLM生成
"video_aspect": "9:16", ## 视频宽高比,支持:"16:9""9:16""1:1"
"video_concat_mode": "random", ## 视频拼接方式,支持:"random""sequential"
"video_clip_duration": 5, ## 视频剪辑持续时长,默认5,小于此时长的视频不会被下载
"video_count": 1, ## 视频生成个数,默认1
"video_language": "", ## 视频语言
"voice_name": "", ## 配音人名称
"voice_volume": 1, ## 配音音量,默认1
"bgm_type": "random", ## 背景音乐选择类型,默认random
"bgm_file": "", ## 背景音乐文件
"bgm_volume": 0.2, ## 背景音乐音量大小,默认0.2
"subtitle_enabled": true, ## 生成视频是否包含字幕,默认true
"subtitle_position": "bottom", ## 字幕位置,默认bottom
"font_name": "STHeitiMedium.ttc", ## 字幕字体,默认STHeitiMedium.ttc
"text_fore_color": "#FFFFFF", ## 字幕字体前景色,默认#FFFFFF
"text_background_color": "transparent", ## 字幕字体背景色,默认transparent
"font_size": 60, ## 字幕字体大小,默认60
"stroke_color": "#000000", ## 字幕描边颜色,默认#000000
"stroke_width": 1.5, ## 字幕描边宽度,默认1.5
"n_threads": 2, ## 处理线程数,默认2
"paragraph_number": 1 ## 生成视频段落数量,默认1
}
3.处理流程
3.1.获取配音人信息
配音人格式:语言 - 姓名 - 性别,返回:去除性别的其它部分
# zh-CN-XiaoyiNeural-Female
# zh-CN-YunxiNeural-Male
3.2.视频脚本&视频搜索词生成
视频脚本&视频搜索词生成基于LLM,可以修改 config.toml
配置文件中的 llm_provider 进行切换,目前支持的LLM有:
# openai
# moonshot (月之暗面)
# oneapi
# g4f
# azure
# qwen (通义千问)
# gemini
(1).如果有视频脚本参数为空,则启用LLM生成,生成所需提示词详情如下:
# Role: Video Script Generator
## Goals:
Generate a script for a video, depending on the subject of the video.
## Constrains:
1. the script is to be returned as a string with the specified number of paragraphs.
2. do not under any circumstance reference this prompt in your response.
3. get straight to the point, don't start with unnecessary things like, "welcome to this video".
4. you must not include any type of markdown or formatting in the script, never use a title.
5. only return the raw content of the script.
6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line.
7. you must not mention the prompt, or anything about the script itself. also, never talk about the amount of paragraphs or lines. just write the script.
8. respond in the same language as the video subject.
# Initialization:
- video subject: {视频主题}
- number of paragraphs: {生成的视频段落}
- language: {视频语言}
(2).如果有视频搜索词参数为空,则启用LLM生成,生成所需提示词详情如下:
# Role: Video Search Terms Generator
## Goals:
Generate {amount} search terms for stock videos, depending on the subject of a video.
## Constrains:
1. the search terms are to be returned as a json-array of strings.
2. each search term should consist of 1-3 words, always add the main subject of the video.
3. you must only return the json-array of strings. you must not return anything else. you must not return the script.
4. the search terms must be related to the subject of the video.
5. reply with english search terms only.
## Output Example:
["search term 1", "search term 2", "search term 3","search term 4","search term 5"]
## Context:
### Video Subject
{视频主题}
### Video Script
{视频脚本}
Please note that you must use English for generating video search terms; Chinese is not accepted.
3.3.音频合成
基于edge_tts库进行语音合成(失败尝试3次)
-
代码库:https://github.com/rany2/edge-tts
-
所有支持的声音列表,可以查看:附录-声音列表
-
使用方法:口播神器,基于Edge,微软TTS(text-to-speech)文字转语音免费开源库edge-tts实践(Python3.10)
3.4.字幕生成
当前支持2种字幕生成方式:
-
edge: 生成速度更快,性能更好,对电脑配置没有要求,但是质量可能不稳定
-
whisper: 生成速度较慢,性能较差,对电脑配置有一定要求,但是质量更可靠
可以修改 config.toml
配置文件中的 subtitle_provider
进行切换
建议使用 edge
模式,如果生成的字幕质量不好,再切换到 whisper
模式
注意:
whisper 模式下需要到 HuggingFace 下载一个模型文件,大约 3GB 左右,请确保网络通畅
如果留空,表示不生成字幕。
3.5.视频下载
需要提前在config.toml
文件中配置pexels_api_keys
视频文件搜索基于免费的https://www.pexels.com/zh-cn/提供,详细接口文档见:附录 - Pexels视频搜索接口
-
根据视频搜索词+宽高比作为参数进行检索
-
检索结果去除小于video_clip_duration的视频链接
-
然后根据video_concat_mode进行排序
-
最后按照2.3合成音频总时长顺序下载列表中的视频
3.6.视频合并
视频拼接基于moviepy库:
-
代码库:https://github.com/Zulko/moviepy
-
使用方法:User Guide — MoviePy 1.0.2 documentation
拼接方法:
-
获取音频时长,通过视频个数计算每个视频的时长
-
根据宽高比,获取视频分辨率
-
不停地添加下载的剪辑,直到达到音频的持续时间(根据情况处理时长、resize宽高比分辨率)
3.7.视频生成
基于如上生成的TTS配音、SRT字幕及静音视频,加之以预置的音乐文件,进行视频生成。
-
SRT字幕、静音视频与TTS配音CLIP合成,生成temp视频文件
-
temp视频文件与背景音乐CLIP合成,生成最终视频
用于视频的背景音乐,位于项目的
resource/songs
目录下。用于视频字幕的渲染,位于项目的
resource/fonts
目录下,你也可以放进去自己的字体。
四.附录
1.声音列表
Name: af-ZA-AdriNeural
Gender: Female
Name: af-ZA-WillemNeural
Gender: Male
Name: am-ET-AmehaNeural
Gender: Male
Name: am-ET-MekdesNeural
Gender: Female
Name: ar-AE-FatimaNeural
Gender: Female
Name: ar-AE-HamdanNeural
Gender: Male
Name: ar-BH-AliNeural
Gender: Male
Name: ar-BH-LailaNeural
Gender: Female
Name: ar-DZ-AminaNeural
Gender: Female
Name: ar-DZ-IsmaelNeural
Gender: Male
Name: ar-EG-SalmaNeural
Gender: Female
Name: ar-EG-ShakirNeural
Gender: Male
Name: ar-IQ-BasselNeural
Gender: Male
Name: ar-IQ-RanaNeural
Gender: Female
Name: ar-JO-SanaNeural
Gender: Female
Name: ar-JO-TaimNeural
Gender: Male
Name: ar-KW-FahedNeural
Gender: Male
Name: ar-KW-NouraNeural
Gender: Female
Name: ar-LB-LaylaNeural
Gender: Female
Name: ar-LB-RamiNeural
Gender: Male
Name: ar-LY-ImanNeural
Gender: Female
Name: ar-LY-OmarNeural
Gender: Male
Name: ar-MA-JamalNeural
Gender: Male
Name: ar-MA-MounaNeural
Gender: Female
Name: ar-OM-AbdullahNeural
Gender: Male
Name: ar-OM-AyshaNeural
Gender: Female
Name: ar-QA-AmalNeural
Gender: Female
Name: ar-QA-MoazNeural
Gender: Male
Name: ar-SA-HamedNeural
Gender: Male
Name: ar-SA-ZariyahNeural
Gender: Female
Name: ar-SY-AmanyNeural
Gender: Female
Name: ar-SY-LaithNeural
Gender: Male
Name: ar-TN-HediNeural
Gender: Male
Name: ar-TN-ReemNeural
Gender: Female
Name: ar-YE-MaryamNeural
Gender: Female
Name: ar-YE-SalehNeural
Gender: Male
Name: az-AZ-BabekNeural
Gender: Male
Name: az-AZ-BanuNeural
Gender: Female
Name: bg-BG-BorislavNeural
Gender: Male
Name: bg-BG-KalinaNeural
Gender: Female
Name: bn-BD-NabanitaNeural
Gender: Female
Name: bn-BD-PradeepNeural
Gender: Male
Name: bn-IN-BashkarNeural
Gender: Male
Name: bn-IN-TanishaaNeural
Gender: Female
Name: bs-BA-GoranNeural
Gender: Male
Name: bs-BA-VesnaNeural
Gender: Female
Name: ca-ES-EnricNeural
Gender: Male
Name: ca-ES-JoanaNeural
Gender: Female
Name: cs-CZ-AntoninNeural
Gender: Male
Name: cs-CZ-VlastaNeural
Gender: Female
Name: cy-GB-AledNeural
Gender: Male
Name: cy-GB-NiaNeural
Gender: Female
Name: da-DK-ChristelNeural
Gender: Female
Name: da-DK-JeppeNeural
Gender: Male
Name: de-AT-IngridNeural
Gender: Female
Name: de-AT-JonasNeural
Gender: Male
Name: de-CH-JanNeural
Gender: Male
Name: de-CH-LeniNeural
Gender: Female
Name: de-DE-AmalaNeural
Gender: Female
Name: de-DE-ConradNeural
Gender: Male
Name: de-DE-FlorianMultilingualNeural
Gender: Male
Name: de-DE-KatjaNeural
Gender: Female
Name: de-DE-KillianNeural
Gender: Male
Name: de-DE-SeraphinaMultilingualNeural
Gender: Female
Name: el-GR-AthinaNeural
Gender: Female
Name: el-GR-NestorasNeural
Gender: Male
Name: en-AU-NatashaNeural
Gender: Female
Name: en-AU-WilliamNeural
Gender: Male
Name: en-CA-ClaraNeural
Gender: Female
Name: en-CA-LiamNeural
Gender: Male
Name: en-GB-LibbyNeural
Gender: Female
Name: en-GB-MaisieNeural
Gender: Female
Name: en-GB-RyanNeural
Gender: Male
Name: en-GB-SoniaNeural
Gender: Female
Name: en-GB-ThomasNeural
Gender: Male
Name: en-HK-SamNeural
Gender: Male
Name: en-HK-YanNeural
Gender: Female
Name: en-IE-ConnorNeural
Gender: Male
Name: en-IE-EmilyNeural
Gender: Female
Name: en-IN-NeerjaExpressiveNeural
Gender: Female
Name: en-IN-NeerjaNeural
Gender: Female
Name: en-IN-PrabhatNeural
Gender: Male
Name: en-KE-AsiliaNeural
Gender: Female
Name: en-KE-ChilembaNeural
Gender: Male
Name: en-NG-AbeoNeural
Gender: Male
Name: en-NG-EzinneNeural
Gender: Female
Name: en-NZ-MitchellNeural
Gender: Male
Name: en-NZ-MollyNeural
Gender: Female
Name: en-PH-JamesNeural
Gender: Male
Name: en-PH-RosaNeural
Gender: Female
Name: en-SG-LunaNeural
Gender: Female
Name: en-SG-WayneNeural
Gender: Male
Name: en-TZ-ElimuNeural
Gender: Male
Name: en-TZ-ImaniNeural
Gender: Female
Name: en-US-AnaNeural
Gender: Female
Name: en-US-AndrewNeural
Gender: Male
Name: en-US-AriaNeural
Gender: Female
Name: en-US-AvaNeural
Gender: Female
Name: en-US-BrianNeural
Gender: Male
Name: en-US-ChristopherNeural
Gender: Male
Name: en-US-EmmaNeural
Gender: Female
Name: en-US-EricNeural
Gender: Male
Name: en-US-GuyNeural
Gender: Male
Name: en-US-JennyNeural
Gender: Female
Name: en-US-MichelleNeural
Gender: Female
Name: en-US-RogerNeural
Gender: Male
Name: en-US-SteffanNeural
Gender: Male
Name: en-ZA-LeahNeural
Gender: Female
Name: en-ZA-LukeNeural
Gender: Male
Name: es-AR-ElenaNeural
Gender: Female
Name: es-AR-TomasNeural
Gender: Male
Name: es-BO-MarceloNeural
Gender: Male
Name: es-BO-SofiaNeural
Gender: Female
Name: es-CL-CatalinaNeural
Gender: Female
Name: es-CL-LorenzoNeural
Gender: Male
Name: es-CO-GonzaloNeural
Gender: Male
Name: es-CO-SalomeNeural
Gender: Female
Name: es-CR-JuanNeural
Gender: Male
Name: es-CR-MariaNeural
Gender: Female
Name: es-CU-BelkysNeural
Gender: Female
Name: es-CU-ManuelNeural
Gender: Male
Name: es-DO-EmilioNeural
Gender: Male
Name: es-DO-RamonaNeural
Gender: Female
Name: es-EC-AndreaNeural
Gender: Female
Name: es-EC-LuisNeural
Gender: Male
Name: es-ES-AlvaroNeural
Gender: Male
Name: es-ES-ElviraNeural
Gender: Female
Name: es-ES-XimenaNeural
Gender: Female
Name: es-GQ-JavierNeural
Gender: Male
Name: es-GQ-TeresaNeural
Gender: Female
Name: es-GT-AndresNeural
Gender: Male
Name: es-GT-MartaNeural
Gender: Female
Name: es-HN-CarlosNeural
Gender: Male
Name: es-HN-KarlaNeural
Gender: Female
Name: es-MX-DaliaNeural
Gender: Female
Name: es-MX-JorgeNeural
Gender: Male
Name: es-NI-FedericoNeural
Gender: Male
Name: es-NI-YolandaNeural
Gender: Female
Name: es-PA-MargaritaNeural
Gender: Female
Name: es-PA-RobertoNeural
Gender: Male
Name: es-PE-AlexNeural
Gender: Male
Name: es-PE-CamilaNeural
Gender: Female
Name: es-PR-KarinaNeural
Gender: Female
Name: es-PR-VictorNeural
Gender: Male
Name: es-PY-MarioNeural
Gender: Male
Name: es-PY-TaniaNeural
Gender: Female
Name: es-SV-LorenaNeural
Gender: Female
Name: es-SV-RodrigoNeural
Gender: Male
Name: es-US-AlonsoNeural
Gender: Male
Name: es-US-PalomaNeural
Gender: Female
Name: es-UY-MateoNeural
Gender: Male
Name: es-UY-ValentinaNeural
Gender: Female
Name: es-VE-PaolaNeural
Gender: Female
Name: es-VE-SebastianNeural
Gender: Male
Name: et-EE-AnuNeural
Gender: Female
Name: et-EE-KertNeural
Gender: Male
Name: fa-IR-DilaraNeural
Gender: Female
Name: fa-IR-FaridNeural
Gender: Male
Name: fi-FI-HarriNeural
Gender: Male
Name: fi-FI-NooraNeural
Gender: Female
Name: fil-PH-AngeloNeural
Gender: Male
Name: fil-PH-BlessicaNeural
Gender: Female
Name: fr-BE-CharlineNeural
Gender: Female
Name: fr-BE-GerardNeural
Gender: Male
Name: fr-CA-AntoineNeural
Gender: Male
Name: fr-CA-JeanNeural
Gender: Male
Name: fr-CA-SylvieNeural
Gender: Female
Name: fr-CA-ThierryNeural
Gender: Male
Name: fr-CH-ArianeNeural
Gender: Female
Name: fr-CH-FabriceNeural
Gender: Male
Name: fr-FR-DeniseNeural
Gender: Female
Name: fr-FR-EloiseNeural
Gender: Female
Name: fr-FR-HenriNeural
Gender: Male
Name: fr-FR-RemyMultilingualNeural
Gender: Male
Name: fr-FR-VivienneMultilingualNeural
Gender: Female
Name: ga-IE-ColmNeural
Gender: Male
Name: ga-IE-OrlaNeural
Gender: Female
Name: gl-ES-RoiNeural
Gender: Male
Name: gl-ES-SabelaNeural
Gender: Female
Name: gu-IN-DhwaniNeural
Gender: Female
Name: gu-IN-NiranjanNeural
Gender: Male
Name: he-IL-AvriNeural
Gender: Male
Name: he-IL-HilaNeural
Gender: Female
Name: hi-IN-MadhurNeural
Gender: Male
Name: hi-IN-SwaraNeural
Gender: Female
Name: hr-HR-GabrijelaNeural
Gender: Female
Name: hr-HR-SreckoNeural
Gender: Male
Name: hu-HU-NoemiNeural
Gender: Female
Name: hu-HU-TamasNeural
Gender: Male
Name: id-ID-ArdiNeural
Gender: Male
Name: id-ID-GadisNeural
Gender: Female
Name: is-IS-GudrunNeural
Gender: Female
Name: is-IS-GunnarNeural
Gender: Male
Name: it-IT-DiegoNeural
Gender: Male
Name: it-IT-ElsaNeural
Gender: Female
Name: it-IT-GiuseppeNeural
Gender: Male
Name: it-IT-IsabellaNeural
Gender: Female
Name: ja-JP-KeitaNeural
Gender: Male
Name: ja-JP-NanamiNeural
Gender: Female
Name: jv-ID-DimasNeural
Gender: Male
Name: jv-ID-SitiNeural
Gender: Female
Name: ka-GE-EkaNeural
Gender: Female
Name: ka-GE-GiorgiNeural
Gender: Male
Name: kk-KZ-AigulNeural
Gender: Female
Name: kk-KZ-DauletNeural
Gender: Male
Name: km-KH-PisethNeural
Gender: Male
Name: km-KH-SreymomNeural
Gender: Female
Name: kn-IN-GaganNeural
Gender: Male
Name: kn-IN-SapnaNeural
Gender: Female
Name: ko-KR-HyunsuNeural
Gender: Male
Name: ko-KR-InJoonNeural
Gender: Male
Name: ko-KR-SunHiNeural
Gender: Female
Name: lo-LA-ChanthavongNeural
Gender: Male
Name: lo-LA-KeomanyNeural
Gender: Female
Name: lt-LT-LeonasNeural
Gender: Male
Name: lt-LT-OnaNeural
Gender: Female
Name: lv-LV-EveritaNeural
Gender: Female
Name: lv-LV-NilsNeural
Gender: Male
Name: mk-MK-AleksandarNeural
Gender: Male
Name: mk-MK-MarijaNeural
Gender: Female
Name: ml-IN-MidhunNeural
Gender: Male
Name: ml-IN-SobhanaNeural
Gender: Female
Name: mn-MN-BataaNeural
Gender: Male
Name: mn-MN-YesuiNeural
Gender: Female
Name: mr-IN-AarohiNeural
Gender: Female
Name: mr-IN-ManoharNeural
Gender: Male
Name: ms-MY-OsmanNeural
Gender: Male
Name: ms-MY-YasminNeural
Gender: Female
Name: mt-MT-GraceNeural
Gender: Female
Name: mt-MT-JosephNeural
Gender: Male
Name: my-MM-NilarNeural
Gender: Female
Name: my-MM-ThihaNeural
Gender: Male
Name: nb-NO-FinnNeural
Gender: Male
Name: nb-NO-PernilleNeural
Gender: Female
Name: ne-NP-HemkalaNeural
Gender: Female
Name: ne-NP-SagarNeural
Gender: Male
Name: nl-BE-ArnaudNeural
Gender: Male
Name: nl-BE-DenaNeural
Gender: Female
Name: nl-NL-ColetteNeural
Gender: Female
Name: nl-NL-FennaNeural
Gender: Female
Name: nl-NL-MaartenNeural
Gender: Male
Name: pl-PL-MarekNeural
Gender: Male
Name: pl-PL-ZofiaNeural
Gender: Female
Name: ps-AF-GulNawazNeural
Gender: Male
Name: ps-AF-LatifaNeural
Gender: Female
Name: pt-BR-AntonioNeural
Gender: Male
Name: pt-BR-FranciscaNeural
Gender: Female
Name: pt-BR-ThalitaNeural
Gender: Female
Name: pt-PT-DuarteNeural
Gender: Male
Name: pt-PT-RaquelNeural
Gender: Female
Name: ro-RO-AlinaNeural
Gender: Female
Name: ro-RO-EmilNeural
Gender: Male
Name: ru-RU-DmitryNeural
Gender: Male
Name: ru-RU-SvetlanaNeural
Gender: Female
Name: si-LK-SameeraNeural
Gender: Male
Name: si-LK-ThiliniNeural
Gender: Female
Name: sk-SK-LukasNeural
Gender: Male
Name: sk-SK-ViktoriaNeural
Gender: Female
Name: sl-SI-PetraNeural
Gender: Female
Name: sl-SI-RokNeural
Gender: Male
Name: so-SO-MuuseNeural
Gender: Male
Name: so-SO-UbaxNeural
Gender: Female
Name: sq-AL-AnilaNeural
Gender: Female
Name: sq-AL-IlirNeural
Gender: Male
Name: sr-RS-NicholasNeural
Gender: Male
Name: sr-RS-SophieNeural
Gender: Female
Name: su-ID-JajangNeural
Gender: Male
Name: su-ID-TutiNeural
Gender: Female
Name: sv-SE-MattiasNeural
Gender: Male
Name: sv-SE-SofieNeural
Gender: Female
Name: sw-KE-RafikiNeural
Gender: Male
Name: sw-KE-ZuriNeural
Gender: Female
Name: sw-TZ-DaudiNeural
Gender: Male
Name: sw-TZ-RehemaNeural
Gender: Female
Name: ta-IN-PallaviNeural
Gender: Female
Name: ta-IN-ValluvarNeural
Gender: Male
Name: ta-LK-KumarNeural
Gender: Male
Name: ta-LK-SaranyaNeural
Gender: Female
Name: ta-MY-KaniNeural
Gender: Female
Name: ta-MY-SuryaNeural
Gender: Male
Name: ta-SG-AnbuNeural
Gender: Male
Name: ta-SG-VenbaNeural
Gender: Female
Name: te-IN-MohanNeural
Gender: Male
Name: te-IN-ShrutiNeural
Gender: Female
Name: th-TH-NiwatNeural
Gender: Male
Name: th-TH-PremwadeeNeural
Gender: Female
Name: tr-TR-AhmetNeural
Gender: Male
Name: tr-TR-EmelNeural
Gender: Female
Name: uk-UA-OstapNeural
Gender: Male
Name: uk-UA-PolinaNeural
Gender: Female
Name: ur-IN-GulNeural
Gender: Female
Name: ur-IN-SalmanNeural
Gender: Male
Name: ur-PK-AsadNeural
Gender: Male
Name: ur-PK-UzmaNeural
Gender: Female
Name: uz-UZ-MadinaNeural
Gender: Female
Name: uz-UZ-SardorNeural
Gender: Male
Name: vi-VN-HoaiMyNeural
Gender: Female
Name: vi-VN-NamMinhNeural
Gender: Male
Name: zh-CN-XiaoxiaoNeural
Gender: Female
Name: zh-CN-XiaoyiNeural
Gender: Female
Name: zh-CN-YunjianNeural
Gender: Male
Name: zh-CN-YunxiNeural
Gender: Male
Name: zh-CN-YunxiaNeural
Gender: Male
Name: zh-CN-YunyangNeural
Gender: Male
Name: zh-CN-liaoning-XiaobeiNeural
Gender: Female
Name: zh-CN-shaanxi-XiaoniNeural
Gender: Female
Name: zh-HK-HiuGaaiNeural
Gender: Female
Name: zh-HK-HiuMaanNeural
Gender: Female
Name: zh-HK-WanLungNeural
Gender: Male
Name: zh-TW-HsiaoChenNeural
Gender: Female
Name: zh-TW-HsiaoYuNeural
Gender: Female
Name: zh-TW-YunJheNeural
Gender: Male
Name: zu-ZA-ThandoNeural
Gender: Female
Name: zu-ZA-ThembaNeural
Gender: Male
2.Pexels视频搜索接口
接口文档见:https://www.pexels.com/zh-cn/api/documentation/#videos-search,详情如下:
GET https://api.pexels.com/videos/search
此端点使你可以在Pexels中搜索任意主题。例如,你的查询范围可以很宽泛,如Nature
、Tigers
、People
;也可以很具体,如Group of people working
。
参数
-
querystring | requiredThe search query.
Ocean
,Tigers
,Pears
, etc. -
orientationstring | optionalDesired video orientation. The current supported orientations are:
landscape
,portrait
orsquare
. -
sizestring | optionalMinimum video size. The current supported sizes are:
large
(4K),medium
(Full HD) orsmall
(HD). -
localestring | optionalThe locale of the search you are performing. The current supported locales are:
'en-US'
'pt-BR'
'es-ES'
'ca-ES'
'de-DE'
'it-IT'
'fr-FR'
'sv-SE'
'id-ID'
'pl-PL'
'ja-JP'
'zh-TW'
'zh-CN'
'ko-KR'
'th-TH'
'nl-NL'
'hu-HU'
'vi-VN'
'cs-CZ'
'da-DK'
'fi-FI'
'uk-UA'
'el-GR'
'ro-RO'
'nb-NO'
'sk-SK'
'tr-TR'
'ru-RU'
. -
pageinteger | optionalThe page number you are requesting.
Default: 1
-
per_pageinteger | optionalThe number of results you are requesting per page.
Default: 15
Max: 80
响应
-
videosarray ofVideoAn array of
Video
objects. -
urlstringThe Pexels URL for the current search query.
-
pageintegerThe current page number.
-
per_pageintegerThe number of results returned with each page.
-
total_resultsintegerThe total number of results for the request.
-
prev_pagestring | optionalURL for the previous page of results, if applicable.
-
next_pagestring | optionalURL for the next page of results, if applicable.
请求范例
curl -H "Authorization: <secret key>" \
"https://api.pexels.com/videos/search?query=nature&per_page=1"
响应范例
{
"page": 1,
"per_page": 1,
"total_results": 20475,
"url": "https://www.pexels.com/videos/",
"videos": [
{
"id": 1448735,
"width": 4096,
"height": 2160,
"url": "https://www.pexels.com/video/video-of-forest-1448735/",
"image": "https://images.pexels.com/videos/1448735/free-video-1448735.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb",
"duration": 32,
"user": {
"id": 574687,
"name": "Ruvim Miksanskiy",
"url": "https://www.pexels.com/@digitech"
},
"video_files": [
{
"id": 58649,
"quality": "sd",
"file_type": "video/mp4",
"width": 640,
"height": 338,
"link": "https://player.vimeo.com/external/291648067.sd.mp4?s=7f9ee1f8ec1e5376027e4a6d1d05d5738b2fbb29&profile_id=164&oauth2_token_id=57447761"
},
{
"id": 58650,
"quality": "hd",
"file_type": "video/mp4",
"width": 2048,
"height": 1080,
"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=175&oauth2_token_id=57447761"
},
{
"id": 58651,
"quality": "hd",
"file_type": "video/mp4",
"width": 4096,
"height": 2160,
"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=172&oauth2_token_id=57447761"
},
{
"id": 58652,
"quality": "hd",
"file_type": "video/mp4",
"width": 1366,
"height": 720,
"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=174&oauth2_token_id=57447761"
},
{
"id": 58653,
"quality": "hd",
"file_type": "video/mp4",
"width": 2732,
"height": 1440,
"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=170&oauth2_token_id=57447761"
},
{
"id": 58654,
"quality": "sd",
"file_type": "video/mp4",
"width": 960,
"height": 506,
"link": "https://player.vimeo.com/external/291648067.sd.mp4?s=7f9ee1f8ec1e5376027e4a6d1d05d5738b2fbb29&profile_id=165&oauth2_token_id=57447761"
},
{
"id": 58655,
"quality": "hls",
"file_type": "video/mp4",
"width": null,
"height": null,
"link": "https://player.vimeo.com/external/291648067.m3u8?s=1210fac9d80f9b74b4a334c4fca327cde08886b2&oauth2_token_id=57447761"
}
],
"video_pictures": [
{
"id": 133236,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-0.jpg",
"nr": 0
},
{
"id": 133237,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-1.jpg",
"nr": 1
},
{
"id": 133238,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-2.jpg",
"nr": 2
},
{
"id": 133239,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-3.jpg",
"nr": 3
},
{
"id": 133240,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-4.jpg",
"nr": 4
},
{
"id": 133241,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-5.jpg",
"nr": 5
},
{
"id": 133242,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-6.jpg",
"nr": 6
},
{
"id": 133243,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-7.jpg",
"nr": 7
},
{
"id": 133244,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-8.jpg",
"nr": 8
},
{
"id": 133245,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-9.jpg",
"nr": 9
},
{
"id": 133246,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-10.jpg",
"nr": 10
},
{
"id": 133247,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-11.jpg",
"nr": 11
},
{
"id": 133248,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-12.jpg",
"nr": 12
},
{
"id": 133249,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-13.jpg",
"nr": 13
},
{
"id": 133250,
"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-14.jpg",
"nr": 14
}
]
}
3.接口调用脚本
3.1.获取配乐
curl --location 'http://127.0.0.1:8080/api/v1/musics'
3.2.视频生成
curl --location 'http://127.0.0.1:8080/api/v1/videos' \
--header 'Content-Type: application/json' \
--data '{
"video_subject": "千岛湖的落日",
"video_script": "",
"video_terms": "",
"video_aspect": "16:9",
"video_concat_mode": "random",
"video_clip_duration": 5,
"video_count": 1,
"video_language": "",
"voice_name": "zh-CN-XiaoyiNeural",
"voice_volume": 1,
"bgm_type": "random",
"bgm_file": "",
"bgm_volume": 0.2,
"subtitle_enabled": true,
"subtitle_position": "bottom",
"font_name": "STHeitiMedium.ttc",
"text_fore_color": "#FFFFFF",
"text_background_color": "transparent",
"font_size": 60,
"stroke_color": "#000000",
"stroke_width": 1.5,
"n_threads": 2,
"paragraph_number": 1
}'
3.3.任务状态查询
curl --location 'http://127.0.0.1:8080/api/v1/tasks/97087c51-d01a-43fb-96b9-9eefadb8f842'
3.4.视频脚本生成
curl --location 'http://127.0.0.1:8080/api/v1/scripts' \
--header 'Content-Type: application/json' \
--data '{
"video_subject": "春天的花海",
"video_language": "",
"paragraph_number": 5
}'
3.5.视频检索关键词生成
curl --location 'http://127.0.0.1:8080/api/v1/terms' \
--header 'Content-Type: application/json' \
--data '{
"video_subject": "春天的花海",
"video_script": "春天是一年中最美丽的季节之一。当冬天的寒冷逐渐结束,春天花海的美丽将会迎接我们。在春天的花海中,我们可以看到各种各样的花朵。粉色的樱花树下,人们纷纷拿出相机,纪录下这美好的瞬间。紫色的薰衣草田中,花朵的香气弥漫在空气中,让人们感到宁静和放松。还有,五颜六色的郁金香花海,吸引着许多游客前来欣赏。除了花朵的美丽,春天的花海还有许多活动可以参与。人们可以穿上轻便的衣服,漫步在花海中,感受春天的温暖。还可以举办野餐,在花海中享受美食和阳光。还可以举办婚礼或其他仪式,选择在花海中迎接新的开始。无论是花朵的美丽还是花海中的活动,春天的花海都是一个令人愉悦和放松的地方。在这里,我们可以忘记一切烦恼,沉浸在自然的美景中。春天的花海,让我们感受到生活的美好和希望。忘记繁忙的生活,放松身心,与家人和朋友一起享受这美丽的季节吧。希望你们喜欢这个视频,也希望在未来的春天里能够亲自到花海中感受这美好的景色。谢谢观看!",
"amount": 3
}'
3.6.上传背景音乐
curl --location 'http://127.0.0.1:8080/api/v1/musics' \
--form 'file=@"/Users/abc/Music/4.mp3"'