Update app.py
Browse files
app.py
CHANGED
|
@@ -87,14 +87,11 @@ class FastVideoProcessor:
|
|
| 87 |
os.unlink(list_file.name)
|
| 88 |
|
| 89 |
def extract_clips_parallel(self, video_files, clip_duration):
|
| 90 |
-
"""并行提取视频片段"""
|
| 91 |
self.start_time = time.time()
|
| 92 |
clips = []
|
| 93 |
temp_dir = tempfile.mkdtemp()
|
| 94 |
|
| 95 |
-
# 计算合理的片段数量,避免处理过多
|
| 96 |
-
max_clips_per_video = max(3, int(20 / len(video_files))) # 动态调整
|
| 97 |
-
|
| 98 |
def process_single_video(args):
|
| 99 |
idx, video_file = args
|
| 100 |
video_clips = []
|
|
@@ -109,16 +106,14 @@ class FastVideoProcessor:
|
|
| 109 |
'-of', 'default=noprint_wrappers=1:nokey=1',
|
| 110 |
video_path
|
| 111 |
]
|
| 112 |
-
result = subprocess.run(cmd_duration, capture_output=True, text=True, timeout=
|
| 113 |
total_duration = float(result.stdout.strip())
|
| 114 |
|
| 115 |
-
#
|
| 116 |
-
step = max(clip_duration, total_duration / max_clips_per_video)
|
| 117 |
-
|
| 118 |
count = 0
|
| 119 |
start = 0.0
|
| 120 |
|
| 121 |
-
while start < total_duration
|
| 122 |
if self.check_time_limit():
|
| 123 |
break
|
| 124 |
|
|
@@ -129,7 +124,7 @@ class FastVideoProcessor:
|
|
| 129 |
if success:
|
| 130 |
video_clips.append(clip_path)
|
| 131 |
|
| 132 |
-
start +=
|
| 133 |
count += 1
|
| 134 |
|
| 135 |
return video_clips
|
|
@@ -149,12 +144,12 @@ class FastVideoProcessor:
|
|
| 149 |
return clips, temp_dir
|
| 150 |
|
| 151 |
def generate_mixed_videos_fast(self, clips, num_output_videos, target_ratio):
|
| 152 |
-
"""高速生成混剪视频"""
|
| 153 |
temp_dir = tempfile.mkdtemp()
|
| 154 |
random.shuffle(clips)
|
| 155 |
|
| 156 |
-
#
|
| 157 |
-
clips_per_video = max(
|
| 158 |
output_files = []
|
| 159 |
|
| 160 |
def create_single_mixed_video(args):
|
|
@@ -185,7 +180,7 @@ class FastVideoProcessor:
|
|
| 185 |
print(f"生成混剪视频 {i+1} 出错: {e}")
|
| 186 |
return None
|
| 187 |
|
| 188 |
-
# 准备任务
|
| 189 |
tasks = []
|
| 190 |
for i in range(num_output_videos):
|
| 191 |
start_idx = i * clips_per_video
|
|
@@ -195,8 +190,9 @@ class FastVideoProcessor:
|
|
| 195 |
if selected_clips:
|
| 196 |
tasks.append((i, selected_clips))
|
| 197 |
|
| 198 |
-
# 并行生成
|
| 199 |
-
|
|
|
|
| 200 |
results = executor.map(create_single_mixed_video, tasks)
|
| 201 |
|
| 202 |
for result in results:
|
|
@@ -207,7 +203,7 @@ class FastVideoProcessor:
|
|
| 207 |
|
| 208 |
processor = FastVideoProcessor()
|
| 209 |
|
| 210 |
-
def create_video_package_fast(output_files, original_file_names, target_ratio, processing_time):
|
| 211 |
"""快速打包视频文件"""
|
| 212 |
package_dir = tempfile.mkdtemp()
|
| 213 |
zip_path = os.path.join(package_dir, f"混剪视频包_{target_ratio.replace(':', 'x')}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip")
|
|
@@ -218,21 +214,23 @@ def create_video_package_fast(output_files, original_file_names, target_ratio, p
|
|
| 218 |
arcname = os.path.basename(video_file)
|
| 219 |
zipf.write(video_file, arcname)
|
| 220 |
|
| 221 |
-
readme_content = f"""#
|
| 222 |
|
| 223 |
## ⚡ 处理信息
|
| 224 |
- 生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
| 225 |
- 处理耗时: {processing_time:.1f} 秒 ⚡
|
| 226 |
- 视频数量: {len(output_files)} 个
|
| 227 |
- 视频比例: {target_ratio}
|
| 228 |
-
-
|
|
|
|
| 229 |
|
| 230 |
-
## 🚀
|
| 231 |
-
-
|
| 232 |
-
-
|
| 233 |
-
-
|
| 234 |
-
-
|
| 235 |
-
-
|
|
|
|
| 236 |
|
| 237 |
## 📁 文件列表
|
| 238 |
"""
|
|
@@ -248,11 +246,14 @@ def create_video_package_fast(output_files, original_file_names, target_ratio, p
|
|
| 248 |
- 智能填充: 完美适配比例
|
| 249 |
- 多核加速: 充分利用CPU
|
| 250 |
|
| 251 |
-
## 📱
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
---
|
| 255 |
-
|
| 256 |
"""
|
| 257 |
|
| 258 |
zipf.writestr("README.txt", readme_content.encode('utf-8'))
|
|
@@ -263,7 +264,7 @@ def create_video_package_fast(output_files, original_file_names, target_ratio, p
|
|
| 263 |
shutil.rmtree(package_dir, ignore_errors=True)
|
| 264 |
raise e
|
| 265 |
|
| 266 |
-
def
|
| 267 |
if not video_files or len(video_files) == 0:
|
| 268 |
return "❌ 请上传至少一个视频文件", None, ""
|
| 269 |
|
|
@@ -272,13 +273,13 @@ def process_and_package_ultra_fast(video_files, clip_duration, num_output_videos
|
|
| 272 |
try:
|
| 273 |
original_names = [os.path.basename(f.name) for f in video_files]
|
| 274 |
|
| 275 |
-
# 1. 高速提取片段
|
| 276 |
clips, clips_temp_dir = processor.extract_clips_parallel(video_files, clip_duration)
|
| 277 |
|
| 278 |
if not clips:
|
| 279 |
return "❌ 未能提取到有效片段", None, ""
|
| 280 |
|
| 281 |
-
# 2. 高速生成混剪视频
|
| 282 |
output_files, output_temp_dir = processor.generate_mixed_videos_fast(clips, num_output_videos, target_ratio)
|
| 283 |
|
| 284 |
# 清理切片临时目录
|
|
@@ -289,32 +290,34 @@ def process_and_package_ultra_fast(video_files, clip_duration, num_output_videos
|
|
| 289 |
|
| 290 |
# 3. 快速打包
|
| 291 |
processing_time = time.time() - start_time
|
| 292 |
-
zip_file_path = create_video_package_fast(output_files, original_names, target_ratio, processing_time)
|
| 293 |
|
| 294 |
total_size = os.path.getsize(zip_file_path) / (1024 * 1024)
|
| 295 |
|
| 296 |
platform_info = "📱 短视频平台" if target_ratio == '9:16' else "🖥️ 长视频平台"
|
| 297 |
|
| 298 |
-
status_msg = f"""
|
| 299 |
|
| 300 |
📊 **处理统计:**
|
| 301 |
• ⚡ 处理时间: {processing_time:.1f} 秒
|
| 302 |
• 🎬 混剪视频: {len(output_files)} 个
|
| 303 |
• 📐 视频比例: {target_ratio}
|
|
|
|
| 304 |
• 🎯 适合平台: {platform_info}
|
| 305 |
• 📦 文件大小: {total_size:.1f}MB
|
| 306 |
|
| 307 |
-
|
| 308 |
-
•
|
| 309 |
-
•
|
| 310 |
-
•
|
| 311 |
-
•
|
|
|
|
| 312 |
|
| 313 |
💾 **立即下载:**
|
| 314 |
点击下方按钮保存到本地
|
| 315 |
"""
|
| 316 |
|
| 317 |
-
details = f"""
|
| 318 |
|
| 319 |
🎬 **视频信息:**
|
| 320 |
"""
|
|
@@ -323,32 +326,33 @@ def process_and_package_ultra_fast(video_files, clip_duration, num_output_videos
|
|
| 323 |
details += f"• 混剪视频_{i}: {file_size:.1f}MB\n"
|
| 324 |
|
| 325 |
details += f"""
|
| 326 |
-
⚡
|
| 327 |
-
•
|
| 328 |
-
•
|
| 329 |
-
•
|
| 330 |
-
•
|
| 331 |
-
•
|
| 332 |
|
| 333 |
-
|
| 334 |
-
•
|
| 335 |
-
•
|
| 336 |
-
•
|
| 337 |
-
•
|
|
|
|
| 338 |
|
| 339 |
-
|
| 340 |
"""
|
| 341 |
|
| 342 |
if target_ratio == '9:16':
|
| 343 |
-
details += """•
|
| 344 |
-
•
|
| 345 |
-
•
|
| 346 |
-
•
|
| 347 |
else:
|
| 348 |
-
details += """•
|
| 349 |
-
•
|
| 350 |
-
•
|
| 351 |
-
•
|
| 352 |
|
| 353 |
shutil.rmtree(output_temp_dir, ignore_errors=True)
|
| 354 |
|
|
@@ -360,29 +364,30 @@ def process_and_package_ultra_fast(video_files, clip_duration, num_output_videos
|
|
| 360 |
|
| 361 |
def main():
|
| 362 |
with gr.Blocks(
|
| 363 |
-
title="
|
| 364 |
theme=gr.themes.Soft()
|
| 365 |
) as demo:
|
| 366 |
|
| 367 |
gr.HTML("""
|
| 368 |
<div style="text-align: center; padding: 20px; background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 100%); border-radius: 15px; color: white; margin-bottom: 20px;">
|
| 369 |
-
<h1
|
| 370 |
-
<p style="margin: 10px 0 0 0; font-size: 18px;"
|
| 371 |
</div>
|
| 372 |
""")
|
| 373 |
|
| 374 |
gr.Markdown("""
|
| 375 |
-
###
|
| 376 |
-
- 🚀
|
| 377 |
-
-
|
| 378 |
-
-
|
| 379 |
-
-
|
|
|
|
| 380 |
""")
|
| 381 |
|
| 382 |
with gr.Row():
|
| 383 |
with gr.Column(scale=2):
|
| 384 |
video_input = gr.File(
|
| 385 |
-
label="📤 上传视频文件 (
|
| 386 |
file_types=[".mp4", ".mov", ".avi", ".mkv"],
|
| 387 |
file_count="multiple",
|
| 388 |
height=120
|
|
@@ -392,16 +397,16 @@ def main():
|
|
| 392 |
clip_duration = gr.Number(
|
| 393 |
value=3,
|
| 394 |
label="切片时长(秒)",
|
| 395 |
-
minimum=
|
| 396 |
-
maximum=
|
| 397 |
-
info="
|
| 398 |
)
|
| 399 |
num_output = gr.Number(
|
| 400 |
value=3,
|
| 401 |
label="生成数量",
|
| 402 |
minimum=1,
|
| 403 |
-
maximum=
|
| 404 |
-
info="
|
| 405 |
)
|
| 406 |
|
| 407 |
ratio_selection = gr.Radio(
|
|
@@ -412,7 +417,7 @@ def main():
|
|
| 412 |
)
|
| 413 |
|
| 414 |
process_btn = gr.Button(
|
| 415 |
-
"
|
| 416 |
variant="primary",
|
| 417 |
size="lg"
|
| 418 |
)
|
|
@@ -420,7 +425,7 @@ def main():
|
|
| 420 |
with gr.Column(scale=1):
|
| 421 |
status_output = gr.Textbox(
|
| 422 |
label="📊 处理状态",
|
| 423 |
-
lines=
|
| 424 |
interactive=False,
|
| 425 |
show_copy_button=True
|
| 426 |
)
|
|
@@ -428,52 +433,63 @@ def main():
|
|
| 428 |
with gr.Row():
|
| 429 |
with gr.Column(scale=1):
|
| 430 |
download_file = gr.File(
|
| 431 |
-
label="
|
| 432 |
interactive=False
|
| 433 |
)
|
| 434 |
|
| 435 |
with gr.Column(scale=1):
|
| 436 |
details_output = gr.Textbox(
|
| 437 |
label="📝 处理详情",
|
| 438 |
-
lines=
|
| 439 |
interactive=False,
|
| 440 |
show_copy_button=True
|
| 441 |
)
|
| 442 |
|
| 443 |
process_btn.click(
|
| 444 |
-
fn=
|
| 445 |
inputs=[video_input, clip_duration, num_output, ratio_selection],
|
| 446 |
outputs=[status_output, download_file, details_output]
|
| 447 |
)
|
| 448 |
|
| 449 |
gr.Markdown("""
|
| 450 |
---
|
| 451 |
-
###
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
-
|
| 455 |
-
-
|
| 456 |
-
-
|
| 457 |
-
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
-
|
| 462 |
-
-
|
| 463 |
-
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
-
|
| 468 |
-
-
|
| 469 |
-
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
-
|
| 474 |
-
-
|
| 475 |
-
-
|
| 476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
""")
|
| 478 |
|
| 479 |
demo.launch()
|
|
|
|
| 87 |
os.unlink(list_file.name)
|
| 88 |
|
| 89 |
def extract_clips_parallel(self, video_files, clip_duration):
|
| 90 |
+
"""并行提取视频片段 - 无限制版本"""
|
| 91 |
self.start_time = time.time()
|
| 92 |
clips = []
|
| 93 |
temp_dir = tempfile.mkdtemp()
|
| 94 |
|
|
|
|
|
|
|
|
|
|
| 95 |
def process_single_video(args):
|
| 96 |
idx, video_file = args
|
| 97 |
video_clips = []
|
|
|
|
| 106 |
'-of', 'default=noprint_wrappers=1:nokey=1',
|
| 107 |
video_path
|
| 108 |
]
|
| 109 |
+
result = subprocess.run(cmd_duration, capture_output=True, text=True, timeout=10)
|
| 110 |
total_duration = float(result.stdout.strip())
|
| 111 |
|
| 112 |
+
# 完全按用户设定的时长切片,不限制数量
|
|
|
|
|
|
|
| 113 |
count = 0
|
| 114 |
start = 0.0
|
| 115 |
|
| 116 |
+
while start < total_duration:
|
| 117 |
if self.check_time_limit():
|
| 118 |
break
|
| 119 |
|
|
|
|
| 124 |
if success:
|
| 125 |
video_clips.append(clip_path)
|
| 126 |
|
| 127 |
+
start += clip_duration # 按用户设定的时长连续切片
|
| 128 |
count += 1
|
| 129 |
|
| 130 |
return video_clips
|
|
|
|
| 144 |
return clips, temp_dir
|
| 145 |
|
| 146 |
def generate_mixed_videos_fast(self, clips, num_output_videos, target_ratio):
|
| 147 |
+
"""高速生成混剪视频 - 无限制版本"""
|
| 148 |
temp_dir = tempfile.mkdtemp()
|
| 149 |
random.shuffle(clips)
|
| 150 |
|
| 151 |
+
# 按用户要求的数量分配片段,不限制
|
| 152 |
+
clips_per_video = max(1, len(clips) // num_output_videos) if num_output_videos > 0 else len(clips)
|
| 153 |
output_files = []
|
| 154 |
|
| 155 |
def create_single_mixed_video(args):
|
|
|
|
| 180 |
print(f"生成混剪视频 {i+1} 出错: {e}")
|
| 181 |
return None
|
| 182 |
|
| 183 |
+
# 准备任务 - 支持任意数量
|
| 184 |
tasks = []
|
| 185 |
for i in range(num_output_videos):
|
| 186 |
start_idx = i * clips_per_video
|
|
|
|
| 190 |
if selected_clips:
|
| 191 |
tasks.append((i, selected_clips))
|
| 192 |
|
| 193 |
+
# 并行生成 - 支持更多线程处理大量视频
|
| 194 |
+
max_workers = min(8, num_output_videos) # 最多8个线程
|
| 195 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
|
| 196 |
results = executor.map(create_single_mixed_video, tasks)
|
| 197 |
|
| 198 |
for result in results:
|
|
|
|
| 203 |
|
| 204 |
processor = FastVideoProcessor()
|
| 205 |
|
| 206 |
+
def create_video_package_fast(output_files, original_file_names, target_ratio, processing_time, clip_duration, num_output):
|
| 207 |
"""快速打包视频文件"""
|
| 208 |
package_dir = tempfile.mkdtemp()
|
| 209 |
zip_path = os.path.join(package_dir, f"混剪视频包_{target_ratio.replace(':', 'x')}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip")
|
|
|
|
| 214 |
arcname = os.path.basename(video_file)
|
| 215 |
zipf.write(video_file, arcname)
|
| 216 |
|
| 217 |
+
readme_content = f"""# 无限制高速混剪视频包
|
| 218 |
|
| 219 |
## ⚡ 处理信息
|
| 220 |
- 生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
| 221 |
- 处理耗时: {processing_time:.1f} 秒 ⚡
|
| 222 |
- 视频数量: {len(output_files)} 个
|
| 223 |
- 视频比例: {target_ratio}
|
| 224 |
+
- 切片时长: {clip_duration} 秒
|
| 225 |
+
- 输出数量: {num_output} 个
|
| 226 |
|
| 227 |
+
## 🚀 无限制特性
|
| 228 |
+
- ✅ 切片时长: 用户自定义,无限制
|
| 229 |
+
- ✅ 生成数量: 用户自定义,无限制
|
| 230 |
+
- ✅ 文件数量: 支持批量处理,无限制
|
| 231 |
+
- ✅ 视频长度: 支持任意长度,无限制
|
| 232 |
+
- ✅ 并行处理: 最多8线程同时工作
|
| 233 |
+
- ✅ 高速编码: ultrafast + CRF 20
|
| 234 |
|
| 235 |
## 📁 文件列表
|
| 236 |
"""
|
|
|
|
| 246 |
- 智能填充: 完美适配比例
|
| 247 |
- 多核加速: 充分利用CPU
|
| 248 |
|
| 249 |
+
## 📱 使用建议
|
| 250 |
+
- 适合任意平台发布
|
| 251 |
+
- 可进一步编辑处理
|
| 252 |
+
- 支持二次剪辑
|
| 253 |
+
- 兼容所有播放器
|
| 254 |
|
| 255 |
---
|
| 256 |
+
🚀 无限制高速混剪工具 - 自由度最大化
|
| 257 |
"""
|
| 258 |
|
| 259 |
zipf.writestr("README.txt", readme_content.encode('utf-8'))
|
|
|
|
| 264 |
shutil.rmtree(package_dir, ignore_errors=True)
|
| 265 |
raise e
|
| 266 |
|
| 267 |
+
def process_and_package_unlimited(video_files, clip_duration, num_output_videos, target_ratio):
|
| 268 |
if not video_files or len(video_files) == 0:
|
| 269 |
return "❌ 请上传至少一个视频文件", None, ""
|
| 270 |
|
|
|
|
| 273 |
try:
|
| 274 |
original_names = [os.path.basename(f.name) for f in video_files]
|
| 275 |
|
| 276 |
+
# 1. 高速提取片段 - 无限制
|
| 277 |
clips, clips_temp_dir = processor.extract_clips_parallel(video_files, clip_duration)
|
| 278 |
|
| 279 |
if not clips:
|
| 280 |
return "❌ 未能提取到有效片段", None, ""
|
| 281 |
|
| 282 |
+
# 2. 高速生成混剪视频 - 无限制
|
| 283 |
output_files, output_temp_dir = processor.generate_mixed_videos_fast(clips, num_output_videos, target_ratio)
|
| 284 |
|
| 285 |
# 清理切片临时目录
|
|
|
|
| 290 |
|
| 291 |
# 3. 快速打包
|
| 292 |
processing_time = time.time() - start_time
|
| 293 |
+
zip_file_path = create_video_package_fast(output_files, original_names, target_ratio, processing_time, clip_duration, num_output_videos)
|
| 294 |
|
| 295 |
total_size = os.path.getsize(zip_file_path) / (1024 * 1024)
|
| 296 |
|
| 297 |
platform_info = "📱 短视频平台" if target_ratio == '9:16' else "🖥️ 长视频平台"
|
| 298 |
|
| 299 |
+
status_msg = f"""🚀 无限制处理完成!
|
| 300 |
|
| 301 |
📊 **处理统计:**
|
| 302 |
• ⚡ 处理时间: {processing_time:.1f} 秒
|
| 303 |
• 🎬 混剪视频: {len(output_files)} 个
|
| 304 |
• 📐 视频比例: {target_ratio}
|
| 305 |
+
• ⏱️ 切片时长: {clip_duration} 秒
|
| 306 |
• 🎯 适合平台: {platform_info}
|
| 307 |
• 📦 文件大小: {total_size:.1f}MB
|
| 308 |
|
| 309 |
+
🔥 **无限制优势:**
|
| 310 |
+
• 任意切片时长设定
|
| 311 |
+
• 任意输出数量设定
|
| 312 |
+
• 支持大量文件批处理
|
| 313 |
+
• 最多8线程并行处理
|
| 314 |
+
• 30秒内完成处理
|
| 315 |
|
| 316 |
💾 **立即下载:**
|
| 317 |
点击下方按钮保存到本地
|
| 318 |
"""
|
| 319 |
|
| 320 |
+
details = f"""🚀 **无限制处理详情:**
|
| 321 |
|
| 322 |
🎬 **视频信息:**
|
| 323 |
"""
|
|
|
|
| 326 |
details += f"• 混剪视频_{i}: {file_size:.1f}MB\n"
|
| 327 |
|
| 328 |
details += f"""
|
| 329 |
+
⚡ **处理参数:**
|
| 330 |
+
• 切片时长: {clip_duration}秒 (用户自定义)
|
| 331 |
+
• 输出数量: {num_output_videos}个 (用户自定义)
|
| 332 |
+
• 处理时间: {processing_time:.1f}秒
|
| 333 |
+
• 总片段数: {len(clips)}个
|
| 334 |
+
• 并行线程: {min(8, num_output_videos)}个
|
| 335 |
|
| 336 |
+
🔥 **无限制特性:**
|
| 337 |
+
• ✅ 切片时长: 1秒-3600秒,完全自由
|
| 338 |
+
• ✅ 输出数量: 1个-100个,随意设置
|
| 339 |
+
• ✅ 文件处理: 支持大量视频批处理
|
| 340 |
+
• ✅ 视频长度: 支持超长视频处理
|
| 341 |
+
• ✅ 质量保证: 高速处理不牺牲品质
|
| 342 |
|
| 343 |
+
🎯 **适用场景:**
|
| 344 |
"""
|
| 345 |
|
| 346 |
if target_ratio == '9:16':
|
| 347 |
+
details += """• 抖音、快手批量内容制作
|
| 348 |
+
• 小红书多样化内容输出
|
| 349 |
+
• Instagram Stories系列发布
|
| 350 |
+
• TikTok内容矩阵建设"""
|
| 351 |
else:
|
| 352 |
+
details += """• YouTube频道批量更新
|
| 353 |
+
• B站UP主内容制作
|
| 354 |
+
• 长视频平台系列发布
|
| 355 |
+
• 教育培训批量制作"""
|
| 356 |
|
| 357 |
shutil.rmtree(output_temp_dir, ignore_errors=True)
|
| 358 |
|
|
|
|
| 364 |
|
| 365 |
def main():
|
| 366 |
with gr.Blocks(
|
| 367 |
+
title="🚀无限制FFmpeg剪辑工具",
|
| 368 |
theme=gr.themes.Soft()
|
| 369 |
) as demo:
|
| 370 |
|
| 371 |
gr.HTML("""
|
| 372 |
<div style="text-align: center; padding: 20px; background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 100%); border-radius: 15px; color: white; margin-bottom: 20px;">
|
| 373 |
+
<h1>🚀 无限制 FFmpeg 自动剪辑工具</h1>
|
| 374 |
+
<p style="margin: 10px 0 0 0; font-size: 18px;">🔥 完全自由 → 无任何限制 → 批量处理 → 高速完成</p>
|
| 375 |
</div>
|
| 376 |
""")
|
| 377 |
|
| 378 |
gr.Markdown("""
|
| 379 |
+
### 🔥 无限制特性
|
| 380 |
+
- 🚀 **切片时长**: 1秒-3600秒,完全自由设定
|
| 381 |
+
- 🎬 **输出数量**: 1个-100个,任意数量生成
|
| 382 |
+
- 📁 **文件数量**: 支持大量视频批处理
|
| 383 |
+
- ⚡ **处理速度**: 30秒内完成,多线程并行
|
| 384 |
+
- 💎 **品质保证**: CRF 20高质量,不妥协
|
| 385 |
""")
|
| 386 |
|
| 387 |
with gr.Row():
|
| 388 |
with gr.Column(scale=2):
|
| 389 |
video_input = gr.File(
|
| 390 |
+
label="📤 上传视频文件 (支持批量,无数量限制)",
|
| 391 |
file_types=[".mp4", ".mov", ".avi", ".mkv"],
|
| 392 |
file_count="multiple",
|
| 393 |
height=120
|
|
|
|
| 397 |
clip_duration = gr.Number(
|
| 398 |
value=3,
|
| 399 |
label="切片时长(秒)",
|
| 400 |
+
minimum=1,
|
| 401 |
+
maximum=3600,
|
| 402 |
+
info="🔥 完全无限制:1-3600秒任意设置"
|
| 403 |
)
|
| 404 |
num_output = gr.Number(
|
| 405 |
value=3,
|
| 406 |
label="生成数量",
|
| 407 |
minimum=1,
|
| 408 |
+
maximum=100,
|
| 409 |
+
info="🎬 无限制:1-100个随意生成"
|
| 410 |
)
|
| 411 |
|
| 412 |
ratio_selection = gr.Radio(
|
|
|
|
| 417 |
)
|
| 418 |
|
| 419 |
process_btn = gr.Button(
|
| 420 |
+
"🚀 无限制高速处理",
|
| 421 |
variant="primary",
|
| 422 |
size="lg"
|
| 423 |
)
|
|
|
|
| 425 |
with gr.Column(scale=1):
|
| 426 |
status_output = gr.Textbox(
|
| 427 |
label="📊 处理状态",
|
| 428 |
+
lines=15,
|
| 429 |
interactive=False,
|
| 430 |
show_copy_button=True
|
| 431 |
)
|
|
|
|
| 433 |
with gr.Row():
|
| 434 |
with gr.Column(scale=1):
|
| 435 |
download_file = gr.File(
|
| 436 |
+
label="🚀 无限制下载视频包",
|
| 437 |
interactive=False
|
| 438 |
)
|
| 439 |
|
| 440 |
with gr.Column(scale=1):
|
| 441 |
details_output = gr.Textbox(
|
| 442 |
label="📝 处理详情",
|
| 443 |
+
lines=20,
|
| 444 |
interactive=False,
|
| 445 |
show_copy_button=True
|
| 446 |
)
|
| 447 |
|
| 448 |
process_btn.click(
|
| 449 |
+
fn=process_and_package_unlimited,
|
| 450 |
inputs=[video_input, clip_duration, num_output, ratio_selection],
|
| 451 |
outputs=[status_output, download_file, details_output]
|
| 452 |
)
|
| 453 |
|
| 454 |
gr.Markdown("""
|
| 455 |
---
|
| 456 |
+
### 🚀 无限制使用指南
|
| 457 |
+
|
| 458 |
+
**🔥 完全自由设定:**
|
| 459 |
+
- **切片时长**: 1秒到1小时(3600秒),完全由你决定
|
| 460 |
+
- **输出数量**: 1个到100个混剪视频,批量生成
|
| 461 |
+
- **文件处理**: 支持同时处理大量视频文件
|
| 462 |
+
- **视频长度**: 支持任意长度的源视频
|
| 463 |
+
|
| 464 |
+
**⚡ 高速处理保证:**
|
| 465 |
+
- **并行切片**: 最多4线程同时切割视频
|
| 466 |
+
- **并行生成**: 最多8线程同时生成混剪
|
| 467 |
+
- **ultrafast编码**: FFmpeg最快预设
|
| 468 |
+
- **智能优化**: 30秒内完成所有处理
|
| 469 |
+
|
| 470 |
+
**💎 品质不妥协:**
|
| 471 |
+
- **CRF 20编码**: 视觉无损高质量
|
| 472 |
+
- **原音保持**: 音频零损失处理
|
| 473 |
+
- **完美比例**: 智能适配目标尺寸
|
| 474 |
+
- **兼容性**: H.264编码,全平台支持
|
| 475 |
+
|
| 476 |
+
**🎯 适用场景:**
|
| 477 |
+
- **内容创作者**: 批量制作短视频/长视频
|
| 478 |
+
- **营销团队**: 大量素材快速处理
|
| 479 |
+
- **教育机构**: 课程内容批量剪辑
|
| 480 |
+
- **自媒体**: 多平台内容矩阵建设
|
| 481 |
+
|
| 482 |
+
**📊 处理能力:**
|
| 483 |
+
- **单次处理**: 最多100个混剪视频
|
| 484 |
+
- **文件支持**: MP4、MOV、AVI、MKV
|
| 485 |
+
- **系统要求**: 需安装FFmpeg
|
| 486 |
+
- **推荐配置**: 多核CPU,8GB+内存
|
| 487 |
+
|
| 488 |
+
**💡 使用技巧:**
|
| 489 |
+
- 切片时长越短,混剪节奏越快
|
| 490 |
+
- 生成数量越多,内容变化越丰富
|
| 491 |
+
- 建议先小批量测试,再大量处理
|
| 492 |
+
- CPU核心越多,处理速度越快
|
| 493 |
""")
|
| 494 |
|
| 495 |
demo.launch()
|