Advertisement
Guest User

Untitled

a guest
Dec 26th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.44 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set +e
  4.  
  5. reencode() {
  6.     local E=${2##*.}
  7.     ffmpeg  -i "$2" -vf scale="-1:'min(ih,720)'" -c:v hevc_nvenc -b:v 1M -c:a aac -b:a 256K -y "$1.$E"
  8.     local newsize=$(stat -c %s "$1.$E")
  9.     local oldsize=$(stat -c %s "$2")
  10.     if [ $newsize -lt $oldsize ]; then
  11.         mv "$1.$E" "$2"
  12.     else
  13.         rm "$1.$E"
  14.     fi
  15. }
  16.  
  17. export -f reencode
  18.  
  19. find -size +100M -and \( -iname '*.mkv' -or -iname '*.mp4' \) | parallel -j 4 --progress --eta "reencode {#} {}"
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement