AI-Shorts-Creator is a powerful tool designed for content creators, podcasters, and video enthusiasts to effortlessly extract captivating segments from their videos. Leveraging the advanced language model GPT-4, this innovative solution intelligently analyzes video transcripts to identify the most viral and exciting moments. By harnessing the capabilities of FFmpeg and OpenCV, AI-Shorts-Creator automatically crops videos, allowing you to focus on the key highlights and provide an enhanced viewing experience.
Source Video : https://www.youtube.com/watch?v=NHaczOsMQ20
Get started with AI-Shorts-Creator today and unlock the potential of your videos like never before!
Requirements
pytube
library (install with pip install pytube
)opencv-python
library (install with pip install opencv-python
)openai
library (install with pip install openai
)youtube-transcript-api
library (install with pip install youtube-transcript-api
)pip install -r requirements.txt
Install FFmpeg by following the installation instructions for your operating system. Make sure the ffmpeg
command is accessible from the command line.
Set up your OpenAI API key by replacing openai.api_key = ''
with your actual OpenAI API key.
Modify the video_id
variable in the main()
function to specify the YouTube video you want to process.
Run the script:
python auto_cropper.py
The script will download the YouTube video, analyze its transcript using OpenAI's GPT-4, extract the best sections based on the analysis, crop the video using FFmpeg, and apply face detection using OpenCV to further refine the cropping.
download_video(url, filename)
function downloads a YouTube video by providing the URL and specifying the filename.segment_video(response)
function segments the video into interesting sections based on a transcript analysis using OpenAI's GPT-4 model.detect_faces(video_file)
function uses face detection to identify faces in a video file.crop_video(faces, input_file, output_file)
function crops the video around the detected faces using FFmpeg.is_talking_in_batch(frames)
function analyzes the lip movement or facial muscle activity within a batch of frames to determine if talking behavior is present.adjust_focus(frame, talking)
function applies visual effects or adjustments to emphasize the speaker in the frame.Please note that the GPT-4 model and transcript analysis functionality in the provided code are simulated and not fully functional. You would need a valid OpenAI API key and a working GPT-4 model to perform transcript analysis.