AI视频剪辑
一个基于人工智能的自动视频剪辑系统,能够自动分析视频内容并根据用户需求生成编辑后的视频。
git clone https://github.com/LumingMelody/Ai-movie-clip.git
cd Ai-movie-clippip install -r requirements.txt复制环境变量模板并填写您的配置:
cp .env.example .env编辑 .env 文件,填入您的API密钥:
# AI Model API Keys
DASHSCOPE_API_KEY=your_dashscope_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
# OSS Configuration (Alibaba Cloud)
OSS_ACCESS_KEY_ID=your_oss_access_key_id_here
OSS_ACCESS_KEY_SECRET=your_oss_access_key_secret_here
OSS_BUCKET_NAME=your_bucket_name_here本系统集成了 Coze 数字人和图片插入功能,为视频制作提供更丰富的素材和效果。
使用 Coze 相关功能需要:
搭建 Coze Workflow
下载素材包
resources/ 目录下环境配置
# 添加到 .env 文件
COZE_API_KEY=your_coze_api_key_here
COZE_WORKFLOW_ID=your_workflow_id_here# 使用数字人功能
from core.cliptemplate.coze.video_digital_human_easy import VideoDigitalHumanEasy
# 生成数字人视频
digital_human = VideoDigitalHumanEasy()
result = digital_human.generate_video(
text="你好,欢迎使用AI视频剪辑系统",
avatar_id="your_avatar_id"
)
# 使用图片插入功能
from core.cliptemplate.coze.video_dgh_img_insert import VideoDghImgInsert
# 插入图片到视频
img_inserter = VideoDghImgInsert()
result = img_inserter.insert_image(
video_path="path/to/video.mp4",
image_path="path/to/image.jpg",
position="center"
)# 分析视频
python main.py analyze video.mp4 --output analysis.json
# 自动剪辑视频
python main.py edit video.mp4 --duration 30 --style "抖音风"
# 查看更多选项
python main.py --help# 启动FastAPI服务器
python app.py
# 或
uvicorn app:app --reload
# 访问API文档
# http://localhost:8000/docsimport requests
# 分析视频
response = requests.post(
"http://localhost:8000/analyze",
files={"file": open("video.mp4", "rb")},
data={"duration": 30}
)
# 生成编辑视频
response = requests.post(
"http://localhost:8000/edit",
json={
"video_path": "path/to/video.mp4",
"template": "douyin",
"duration": 30
}
)Ai-movie-clip/
├── core/ # 核心功能模块
│ ├── orchestrator/ # 工作流编排
│ ├── analyzer/ # 视频分析
│ ├── ai/ # AI模型集成
│ ├── clipeffects/ # 视频特效
│ ├── cliptransition/ # 转场效果
│ ├── clipgenerate/ # AI内容生成
│ └── cliptemplate/ # 视频模板
├── templates/ # Jinja2模板文件
├── config/ # 配置文件
├── main.py # CLI入口
├── app.py # API服务器
└── requirements.txt # 依赖列表在 templates/ 目录下创建新的模板文件:
# templates/custom/my_template.j2
产品名称:{{ product_name }}
特点:{{ features }}
价格:{{ price }}在 core/ai/ai_model_caller.py 中添加新的模型:
def call_custom_model(prompt):
# 实现您的模型调用逻辑
passA: 系统会自动进行分片处理,您可以在配置中调整分片大小。
A: 支持 MP4、AVI、MOV、MKV 等常见格式。
A: 使用GPU加速,或调整 config.yaml 中的并发设置。
欢迎贡献代码!请遵循以下步骤:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
No open issues yet, or sync has not completed.