Skip to content

Instantly share code, notes, and snippets.

@gphg
Last active February 20, 2025 16:53
Show Gist options
  • Save gphg/9bfa1704349e505ac235bb6587585ff9 to your computer and use it in GitHub Desktop.
Save gphg/9bfa1704349e505ac235bb6587585ff9 to your computer and use it in GitHub Desktop.
Local copy and slightly fixed script of this discussion: https://github.com/Breakthrough/PySceneDetect/discussions/475
__input="$1" # Required
__phase="$2" # Aka controller
__video_file=$(basename -- "$__input")
__video_name="${__video_file%.*}"
__video_ext="${__video_file##*.}"
__csv_name="${__video_name}-Scenes.csv"
# TODO: file checks
# Detect content and write it to be revised later.
# Saving into a file is important for consistency!
if [ ! -f "$__csv_name" ]; then
echo "$__csv_name doesn't exist."
scenedetect -i "$__input" \
detect-adaptive \
list-scenes -f "$__csv_name" --skip-cuts
fi
# Split everything as it is for human revision.
# Do it manually: remove lines to be merged, eg it was too short.
# To speed up, eg it will be split again later, you can lower the quality.
# split-video -crf 32 -p ultrafast
# split-video -a "-map 0:v:0 -map 0:a? -map 0:s? -c:v libx264 -preset slow -crf 17 -an"
if [ -f "$__csv_name" ]; then
echo "$__csv_name exist, process video spliting."
scenedetect -i "$__input" \
load-scenes -i "$__csv_name" -c "Start Timecode" \
split-video -a "-map 0:v:0 -map 0:a? -map 0:s? -c:v libx264 -preset slow -crf 17 -an" # equal to -hq, but no audio
fi
__input="$1" # Required
__phase="$2" # Aka controller
__video_file=$(basename -- "$__input")
__video_name="${__video_file%.*}"
__video_ext="${__video_file##*.}"
__csv_name="${__video_name}-Scenes.csv"
# TODO: file checks
# Detect content and write it to be revised later.
# Saving into a file is important for consistency!
if [ ! -f "$__csv_name" ]; then
echo "$__csv_name doesn't exist."
scenedetect -i "$__input" \
detect-content \
list-scenes -f "$__csv_name" --skip-cuts
fi
# Split everything as it is for human revision.
# Do it manually: remove lines to be merged, eg it was too short.
# To speed up, eg it will be split again later, you can lower the quality.
# split-video -crf 32 -p ultrafast
if [ -f "$__csv_name" ]; then
echo "$__csv_name exist, process video spliting."
scenedetect -i "$__input" \
load-scenes -i "$__csv_name" -c "Start Timecode" \
split-video -hq
fi
@gphg
Copy link
Author

gphg commented Feb 20, 2025

Maybe I should learn Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment