Article 58PHN Script to cut adverts out of a video

Script to cut adverts out of a video

by
GPGAgent
from LinuxQuestions.org on (#58PHN)
I've written a script that lets me cut bits out of a video but I think it could be slicker, basically thus script takes a filename, number of cuts (I don't usit tho') Start and end of first bit to keep, start and end of second bit to keep and so on up to five bits to keep.

Firstly I'd like to not have limit of just up to five bits to keep, and secondly how could the script be improved, here's the script:Code:#!/bin/bash
# usage:
# CutAndEncode.sh Filename Cuts Start1 End1 Start2 End2 Start3 End3 ... Start5 End5
cnt=1
for P in "$@"
do
case $cnt in
1) FN=$P;;
2) CUTS=$P;;
3) ST=$P;;
4) EN=$P
echo "Cut $cnt of $FN start at $ST and end at $EN"
ffmpeg -ss $ST -to $EN -i "$FN" -vf "yadif" -aspect 4:3 -c:v libx265 -preset faster Tmp-$cnt.mp4;;

5) ST=$P;;
6) EN=$P
echo "Cut $cnt of $FN start at $ST and end at $EN"
ffmpeg -ss $ST -to $EN -i "$FN" -vf "yadif" -aspect 4:3 -c:v libx265 -preset faster Tmp-$cnt.mp4;;

7) ST=$P;;
8) EN=$P
echo "Cut $cnt of $FN start at $ST and end at $EN";;


9) ST=$P;;
10) EN=$P
echo "Cut $cnt of $FN start at $ST and end at $EN";;


11) ST=$P;;
12) EN=$P
echo "Cut $cnt of $FN start at $ST and end at $EN";;

13) ST=$P;;
14) EN=$P
echo "Cut $cnt of $FN start at $ST and end at $EN";;
esac
cnt=$((cnt + 1))
done
echo "Now join the cuts"

ls Tmp*.mp4 | perl -ne 'print "file $_"' | ffmpeg -protocol_whitelist "file,pipe" -safe 0 -y -f concat -i - -codec copy $FN.mp4
echo "Now delete the temp files"
rm Tmp*.mp4Cheers folkslatest?d=yIl2AUoC8zA latest?i=Jc5_3hPo-n0:Cp31U5zrI7I:F7zBnMy latest?i=Jc5_3hPo-n0:Cp31U5zrI7I:V_sGLiP latest?d=qj6IDK7rITs latest?i=Jc5_3hPo-n0:Cp31U5zrI7I:gIN9vFwJc5_3hPo-n0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments