ffmpeg scene detection with a Makefile

ffmpeg has a scene detection filter which can be used to analyze the scene changes in a video,
i created three scripts to automate scene detection using ffmpeg

scene-detect - analyzes the video and outputs the scene time changes to a text file
scene-time - converts the output of scene-detect to a csv file with the start point of the scene and the duration
scene-cut - takes the csv file created scene-time loops over the start points and creates clips for the duration of each scene change

We can use a Makefile to automate ffmpeg scene detection instead of running the scene-detect, scene-time and scene-detect scripts manually

Makefiles and ffmpeg scene detection made easy


You just need to install the scripts listed above put the Makefile in the same directory as the video
and then run

Code:
make input=video.mp4

you can also press tab to autocomplete input and then = and the name of the video to process

you can also perform scene detection on a range in the video for example from 5 to 10 minutes
as well as change threshold used to determine the scene change

the scene detection output video clips filenames will contain the input video filename
and the time of the start of the clip and the duration

so if you processed a video called big-buck-bunny.mp4
the scene detection video clip filenames would look like this

big-buck-bunny-[00:00:00-00:00:02].mp4
big-buck-bunny-[00:00:02-00:00:04].mp4
big-buck-bunny-[00:00:04-00:00:06].mp4

make clean
will prompt you to delete the ffmpeg scene detection text files and all the created clips
except the original video file and Makefile

MakeFile
scene-detect
scene-time
scene-cut

the scripts are part of a collection of ffmpeg shell scripts for simple editing tasks
with a BSD 3-Clause License

ffmpeg-scripts English
ffmpeg-Skripte German

playlist for the scripts
editing audio and video with ffmpeg
 
Back
Top