Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Auto Video Highlight | 自动视频高光剪辑

中文 | English

从长视频中自动抽取高光片段:抽帧 → 逐秒活动强度分析 → 5 秒窗口选段 → 自动倒算剪辑比例 Y → 产出高光集锦。 Python 后端工作流库(vedit)+ WPF(.NET 8)前端面板。


功能特性

  • 逐秒活动强度:ffmpeg 抽灰度帧,计算相邻帧平均像素差作为活动强度
  • 5 秒窗口算法:窗口内平均活动强度 > 整体均值 × Y 即保留,相邻保留秒自动合并为片段
  • 自动倒算 Y:求最小 Y(步长 0.05)使总时长 ≤ 30 分钟;仅作参考值,可手动修改并实时预览结果时长
  • WPF 面板:视频拖放、产品文件夹选择、进度条、实时日志、一键取消
  • 产物布局:每个视频独立文件夹(源文件 / 解析报告 / 剪辑结果)

架构

┌──────────────┐   子进程 python -m vedit.cli    ┌──────────────┐
│  WPF 前端     │ ────────────────────────────> │  vedit 后端   │
│  (.NET 8)    │ <──── [PROGRESS]/[Y]/[DURATION]│  (纯 Python)  │
└──────────────┘        stdout 行协议            └──────────────┘
  • 后端 vedit/:与 UI 彻底解耦,无 tkinter/asyncio 依赖
    • core.py ffmpeg 路径解析 / 5 秒窗口算法 / 路径约定
    • analyze.py 活动强度计算 + report.html
    • plan.py 倒算参考 Y / 预览指定 Y 的结果时长
    • export.py 用内联 Y 拼接高光集锦
    • cli.py 无头运行器(stdout 行协议)
  • 前端 VideoEditor.Wpf/:C#/XAML,Process 拉起后端,解析 [PROGRESS]/[Y]/[DURATION] 行驱动进度条、Y 填充、时长显示

目录结构

剪辑工具/
  vedit/                # 后端 Python 工作流库
  VideoEditor.Wpf/      # WPF 前端工程(源码)
  发布/
    需Python版/         # 自包含 .NET + vedit(需系统已装 Python)
    内置Python版/       # 自包含 .NET + vedit + 内置解释器(零外部依赖,不入库)

使用

  1. 运行 发布\<版本>\视频剪辑面板.exe
  2. 选「视频文件」(可直接拖入窗口)
  3. 选「产品文件夹」
  4. 「开始分析」:源视频搬入 <产品文件夹>/<视频名>/,跑活动强度 + 报告,倒算参考 Y 自动填入
  5. 手动修改 Y(可选),点「计算时长」实时预览该 Y 的结果时长
  6. 「开始剪辑」:用 Y 框的值产出高光集锦

产物布局:

<产品文件夹>/<视频名>/
    <视频名>.mp4        # 源文件(面板搬入)
    01_解析/            # activity.csv / thumbnails / contact_sheets / report.html
    02_剪辑/            # 高光集锦.mp4 + plan.txt(参考Y)

两种发布版

版本 .NET 运行时 Python 适用
需Python版 内置 需系统安装(PATH) 开发机/已有环境
内置Python版 内置 内置(零依赖) 干净机器直接用

重新构建

# 1) 发布 WPF(自包含 .NET)
dotnet publish VideoEditor.Wpf\VideoEditor.Wpf.csproj -c Release -r win-x64 --self-contained true -o <输出目录>

# 2) 拷入 vedit 包
Copy-Item -Recurse vedit <输出目录>\vedit

# 3) 内置 Python 版:再拷入解释器
Copy-Item -Recurse C:\Python314 <输出目录>\python   # 或官方 embeddable 版

前端通过 python -m vedit.cli <命令> 子进程调用后端,解析 [PROGRESS]/[Y]/[DURATION] 行驱动进度、Y、时长。


English

Auto-extract highlight segments from long videos: frame sampling → per-second activity analysis → 5-second window segmentation → auto-calculated editing ratio Y → highlight reel. Python backend workflow library (vedit) + WPF (.NET 8) frontend panel.

Features

  • Per-second activity intensity: grayscale frames via ffmpeg, mean pixel diff between adjacent frames
  • 5-second window algorithm: keep windows whose mean activity > overall mean × Y; merge adjacent kept seconds
  • Auto Y suggestion: minimal Y (step 0.05) so total duration ≤ 30 min — a reference value only; manually adjustable with live duration preview
  • WPF panel: video drag & drop, product folder picker, progress bar, live log, cancel
  • Output layout: one folder per video (source / analysis report / result)

Architecture

  • Backend vedit/: fully decoupled from UI (no tkinter/asyncio)
    • core.py ffmpeg resolution / 5s window algorithm / path conventions
    • analyze.py activity computation + report.html
    • plan.py suggest reference Y / preview duration for a given Y
    • export.py concat highlight reel with inline Y
    • cli.py headless runner (stdout line protocol)
  • Frontend VideoEditor.Wpf/: C#/XAML, spawns the backend via Process, parses [PROGRESS]/[Y]/[DURATION] lines to drive progress bar, Y field and duration display

Usage

  1. Run 发布\<variant>\视频剪辑面板.exe
  2. Pick a video (or drag it onto the window)
  3. Pick a product folder
  4. "开始分析" (Analyze): moves the source into <product>/<video-name>/, computes activity + report, auto-fills the reference Y
  5. Optionally edit Y, click "计算时长" (Calc duration) to preview the resulting length
  6. "开始剪辑" (Edit): renders the highlight reel with the Y from the input box

Build

# 1) Publish WPF (self-contained .NET)
dotnet publish VideoEditor.Wpf\VideoEditor.Wpf.csproj -c Release -r win-x64 --self-contained true -o <outdir>

# 2) Copy in the vedit package
Copy-Item -Recurse vedit <outdir>\vedit

# 3) For the bundled variant, also copy a Python interpreter
Copy-Item -Recurse C:\Python314 <outdir>\python   # or the official embeddable build

The frontend calls the backend via python -m vedit.cli <command> and parses [PROGRESS]/[Y]/[DURATION] stdout lines.

About

长视频自动高光剪辑:抽帧活动分析 + 5秒窗口选段 + 自动Y比例 | Auto video highlight extraction (Python vedit + WPF .NET 8)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages