Detect scene changes in a video with ffmpeg and split the video in clips based on the scene changes
The scripts are posix shell scripts and work on linux,unix,mac and windows using wsl
ffmpeg-scripts
You can perform scene detection on the whole video or specify a start and end time
all the scripts support the time in seconds or sexigisimal format
There are 3 scripts
scene-detect which detects the scene changes in a video and creates a text file with the scene changes
scene-time converts the output of scene-detect into start and end times for ffmpeg to create the clips
scene-cut takes the output of scene-time and the video file and automatically cuts the video into clips based on the scene changes
scene-detect script
https://raw.githubusercontent.com/NapoleonWils0n/ubuntu-bin/master/scene-detect
download the script with curl
Code:curl 'https://raw.githubusercontent.com/NapoleonWils0n/ubuntu-bin/master/scene-detect' -o ~/Desktop/scene-detect
scene-time script
https://raw.githubusercontent.com/NapoleonWils0n/ubuntu-bin/master/scene-time
download the script with curl
Code:curl 'https://raw.githubusercontent.com/NapoleonWils0n/ubuntu-bin/master/scene-time' -o ~/Desktop/scene-time
scene-cut script
https://raw.githubusercontent.com/NapoleonWils0n/ubuntu-bin/master/scene-cut
download the script with curl
Code:curl 'https://raw.githubusercontent.com/NapoleonWils0n/ubuntu-bin/master/scene-cut' -o ~/Desktop/scene-cut
move the scripts to /usr/local/bin
Code:sudo mv ~/Desktop/scene-detect /usr/local/binCode:sudo mv ~/Desktop/scene-time /usr/local/bin
Code:sudo mv ~/Desktop/scene-cut /usr/local/bin
or your ~/bin directory if you have one
Code:sudo mv ~/Desktop/scene-detect ~/binCode:sudo mv ~/Desktop/scene-time ~/bin
Code:sudo mv ~/Desktop/scene-cut ~/bin
Usage
scene-detect
scene-detect detects the scene changes in a video
run the scene-detect script with the -h option to display the help
scene-detect help outputCode:scene-detect -h
You can run the scene-detect script and detect scene changes in the whole video or specify a start and end timeCode:scene-detect -s 00:00:00 -i infile -e 00:00:00 -t (0.1 - 0.9) -f sec -o outfile -s 00:00:00 : start time -i input.(mp4|mov|mkv|m4v) -e 00:00:00 : end time -t (0.1 - 0.9) # threshold -f sec # output in seconds -o output.txt
analyse the whole video
analyse a section of the videoCode:scene-detect -i input.mkv -o detect.txt
the code below will analyse the video from 10 minutes for 10 minutes
the -s option is used to specify the start timeCode:scene-detect -s 00:10:00 -i input.mkv -e 00:10:00 -o detect.txt
the -e option is the amount of time after the start point
the -t option is used to specify the threshold for scene detection
the -f option is used to specify the format in seconds, if you dont use the -f option it defaults to sexigisimal time
the -o option is used to specify the output file name of the text file, if you dont specify the -o option it defaults to the input file name and date and time
scene-time
scene-time converts the output of scene-detect into start and end times for ffmpeg to create the clips
run the scene-time script with the -h option to show the help
scene-time help outputCode:scene-time -h
take the text file produced by the scene-detect script and convert the time into start and end timestamps for ffmpegCode:scene-time -i input -o output -i input -o output
where detect.txt is the name of the file
the -i option is used to specify the name of the text file created by the scene-detect scriptCode:scene-time -i detect.txt -o cutlist.txt
the -o option is used to specify the outfile
scene-cut
scene-cut takes the output of scene-time and the video file and automatically cuts the video into clips based on the scene changes
run the scene-cut script with the -h option to display the help
scene-cut help outputCode:scene-cut -h
Code:scene-cut -i input -c cutfile -i input.(mp4|mov|mkv|m4v) -c cutfile
scene-cut takes a video file and the text file created by the scene-time script and chops the video into clips based on scene detection
the -i option is used to specify the video to processCode:scene-cut -i input.mkv -c cutlist.txt
the -c option is used to specify the cutlist created by the scene-time script
the video clips are automatically named input-1.mp4, input-2.mp4
where input is the name of the input file followed by the clip number, eg clip 1, clip 2 etec
ffmpeg scene-detection videos on youtube
ffmpeg scene detection - automatically cut videos into separate scenes
https://www.youtube.com/watch?v=nOeaFEHuFyM
ffmpeg scene detection - version 2 - specify a range in the video and cut into separate scenes
https://www.youtube.com/watch?v=SqvDCpWad9M
ffmpeg scene detect - version 3 - sexagesimal format - hours, minutes, seconds
https://www.youtube.com/watch?v=GZgE6fYd_wg
run shell scripts on windows using wsl
Windows run shell script using the command prompt or the WSL terminal
https://www.youtube.com/watch?v=N8t9W3u6cxc
+ Reply to Thread
Results 1 to 1 of 1
-
Last edited by NapoleonWils0n; 22nd Mar 2022 at 13:50.
Similar Threads
-
Looking for a Software to Detect Scene(s) in a video
By kucing in forum Newbie / General discussionsReplies: 4Last Post: 5th Nov 2021, 15:07 -
Scene change
By coolgit in forum RestorationReplies: 6Last Post: 9th Oct 2021, 12:22 -
Automatic change/scene detection for video game videos
By onewaydown in forum EditingReplies: 25Last Post: 7th Jan 2019, 00:24 -
is there any any software to split video base on scene?
By ujang in forum Newbie / General discussionsReplies: 45Last Post: 15th Aug 2018, 11:05 -
Ripping only a scene
By Faustus in forum DVD RippingReplies: 4Last Post: 18th Apr 2018, 19:10