This is a script written in PHP to create small video previews like the ones you see on YouTube. It makes use of ffmpeg and ffprobe.
Because I'm a web guy and comfortable with PHP.
In its simplest form you call the script and give it a file and (optionally) video dimensions for the output:
php convert.php myVideo.mp4 400x300
The result will be a small preview video: myVideo-preview.mp4
Use quotes or escape spaces if your filename contains spaces:
php convert.php "my video.mp4" 400x300
php convert.php my\ video.mp4 400x300
Some tuning can be done with the settings at the top of the script:
FFMPEG_PATH
: Path to the ffmpeg binary. If globally installed leave it atffmpeg
FFPROBE_PATH
: Path to the ffprobe binary. If globally installed leave it atffprobe
CHOP_SECONDS
: The number of seconds to skip at the beginning and end of a file, to skip titles, default30
NUMBER_OF_PARTS
: The number of segments you want your preview to have, default8
PART_DURATION
: The length of each segment in seconds, default1.25
FPS
: Frames per second for the output file, default25
The reason why those values are not part of the command line input is because this script will most likely run as an automated task or cronjob and all the video previews need to be the same.
Here is an example video preview of the ElephantsDream movie.
- Add check for minimum video length
- Add option to set output folder