Hi there,
Are you thinking about something they have on pornhub when you hover over a thumbnail?
In that case, here's how it's done.
Let's say, you want a 9 second "trailer" from your videos.
First, you have to get the video length, so you can divide it by 9.
For a 3-minute video, get 1 second clips from: 20s, 40s, 60s, 80s, 100s, 120s, 140s, 160s, 170s
Knowing this data, you can use ffmpeg to get 1 second clips from these times by using
ffmpeg -ss 00:00:20 -i input.mp4 -t 1 -c copy clip1.mp4
ffmpeg -ss 00:00:40 -i input.mp4 -t 1 -c copy clip2.mp4
etc
You'll have to create a text file with all the parts that should look something like this:
filename: parts.txt
file 'clip1.mp4'
file 'clip2.mp4'
file 'clip3.mp4'
etc
Once you are done, you can use ffmpeg to combine the 1 second clips to 1 mp4 video by using:
ffmpeg -f concat -safe 0 -i parts.txt -c:v libx264 -preset fast -crf 28 -an -movflags +faststart preview.mp4
This should do the job.
You can also automate this with php and a cron job by
Code:
$duration = shell_exec("ffprobe -i input.mp4 -show_entries format=duration -v quiet -of csv='p=0'");
$timestamps = [];
$total_clips = 9;
for ($i = 1; $i <= $total_clips; $i++) {
$position = ($duration / ($total_clips + 1)) * $i;
$timestamps[] = (int)$position;
}
etc.
Hope this helps,
z