Skip to content

Commit bb0b404

Browse files
committed
Major refactoring
1 parent 4930c77 commit bb0b404

File tree

9 files changed

+765
-233
lines changed

9 files changed

+765
-233
lines changed

README.md

Lines changed: 67 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,88 @@
1-
# Videogen - AI视频生成工具
1+
# Videogen - AI Video Generation Tool
22

33
![Videogen](assets/creation-light.svg)
44

5-
Videogen是一个基于多种AI模型的视频生成工具,支持火山引擎、阿里云百炼和智谱AI三大平台,可以通过文本提示词或图片+文本组合生成高质量视频。
5+
*English | [中文](README_zh.md)*
66

7-
## 功能特点
7+
Videogen is a video generation tool based on multiple AI models, supporting three major platforms: Volcengine, Aliyun Bailian, and Zhipu AI. It can generate high-quality videos through text prompts or a combination of images and text.
88

9-
- **多平台支持**
10-
- 火山引擎视频生成
11-
- 阿里云百炼通义万相系列模型
12-
- 智谱AI的CogVideoX模型系列
13-
- **多种生成模式**
14-
- 文生视频:仅通过文本描述生成视频
15-
- 图生视频:通过图片和文本联合生成视频
16-
- **高度定制化**
17-
- 支持设置宽高比、分辨率、时长、帧率等参数
18-
- 支持AI音效生成(智谱AI)
19-
- **便捷文件管理**
20-
- 集成Tebi.io云存储服务,自动上传和管理图片素材
9+
## Features
2110

22-
## 环境变量配置
11+
- **Multi-platform Support**:
12+
- Volcengine video generation
13+
- Aliyun Bailian Tongyi Wanxiang series models
14+
- Zhipu AI's CogVideoX model series
15+
- **Multiple Generation Modes**:
16+
- Text-to-video: Generate videos through text descriptions only
17+
- Image-to-video: Generate videos through a combination of images and text
18+
- **Highly Customizable**:
19+
- Set aspect ratio, resolution, duration, frame rate, and other parameters
20+
- Support for AI sound effect generation (Zhipu AI)
21+
- **Convenient File Management**:
22+
- Integrated with Tebi.io cloud storage service for automatic upload and management of image materials
23+
- **Multilingual Support**:
24+
- English and Chinese interface
25+
- Auto-detects system language
26+
- Easily switch languages within the interface
2327

24-
使用本项目需要配置以下环境变量:
28+
## Environment Variables
29+
30+
The following environment variables need to be configured to use this project:
2531

2632
```bash
27-
# 火山引擎配置
28-
ARK_API_KEY=your_ark_api_key # 火山引擎的API KEY
29-
ARK_ENDPOINT=your_ark_endpoint # 火山引擎的推理接入点
33+
# Volcengine Configuration
34+
ARK_API_KEY=your_ark_api_key # Volcengine API KEY
35+
ARK_ENDPOINT=your_ark_endpoint # Volcengine inference endpoint
3036

31-
# 阿里云百炼配置
32-
DASHSCOPE_API_KEY=your_dashscope_api_key # 阿里云百炼的API KEY
37+
# Aliyun Bailian Configuration
38+
DASHSCOPE_API_KEY=your_dashscope_api_key # Aliyun Bailian API KEY
3339

34-
# 智谱AI配置
35-
ZHIPUAI_API_KEY=your_zhipuai_api_key # 智谱AI的API KEY
40+
# Zhipu AI Configuration
41+
ZHIPUAI_API_KEY=your_zhipuai_api_key # Zhipu AI API KEY
3642

37-
# Tebi.io云存储配置
38-
TEBI_ACCESS_KEY=your_tebi_access_key # Tebi.io的ACCESS KEY
39-
TEBI_SECRET_KEY=your_tebi_secret_key # Tebi.io的SECRET KEY
43+
# Tebi.io Cloud Storage Configuration
44+
TEBI_ACCESS_KEY=your_tebi_access_key # Tebi.io ACCESS KEY
45+
TEBI_SECRET_KEY=your_tebi_secret_key # Tebi.io SECRET KEY
4046
```
4147

