Advertisement
metalx1000

Mute Audio by Subtitle Time Stamps for censoring

Jan 18th, 2023
1,606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.75 KB | None | 0 0
  1. ######################################################################                                                      
  2. #Copyright (C) 2023  Kris Occhipinti
  3. #https://filmsbykris.com
  4.  
  5. #This program is free software: you can redistribute it and/or modify                
  6. #it under the terms of the GNU General Public License as published by
  7. #the Free Software Foundation version 3 of the License.        
  8.  
  9. #This program is distributed in the hope that it will be useful,
  10. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. #GNU General Public License for more details.                                                                            
  13.  
  14. #You should have received a copy of the GNU General Public License
  15. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. ######################################################################
  17.  
  18. sub_file="movie.srt"
  19. movie_file="movie.mp4"
  20. cmd=""                                                                                            
  21. entries="$(grep -B 1 -Ei 'bad word2|bad word1|god' $sub_file| grep '\-\->'|sed 's/ --> /|/g')"
  22. echo "$entries"|while read e;
  23. do
  24.   time1="$(echo "$e"|cut -d\| -f1| awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')"
  25.   time2="$(echo "$e"|cut -d\| -f2| awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')"
  26.   echo "$time1 -- $time2"
  27.   cmd="${cmd}volume=enable='between(t,$time1,$time2)':volume=0,"  
  28. done
  29.  
  30. #remove last comma
  31. cmd="$(echo $cmd|rev|cut -c2-|rev)"  
  32. cmd="ffmpeg -i '$movie_file' -af \"$cmd\" -vcodec copy edit_.mp4"              
  33. echo $cmd                                                                                                                      
  34. eval $cmd
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement