Created
November 28, 2023 21:20
-
-
Save ejfox/4eed331a94ea0727bd7c996a2e681ae5 to your computer and use it in GitHub Desktop.
Use ffmpeg to split an mp3 file into separate files based on periods of silence
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
#!/bin/bash | |
# Remember to make your script executable by running chmod +x yourscript.sh and then execute it with ./yourscript.sh. | |
# Name of the input file | |
input="yourfile.mp3" | |
# Threshold for silence detection, in dB | |
silence_threshold="-50dB" | |
# Duration of silence to detect, in seconds | |
silence_duration="1" | |
# Prefix for the output files | |
output_prefix="part" | |
# Command to split the file | |
ffmpeg -i "$input" -af "silencedetect=noise=$silence_threshold:d=$silence_duration" -f segment -segment_time_metadata 1 -c copy -map 0 -segment_list "${input%.*}_segments.txt" -segment_list_type csv "${output_prefix}%03d.${input##*.}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment