How tdollar15/opusclip-clone works
Main Components
• Input/Output:
• Input video source (via a provided YouTube URL).
• Output short video (Final.mp4).
• Download Module:
• YoutubeDownloader (Components/YoutubeDownloader.py) handles video fetching.
• Preprocessing:
• The main.py script orchestrates the whole process.
• Transcription:
• Transcription module (Components/Transcription.py) utilizes Whisper to transcribe the video.
• Extraction:
• LanguageTasks (Components/LanguageTasks.py) communicates with GPT-4 to extract the most engaging segments.
• Speaker and Face Detection:
• SpeakerDetection (Components/SpeakerDetection.py) to detect speakers.
• Speaker (Components/Speaker.py) and FaceCrop (Components/FaceCrop.py) to detect and crop the faces.
• Models in the models/ directory (deploy.prototxt and the caffemodel) support face detection tasks.
• Video Editing:
• Edit (Components/Edit.py) handles the editing/cropping operations (vertical cropping for short format).
• Environment/Configuration:
• A .env file for managing sensitive API keys.
• requirements.txt defines dependencies.
Relationships and Data Flow
• The process begins when main.py prompts for a YouTube URL.
• The YoutubeDownloader downloads the long-form video.
• Once downloaded, the Transcription module processes the video to convert audio to text.
• Using the transcript, the LanguageTasks component calls GPT-4 (via the OpenAI API) to determine which parts are the “highlights.”
• SpeakerDetection and Speaker modules are utilized to identify and verify speakers during these segments.
• The FaceCrop module, leveraging OpenCV and the provided Haar Cascade model files (haarcascade_frontalface_default.xml and models’ files), ensures that the frames are cropped properly (vertically) for optimal display in shorts.
• The Edit module then puts together the final short video output.
• Finally, the processed video (Final.mp4) is saved.