42-
## 安装说明
48+
## Installation
4349

44-
1. 克隆仓库:
50+
1. Clone the repository:
4551

4652
```bash
4753
git clone https://github.com/yourusername/videogen.git
4854
cd videogen
4955
```
5056

51-
2. 安装依赖:
57+
2. Install dependencies:
5258

5359
```bash
5460
pip install -r requirements.txt
5561
```
5662

57-
3. 设置环境变量(可使用.env文件或系统环境变量)
63+
3. Set environment variables (using .env file or system environment variables)
5864

59-
4. 启动应用:
65+
4. Start the application:
6066

6167
```bash
6268
python main.py
6369
```
6470

65-
## 使用方法
71+
## Usage
6672

67-
1. 在浏览器中访问 `http://localhost:7860`(默认端口)
68-
2. 选择目标AI平台(火山引擎/阿里云百炼/智谱AI)
69-
3. 输入详细的提示词描述您想要生成的视频内容
70-
4. 如果需要图生视频,请上传参考图片
71-
5. 根据您选择的平台,设置合适的参数(宽高比、分辨率、时长等)
72-
6. 点击"生成视频"按钮,等待生成完成
73-
7. 生成完成后,可以直接在界面中预览或下载视频
73+
1. Access `http://localhost:7860` in your browser (default port)
74+
2. Select the target AI platform (Volcengine/Aliyun Bailian/Zhipu AI)
75+
3. Enter detailed prompt describing the video content you want to generate
76+
4. If you need image-to-video generation, upload a reference image
77+
5. Set appropriate parameters based on your chosen platform (aspect ratio, resolution, duration, etc.)
78+
6. Click the "Generate Video" button and wait for generation to complete
79+
7. Once generation is complete, you can preview or download the video directly from the interface
7480

75-
## Docker部署
81+
## Docker Deployment
7682

77-
### 使用预构建镜像(推荐)
83+
### Using Pre-built Image (Recommended)
7884

79-
我们提供了预构建的Docker镜像,支持arm64和amd64平台,可以直接使用:
85+
We provide pre-built Docker images supporting arm64 and amd64 platforms:
8086

8187
```bash
8288
docker run -p 7860:7860 \
@@ -89,9 +95,9 @@ docker run -p 7860:7860 \
8995
arnocher/videogen
9096
```
9197

92-
### 自行构建镜像
98+
### Build Your Own Image
9399

94-
也可以自行构建镜像:
100+
You can also build the image yourself:
95101

96102
```bash
97103
docker build -t videogen .
@@ -105,17 +111,26 @@ docker run -p 7860:7860 \
105111
videogen
106112
```
107113

108-
## 注意事项
114+
## Notes
115+
116+
- Make sure you have all required API keys and access permissions
117+
- Uploaded images must comply with the requirements of each platform (recommended resolution ≥300px, aspect ratio between 0.4-2.5)
118+
- Generated video content should comply with relevant laws, regulations, and platform policies
119+
- If the Tebi.io configuration is missing, image-to-video features will be disabled
120+
- The application requires translation files in the i18n directory to run
121+
122+
## Internationalization
109123

110-
- 请确保您拥有所有必需的API密钥和访问权限
111-
- 上传的图片需符合各平台的要求(建议分辨率≥300px,宽高比在0.4-2.5之间)
112-
- 生成的视频内容应遵守相关法律法规和平台政策
124+
The application supports multiple languages through the i18n system:
125+
- Translation files are stored in the `i18n` directory as JSON files
126+
- Currently supported languages: English (`en.json`) and Chinese (`zh.json`)
127+
- To add a new language, create a new JSON file in the i18n directory following the same format
113128

114-
## 鸣谢
129+
## Acknowledgements
115130

116-
本项目使用了以下开源库和API服务:
131+
This project uses the following open-source libraries and API services:
117132
- Gradio
118133
- Volcengine SDK
119134
- DashScope SDK
120135
- ZhipuAI SDK
121-
- Boto3 (用于S3兼容存储)
136+
- Boto3 (for S3-compatible storage)

