pintcat

make-xvid - converts any video into XviD

Aug 5th, 2024 (edited)
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.44 KB | Software | 0 0
  1. #!/bin/sh
  2.  
  3. # Simply converts anything to XviD
  4.  
  5. ERROR(){
  6.     printf "\033[0;31mError - $1\033[0m\n"
  7.     exit 1
  8. }
  9. IPATH="/home/pintcat/skripte/"
  10. [ ! -x "$IPATH"ffprogress.sh ] && ERROR "ffprogress.sh is either missing or not executable."
  11. . "$IPATH"ffprogress.sh
  12.  
  13. # Check source & target path & file name
  14. [ -z "$1" ] || [ ! -e "$1" ] && ERROR "Wrong input path or file name or none at all.\n"
  15. if [ -z "$2" ]; then
  16.     FF_OUTPUT=$(printf "${1%.*}" | sed 's:/*$::').avi    # remove all trailing slashes & add suffix
  17. else
  18.     FF_OUTPUT=${2%*.avi}
  19.     [ -z ${2#$FF_OUTPUT*} ] && FF_OUTPUT="$2".avi || FF_OUTPUT="$2"
  20. fi
  21. if [ -e "$OUT" ]; then
  22.     read -r -p "Output file already exists. Overwrite (y/N)? " OPT
  23.     case $OPT in
  24.         y|Y)
  25.             rm -f "$OUT";;
  26.         *)
  27.             ERROR "Unable to write output file.\n";;
  28.     esac
  29. fi
  30.  
  31. RESX=720
  32. RESY=406
  33. FRAMEX=720
  34. FRAMEY=512
  35. POSX=$((($FRAMEX-$RESX)/2))
  36. POSY=$((($FRAMEY-$RESY)/2))
  37.  
  38. # Video filter:
  39.  
  40. #VIDEO_CROP="crop=320:180:0:30,"
  41. VIDEO_SCALE="scale=$RESX:$RESY:sws_flags=bicubic+accurate_rnd,setsar=1:1,"
  42. #VIDEO_PAD="pad=$FRAMEX:$FRAMEY:$POSX:$POSY,"
  43.  
  44. # These filter options convert HDR10 color space to the more commmon SDR8 (yuv420)
  45.  
  46. #VIDEO_COLCONV="zscale=tin=smpte2084:min=bt2020nc:pin=bt2020:rin=tv:t=smpte2084:m=bt2020nc:p=bt2020:r=tv,"
  47. #VIDEO_COLCONV=$VIDEO_COLCONV"zscale=t=linear:npl=100,"
  48. #VIDEO_COLCONV=$VIDEO_COLCONV"format=gbrpf32le,"
  49. #VIDEO_COLCONV=$VIDEO_COLCONV"zscale=p=bt709,"
  50. #VIDEO_COLCONV=$VIDEO_COLCONV"tonemap=tonemap=mobius:param=0.1:desat=0,"
  51. #VIDEO_COLCONV=$VIDEO_COLCONV"zscale=t=bt709:m=bt709:r=tv:dither=none,"
  52. #VIDEO_COLCONV=$VIDEO_COLCONV"format=yuv420p,"
  53.  
  54. # This filter scales the framerate down to 25fps (PAL standard)
  55.  
  56. VIDEO_FPSCONV="fps=25,zscale=rangein=tv:range=tv -pix_fmt yuv420p -r 25/1"
  57.  
  58. VIDEO_FILTER="$VIDEO_CROP$VIDEO_SCALE$VIDEO_PAD$VIDEO_COLCONV$VIDEO_FPSCONV"
  59.  
  60. # Encoder:
  61. XVID="libxvid -ssim_acc 0 -me_quality 6 -trellis 1 -g 25 -bf 1 -qmin 1 -q:v 4"
  62. #XVID="libxvid -variance_aq 1 -ssim_acc 0 -me_quality 6 -trellis 1 -g 250 -bf 1 -qmin 1 -q:v 4"
  63. AC3="ac3 -b:a 128k -ar 48000 -ac 2 -channel_coupling 1 -dmix_mode 3"
  64.  
  65. # Use this to limit the output to a certain number of frames
  66. #VIDEO_LIMIT="-vframes 25"
  67.  
  68. FF_ARGS="-vf $VIDEO_FILTER -acodec $AC3 -vcodec $XVID $VIDEO_LIMIT -f avi"
  69. FF_INPUT=$1
  70. if ! FF_PROGRESS; then
  71.     printf "\n\033[0;31mError - $FF_ERROR\033[0;32m\n\n"
  72.     exit 1
  73. fi
  74. printf "\n\n\n\n"
  75. rm -f $FF_LOG $FF_CMD
  76.  
Add Comment
Please, Sign In to add comment