PRACTICAL DEVELOPER HANDBOOK • WINDOWS EDITION

0

    
PRACTICAL DEVELOPER HANDBOOK • WINDOWS EDITION

AI YouTube Shorts Clipper

Apne Windows PC Par Free, Locally-Hosted AI Video Repurposing Tool Banane Ki Complete Step

by-Step Guide

Parichay (Introduction): Yeh pustika (handbook) aapko sikhayegi ki kaise aap bina kisi paid

subscription ke apne Windows computer par ek poora AI Video Clipper (OpusClip jaisa) taiyar kar sakte

hain. Yeh tool kisi bhi lambe YouTube video ko download karke uski audio sunta hai, sabse viral aur

engaging moments chunta hai, aur unhein seedha 9:16 Vertical Shorts/Reels format mein cut aur crop

karke taiyar kar deta hai.

CHAPTER 1

System Architecture aur Zaroori Tools

Is application ko banane aur chalane ke liye paanch mukhya open-source aur free technologies ka istemal

kiya gaya hai:

Component / Tool

Category

Tool Mein Mukhya Kaam

Python (3.15+) & Flask

yt-dlp

Backend & Web

Server

Media Downloader

Localhost web interface chalana aur sabhi AI/Video steps

ko control karna.

OpenAI Whisper

Google Gemini API

Speech-to-Text AI

Content Intelligence

YouTube link se best 720p video aur M4A audio download

karke merge karna.

PC ke CPU par offline rehkar video ki baatcheet ka

timestamped transcript banana.

Transcript padhkar Top 3 viral moments, catchy titles aur

Virality Score nikalna.

FFmpeg

CHAPTER 2

Video Processor

Chune gaye timestamps par video cut karna aur center se

9:16 vertical crop karna.

Environment Setup (Python aur FFmpeg)

Sabse pehle apne Windows PC mein core software aur libraries install karein. Har command ko dhyan se

chalayein:

AI YouTube Shorts Clipper • Setup Handbook

Page 1 of 6

1. Windows Start menu mein PowerShell search karein, right-click karke Run as Administrator

chunein.

2. Python Install Karein: Neeche di gayi command paste karke Enter dabayein. Agar installation ke

dauran 

Add commands directory to your PATH now? [y/N] pooche, toh 

y likh kar Enter

dabayein:

winget install Python.Python.3.15

3. FFmpeg Install Karein: Video cutting engine ke liye yeh command chalayein aur source agreement

poochne par Y likh kar Enter dabayein:

winget install Gyan.FFmpeg

4. PowerShell Restart Karein: Installation poori hone ke baad PowerShell ko Close (X) karein aur

ek naya PowerShell kholein taaki Windows ka PATH variable update ho jaye.

5. Project Folder aur Libraries Install Karein: Naye PowerShell mein yeh teeno commands ek

saath paste karke Enter dabayein (is process mein 2 se 5 minute lag sakte hain):

mkdir C:\AI_Clipper\templates

cd C:\AI_Clipper

python -m pip install flask yt-dlp openai-whisper google-genai pydantic

CHAPTER 3

Free Gemini API Key Prapt Karna

AI analysis ke liye aapko Google AI Studio se ek muft API key ki zaroorat hogi:

1. Apne browser mein 

https://aistudio.google.com/api-keys kholein aur apni Gmail ID se login

karein.

2. Upar right side mein Create API key button par click karein aur koi bhi project (jaise Default Gemini

Project) chunein.

3. Table mein Key column ke neeche jo code 

AIza... se shuru hota hai, use copy kar lein.

Dhyan Dein: Project ID (jaise 

gen-lang-client-... ) API key nahi hoti. Code mein hamesha

AIzaSy... se shuru hone wali asli key hi paste karein.

CHAPTER 4

Backend Application File (app.py)

Is file mein smart Transcript Caching (taaki ek hi video dobara download na ho) aur Auto-Retry

Fallback (taaki agar ek Gemini model busy ho toh tool apne aap doosre model par switch kar jaye) shamil

hai.

Windows mein Notepad kholein, neeche diya gaya poora code paste karein, Line 13 mein apni 

key dalein, aur ise 

C:\AI_Clipper folder ke andar 

AIza...

"app.py" (double quotes ke saath) naam se save

karein:

AI YouTube Shorts Clipper • Setup Handbook

Page 2 of 6

import os

import sys

import time

import subprocess

import whisper

from flask import Flask, render_template, request, jsonify, send_from_directory

from google import genai

from pydantic import BaseModel, Field

app = Flask(__name__)

# YAHAN APNI AIza... WALI GEMINI API KEY PASTE KAREIN

GEMINI_API_KEY = "APNI_GEMINI_API_KEY_YAHAN_DALEIN"

client = genai.Client(api_key=GEMINI_API_KEY)

OUTPUT_DIR = "clips"

os.makedirs(OUTPUT_DIR, exist_ok=True)

print("Whisper AI model load ho raha hai...")

whisper_model = whisper.load_model("base")

class Clip(BaseModel):

    title: str = Field(description="Catchy short title for the clip")

    start_time: float = Field(description="Start time in seconds")

    end_time: float = Field(description="End time in seconds (clip should be 20 to 55 

seconds long)")

    virality_score: int = Field(description="Score from 1 to 100")

class ClipList(BaseModel):

    clips: list[Clip]

@app.route("/")

def index():

    return render_template("index.html")

@app.route("/generate", methods=["POST"])

def generate():

    url = request.json.get("url")

    if not url:

        return jsonify({"error": "YouTube link paste karein!"}), 400

    video_path = "source_video.mp4"

    transcript_cache = "last_transcript.txt"

    last_url_file = "last_url.txt"

    try:

        same_video = False

        if os.path.exists(last_url_file) and os.path.exists(video_path) and 

os.path.exists(transcript_cache):

            with open(last_url_file, "r", encoding="utf-8") as f:

                if f.read().strip() == url:

                    same_video = True

        if same_video:

            print("1/4 & 2/4: Purani video aur transcript mil gaya! Seedha AI step par ja 

rahe hain...")

            with open(transcript_cache, "r", encoding="utf-8") as f:

                full_transcript = f.read()

        else:

            if os.path.exists(video_path):

                os.remove(video_path)

AI YouTube Shorts Clipper • Setup Handbook Page 3 of 6

CHAPTER 5

Frontend Interface File (index.html)

Ab ek naya Notepad kholein, neeche diya gaya code copy-paste karein, aur ise

C:\AI_Clipper\templates folder ke andar 

"index.html" (double quotes ke saath) naam se save

karein:

AI YouTube Shorts Clipper • Setup Handbook

Page 4 of 6

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>AI Shorts Clipper</title>

    <style>

        body { font-family: Arial, sans-serif; background: #0f172a; color: #f8fafc; text

align: center; padding: 30px; }

        .box { max-width: 700px; margin: auto; background: #1e293b; padding: 25px; border

radius: 12px; }

        input { width: 70%; padding: 12px; border-radius: 6px; border: none; font-size: 

16px; }

        button { padding: 12px 20px; background: #3b82f6; color: white; border: none; 

border-radius: 6px; font-size: 16px; cursor: pointer; font-weight: bold; }

        button:hover { background: #2563eb; }

        button:disabled { background: #64748b; cursor: not-allowed; }

        #status { margin-top: 20px; font-size: 16px; color: #38bdf8; }

        .clips-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; 

margin-top: 30px; }

        .clip-card { background: #0f172a; padding: 15px; border-radius: 10px; width: 260px; 

border: 1px solid #334155; }

        video { width: 100%; border-radius: 8px; margin-top: 10px; }

        .badge { background: #10b981; color: #000; padding: 3px 8px; border-radius: 4px; 

font-weight: bold; font-size: 12px; }

        .dl-btn { display: inline-block; margin-top: 10px; padding: 8px 14px; background: 

#8b5cf6; color: white; text-decoration: none; border-radius: 5px; font-size: 14px; }

    </style>

</head>

<body>

    <div class="box">

        <h1>My AI Shorts Clipper</h1>

        <p>YouTube link paste karein aur AI se viral vertical clips banayein</p>

        <input type="text" id="ytUrl" placeholder="https://www.youtube.com/watch?v=..." />

        <button id="genBtn" onclick="generateClips()">Generate Clips</button>

        <div id="status"></div>

    </div>

    <div class="clips-grid" id="results"></div>

    <script>

        async function generateClips() {

            const url = document.getElementById("ytUrl").value.trim();

            const btn = document.getElementById("genBtn");

            const status = document.getElementById("status");

            const results = document.getElementById("results");

            if (!url) return alert("Pehle YouTube link paste karein!");

            btn.disabled = true;

            results.innerHTML = "";

            status.innerText = "Kaam chal raha hai... Video download, AI analysis aur 9:16 

crop mein kuch minute lag sakte hain. PowerShell window dekhein!";

            try {

                const res = await fetch("/generate", {

                    method: "POST",

                    headers: { "Content-Type": "application/json" },

                    body: JSON.stringify({ url })

                });

                const data = await res.json();

                if (data.error) {

                    status.innerText = "Error: " + data.error;

                } else {

                    status.innerText = "Clips taiyar hain!";

                    data.clips.forEach(c => {

                        results.innerHTML += `

AI YouTube Shorts Clipper • Setup Handbook Page 5 of 6

CHAPTER 6

Application Chalane Ki Vidhi aur Zaroori Tips

1. Server Start Karein: PowerShell mein project folder khol kar server chalu karein:

cd C:\AI_Clipper

python app.py

2. Browser Mein Kholein: Jab screen par 

Running on http://127.0.0.1:5000 dikhe, toh

PowerShell ko minimize karein (band na karein) aur Chrome browser mein 

http://127.0.0.1:5000

kholein.

3. Clips Generate Karein: Kisi bhi YouTube video ka URL paste karke Generate Clips dabayein.

Process poora hote hi neeche 3 vertical MP4 clips download ke liye taiyar milengi.

Sthiti / Message

Sahi Samadhan aur Jankari

FP16 / JS Runtime Warning

Processing Time

Yeh dono warnings bilkul samanya hain. Bina NVIDIA GPU wale PC par

Whisper apne aap CPU mode (FP32) chunta hai, jisse quality par koi asar

nahi padta.

Normal CPU par 5 minute ke video mein lagbhag 2–4 minute aur 30 minute

ke video mein 12–15 minute lag sakte hain.

503 Model Busy Error

Traffic zyada hone par code apne aap 5 second ruk kar backup models try

karta hai, aur saved transcript ke karan video dobara download nahi hoti.

AI YouTube Shorts Clipper • Setup Handbook

Page 6 of 6



Post a Comment

0Comments
Post a Comment (0)