Last active
February 20, 2025 16:53
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe I should learn Python.