Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ChaneMo/PreenCut

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎬 PreenCut - AI-Powered Video Clipping Tool

License: MIT Python 3.8+ Gradio Interface

PreenCut is an intelligent video editing tool that automatically analyzes audio/video content using speech recognition and large language models. It helps you quickly find and extract relevant segments from your media files using natural language queries.

Gradio Interface

✨ Key Features

  • Automatic Speech Recognition: Powered by WhisperX for accurate transcription
  • AI-Powered Analysis: Uses large language models to segment and summarize content
  • Natural Language Querying: Find clips using descriptive prompts like "Find all product demo segments"
  • Smart Clipping: Select and export segments as individual files or merged video
  • SRT Export: Generate subtitles with custom line length
  • Batch Processing: find a specific topic across multiple files
  • Re-analysis: Experiment with different prompts without reprocessing audio

⚙️ Installation

  1. Clone the repository:
git clone https://github.com/roothch/PreenCut.git
cd PreenCut
  1. Install dependencies, recommend using Python 3.11:
pip install -r requirements.txt
  1. Install FFmpeg (required for video processing):
# ubuntu/Debian
sudo apt install ffmpeg

# CentOS/RHEL
sudo yum install ffmpeg

# macOS (using Homebrew)
brew install ffmpeg

# Windows: Download from https://ffmpeg.org/
  1. Set up API keys (for LLM services): First you need to set your llm services in LLM_MODEL_OPTIONS of config.py. Then set your API keys as environment variables:
# for example, if you are using DeepSeek and DouBao as LLM services
export DEEPSEEK_V3_API_KEY=your_deepseek_api_key
export DOUBAO_1_5_PRO_API_KEY=your_doubao_api_key
  1. (Optional)set up gradio temp file directory: set os.environ['GRADIO_TEMP_DIR'] in config.py file.

🚀 Usage

  1. Start the Gradio interface:
python main.py
  1. Access the web interface at http://localhost:7860
  2. Upload video/audio files (supported formats: mp4, avi, mov, mkv, ts, mxf, mp3, wav, flac)
  3. Configure options:
  • Select LLM model
  • Choose Whisper model size (tiny → large-v3)
  • Add custom analysis prompt (Optional)
  1. Click "Start Processing" to analyze content
  2. View results in the analysis table:
  • Start/end timestamps
  • Duration
  • Content summary
  • AI-generated tags
  1. Use the "Re-analyze" tab to experiment with different prompts
  2. Use the "Cut" tab to select segments and choose export mode:
  • Export as ZIP package
  • Merge into a single video file
  1. you can also visit the Restful api use the route prefix /api/xxx

    • upload file

      POST /api/upload

      body: formdata

      key value type
      file file

      reponse: json

        { file_path: f'${GRADIO_TEMP_DIR}/files/2025/05/06/uuid.v1().replace('-', '')${file_extension}' }
      
    • create task

      POST /api/tasks

      body: json

      {
        "file_path": "put the file path here response from upload api, starting with ${GRADIO_TEMP_DIR}",   
        "llm_model": "DeepSeek-V3-0324",
        "whisper_model_size": "large-v2",
        "prompt": "提取重要信息,时间控制在10s"
      }

      response:

        { "task_id": "" }
    • query task reult

      GET /api/tasks/{task_id}

      response:

      {
        "status": "completed",
        "files": [
            "${GRADIO_TEMP_DIR}/files/2025/06/23/608ecc80500e11f0b08a02420134443f.wav"
        ],
        "prompt": "提取重要信息,时间控制在10s",
        "model_size": "large-v2",
        "llm_model": "DeepSeek-V3-0324",
        "timestamp": 1750668370.6088192,
        "status_info": "共1个文件,正在处理第1个文件",
        "result": [
            {
                "filename": "608ecc80500e11f0b08a02420134443f.wav",
                "align_result": {
                    "segments": [
                        {
                            "text": "有内地媒体报道,嫦娥6号着陆器上升器组合体已经完成了钻取采样,接着正按计划进行月面的表取采样。",
                            "start": 1.145,
                            "end": 9.329
                        }
                    ],
                    "language": "zh"
                },
                "segments": [
                    {
                        "start": 1.145,
                        "end": 9.329,
                        "summary": "嫦娥6号着陆器上升器组合体已完成钻取采样,正进行月面表取采样。",
                        "tags": [
                            "嫦娥6号",
                            "月球采样",
                            "航天科技"
                        ]
                    }
                ],
                "filepath": "${GRADIO_TEMP_DIR}/files/2025/06/23/608ecc80500e11f0b08a02420134443f.wav"
            }
        ],
        "last_accessed": 1750668836.8038888
      }

💻 Development

python3 -m uvicorn main:app --port 7860 --reload

⚡ Performance Tips

  • Use faster-whisper for shorter segments, use whisperx for faster processing
  • Adjust WHISPER_BATCH_SIZE based on available VRAM
  • Use smaller model sizes for CPU-only systems
  • If you don't need srt files, you could set ENABLE_ALIGNMENT=False to improve processing speed.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

💬 Community Communication

RedNote Group

⭐ Star History

Star History Chart

About

AI-Powered Video Retrieval & Clipping Tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.