README_zh.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Videogen - AI视频生成工具
2+
3+
![Videogen](assets/creation-light.svg)
4+
5+
*[English](README.md) | 中文*
6+
7+
Videogen是一个基于多种AI模型的视频生成工具,支持火山引擎、阿里云百炼和智谱AI三大平台,可以通过文本提示词或图片+文本组合生成高质量视频。
8+
9+
## 功能特点
10+
11+
- **多平台支持**
12+
- 火山引擎视频生成
13+
- 阿里云百炼通义万相系列模型
14+
- 智谱AI的CogVideoX模型系列
15+
- **多种生成模式**
16+
- 文生视频:仅通过文本描述生成视频
17+
- 图生视频:通过图片和文本联合生成视频
18+
- **高度定制化**
19+
- 支持设置宽高比、分辨率、时长、帧率等参数
20+
- 支持AI音效生成(智谱AI)
21+
- **便捷文件管理**
22+
- 集成Tebi.io云存储服务,自动上传和管理图片素材
23+
- **多语言支持**
24+
- 支持中英文双语界面
25+
- 自动检测系统语言并设置默认语言
26+
- 界面内轻松切换语言
27+
28+
## 环境变量配置
29+
30+
使用本项目需要配置以下环境变量:
31+
32+
```bash
33+
# 火山引擎配置
34+
ARK_API_KEY=your_ark_api_key # 火山引擎的API KEY
35+
ARK_ENDPOINT=your_ark_endpoint # 火山引擎的推理接入点
36+
37+
# 阿里云百炼配置
38+
DASHSCOPE_API_KEY=your_dashscope_api_key # 阿里云百炼的API KEY
39+
40+
# 智谱AI配置
41+
ZHIPUAI_API_KEY=your_zhipuai_api_key # 智谱AI的API KEY
42+
43+
# Tebi.io云存储配置
44+
TEBI_ACCESS_KEY=your_tebi_access_key # Tebi.io的ACCESS KEY
45+
TEBI_SECRET_KEY=your_tebi_secret_key # Tebi.io的SECRET KEY
46+
```
47+
48+
## 安装说明
49+
50+
1. 克隆仓库:
51+
52+
```bash
53+
git clone https://github.com/yourusername/videogen.git
54+
cd videogen
55+
```
56+
57+
2. 安装依赖:
58+
59+
```bash
60+
pip install -r requirements.txt
61+
```
62+
63+
3. 设置环境变量(可使用.env文件或系统环境变量)
64+
65+
4. 启动应用:
66+
67+
```bash
68+
python main.py
69+
```
70+
71+
## 使用方法
72+
73+
1. 在浏览器中访问 `http://localhost:7860`(默认端口)
74+
2. 选择目标AI平台(火山引擎/阿里云百炼/智谱AI)
75+
3. 输入详细的提示词描述您想要生成的视频内容
76+
4. 如果需要图生视频,请上传参考图片
77+
5. 根据您选择的平台,设置合适的参数(宽高比、分辨率、时长等)
78+
6. 点击"生成视频"按钮,等待生成完成
79+
7. 生成完成后,可以直接在界面中预览或下载视频
80+
81+
## Docker部署
82+
83+
### 使用预构建镜像(推荐)
84+
85+
我们提供了预构建的Docker镜像,支持arm64和amd64平台,可以直接使用:
86+
87+
```bash
88+
docker run -p 7860:7860 \
89+
-e ARK_API_KEY=your_ark_api_key \
90+
-e ARK_ENDPOINT=your_ark_endpoint \
91+
-e DASHSCOPE_API_KEY=your_dashscope_api_key \
92+
-e ZHIPUAI_API_KEY=your_zhipuai_api_key \
93+
-e TEBI_ACCESS_KEY=your_tebi_access_key \
94+
-e TEBI_SECRET_KEY=your_tebi_secret_key \
95+
arnocher/videogen
96+
```
97+
98+
### 自行构建镜像
99+
100+
也可以自行构建镜像:
101+
102+
```bash
103+
docker build -t videogen .
104+
docker run -p 7860:7860 \
105+
-e ARK_API_KEY=your_ark_api_key \
106+
-e ARK_ENDPOINT=your_ark_endpoint \
107+
-e DASHSCOPE_API_KEY=your_dashscope_api_key \
108+
-e ZHIPUAI_API_KEY=your_zhipuai_api_key \
109+
-e TEBI_ACCESS_KEY=your_tebi_access_key \
110+
-e TEBI_SECRET_KEY=your_tebi_secret_key \
111+
videogen
112+
```
113+
114+
## 注意事项
115+
116+
- 请确保您拥有所有必需的API密钥和访问权限
117+
- 上传的图片需符合各平台的要求(建议分辨率≥300px,宽高比在0.4-2.5之间)
118+
- 生成的视频内容应遵守相关法律法规和平台政策
119+
- 如果缺少Tebi.io配置,图生视频功能将被禁用
120+
- 应用程序需要i18n目录中的翻译文件才能运行
121+
122+
## 国际化支持
123+
124+
应用程序通过i18n系统支持多种语言:
125+
- 翻译文件以JSON格式存储在`i18n`目录中
126+
- 当前支持的语言:中文(`zh.json`)和英文(`en.json`
127+
- 要添加新语言,只需在i18n目录中按照相同的格式创建新的JSON文件
128+
129+
## 鸣谢
130+
131+
本项目使用了以下开源库和API服务:
132+
- Gradio
133+
- Volcengine SDK
134+
- DashScope SDK
135+
- ZhipuAI SDK
136+
- Boto3 (用于S3兼容存储)

api/ark.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,58 @@
11
import os
22
import re
33
import time
4+
import logging
45

56
from volcenginesdkarkruntime import Ark
67

7-
# 初始化火山引擎客户端
8-
volc_client = Ark()
8+
# Set up logging
9+
logging.basicConfig(level=logging.WARNING)
10+
logger = logging.getLogger(__name__)
11+
12+
# Initialize Volcengine client and check environment variables
13+
volc_client = None
14+
try:
15+
api_key = os.getenv('ARK_API_KEY')
16+
endpoint = os.getenv('ARK_ENDPOINT')
17+
if api_key and endpoint:
18+
volc_client = Ark()
19+
except Exception as e:
20+
logger.error(f"Failed to initialize Volcengine client: {str(e)}")
921

1022

1123
def generate_volcengine(prompt, image_url=None, ratio="16:9", duration=5):
24+
# If client initialization failed, return error
25+
if not volc_client:
26+
return None, "Volcengine API not configured or initialization failed"
27+
1228
content = [{"type": "text", "text": f"{prompt} --ratio {ratio} --dur {str(duration)}"}]
1329
if image_url:
1430
content.append({"type": "image_url", "image_url": {"url": image_url}})
1531

1632
try:
17-
# 创建任务,传入额外参数
33+
# Create task with additional parameters
1834
create_result = volc_client.content_generation.tasks.create(
1935
model=os.getenv('ARK_ENDPOINT'),
2036
content=content
2137
)
22-
print(f"任务创建成功: {create_result.id}")
38+
logger.info(f"Task created successfully: {create_result.id}")
2339

24-
# 轮询任务状态
40+
# Poll task status
2541
while True:
2642
get_result = volc_client.content_generation.tasks.get(task_id=create_result.id)
27-
print(f"任务状态: {get_result.status}")
43+
logger.info(f"Task status: {get_result.status}")
2844
if get_result.status in ["succeeded", "failed"]:
2945
break
3046
time.sleep(2)
3147

32-
# 提取 video_url
48+
# Extract video_url
3349
if get_result.status == "succeeded":
3450
content_str = str(get_result.content)
3551
video_url_match = re.search(r"video_url='(.*?)'", content_str)
3652
if video_url_match:
37-
return video_url_match.group(1), "任务完成"
38-
return None, "任务成功但未找到视频 URL"
53+
return video_url_match.group(1), "Task completed"
54+
return None, "Task successful but video URL not found"
3955
else:
40-
return None, f"任务失败: {get_result.status}"
56+
return None, f"Task failed: {get_result.status}"
4157
except Exception as e:
42-
return None, f"火山引擎生成失败: {str(e)}"
58+
return None, f"Volcengine generation failed: {str(e)}"

0 commit comments

Comments
 (0)