Created
September 19, 2022 22:49
-
-
Save Behinder/068159b32f736a806e55132ef322ed59 to your computer and use it in GitHub Desktop.
Cut commercials from the video file and join files
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 characters
#!/usr/bin/env bash | |
NAZWA="$(basename "$1" | sed 's/\(.*\)\..*/\1/')" | |
echo "Generating split command\n" | |
KOMENDA="tr -d '\n' < \"$NAZWA.ffsplit\"" | |
STRING=`eval $KOMENDA` | |
echo $STRING | |
#echo "ffmpeg -i \"$1\"" | |
eval "ffmpeg -i \"$1\" $STRING" | |
echo "Done split" | |
echo "Generate merge command" | |
#First counting line in ffsplit file | |
ILE="wc -l < \"$NAZWA.ffsplit\"" | |
ILEWYNIK=`eval $ILE` | |
if [ -n "$2" ]; then | |
CODEC=$2 | |
else | |
CODEC="libx264" | |
fi | |
if [ $ILEWYNIK -lt 10 ]; then | |
STRING="ffmpeg -i \"concat:" | |
for (( i=0;i<$ILEWYNIK-1;i++ )) ; | |
do | |
STRING=$STRING"segment00$i.ts|" | |
done | |
else | |
STRING="ffmpeg -i \"concat:" | |
for (( i=0;i<9;i++ )) ; | |
do | |
STRING=$STRING"segment00$i.ts|" | |
done | |
for (( i=10;i<=$ILEWYNIK-1;i++ )) ; | |
do | |
STRING=$STRING"segment0$i.ts|" | |
done | |
fi | |
KOMENDA=$STRING"\" -c:v $CODEC -c:a ac3 -f mpegts output.mpg" | |
echo $KOMENDA | |
echo "Starting merge segments" | |
eval "$KOMENDA" | |
echo "Done.Removing segments" | |
rm segment*.ts | |
mv output.mpg "_$1" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment