VideoHelp Forum
+ Reply to Thread
Results 1 to 1 of 1
Thread
  1. 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/bin
    Code:
    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 ~/bin
    Code:
    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

    Code:
    scene-detect -h
    scene-detect help output

    Code:
    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
    You can run the scene-detect script and detect scene changes in the whole video or specify a start and end time

    analyse the whole video

    Code:
    scene-detect -i input.mkv -o detect.txt
    analyse a section of the video
    the code below will analyse the video from 10 minutes for 10 minutes


    Code:
    scene-detect -s 00:10:00 -i input.mkv -e 00:10:00 -o detect.txt
    the -s option is used to specify the start time

    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

    Code:
    scene-time -h
    scene-time help output

    Code:
    scene-time -i input -o output
    
    -i input
    -o output
    take the text file produced by the scene-detect script and convert the time into start and end timestamps for ffmpeg
    where detect.txt is the name of the file

    Code:
    scene-time -i detect.txt -o cutlist.txt
    the -i option is used to specify the name of the text file created by the scene-detect script
    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

    Code:
    scene-cut -h
    scene-cut help output

    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

    Code:
    scene-cut -i input.mkv -c cutlist.txt
    the -i option is used to specify the video to process
    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
    Last edited by NapoleonWils0n; 22nd Mar 2022 at 14:50.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!