Created
January 12, 2019 22:08
-
-
Save YasienDwieb/72267f6b350a4370e3685c79f9a339a0 to your computer and use it in GitHub Desktop.
Revisions
-
YasienDwieb created this gist
Jan 12, 2019 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/bin/bash if [ $# -eq 0 ] then echo 'Usage: audiosplitter.sh filename|directory segmenttime' exit fi FILENAME=$1 SEGMENTTIME=$2 if [ -d "${FILENAME}" ]; then for file in `ls $FILENAME`;do NAMEWITHNOEXTENSION=`echo "${file}" | rev | cut -d"." -f2- | rev` OUTPUTFILENAME=`echo $NAMEWITHNOEXTENSION | sed --expression='s/ /_/g'` mkdir $OUTPUTFILENAME ffmpeg -i "$FILENAME/$file" -f segment -segment_time $SEGMENTTIME -c copy $OUTPUTFILENAME/part%03d.mp3 done elif [[ -f $FILENAME ]]; then NAMEWITHNOEXTENSION=`echo $FILENAME | rev | cut -d"." -f2- | rev` OUTPUTFILENAME=`echo $NAMEWITHNOEXTENSION | sed --expression='s/ /_/g'` mkdir $OUTPUTFILENAME ffmpeg -i "$FILENAME" -f segment -segment_time $SEGMENTTIME -c copy $OUTPUTFILENAME/part%03d.mp3 else echo "$PASSED is not valid" exit 1 fi