Advertisement
pintcat

make-xvid - converts any video into XviD

Aug 5th, 2024 (edited)
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.27 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.  
  10. [ -z "$1" -o ! -e "$1" ] && ERROR "Wrong input path or file name or none at all."
  11. IPATH="/home/pintcat/skripte/"
  12. [ -x "$IPATH"progress.sh ] || ERROR_MSG="progress.sh is"
  13. if [ ! -x "$IPATH"ffprogress.sh ]; then
  14.     if [ -n "$ERROR_MSG" ]; then
  15.         ERROR_MSG=$ERROR_MSG"\b\band ffprogress.sh are"
  16.     else
  17.         ERROR_MSG="ffprogress.sh is"
  18.     fi
  19. fi
  20. [ -n "$ERROR_MSG" ] && ERROR "$ERROR_MSG either missing or not executable."
  21. . "$IPATH"ffprogress.sh
  22.  
  23. #RESX=720    # default
  24. #RESY=406    # default
  25. RESX=720
  26. RESY=406
  27. #FRAMEX=720    # default
  28. #FRAMEY=540    # default
  29. FRAMEX=640
  30. FRAMEY=480
  31. POSX=$((($FRAMEX-$RESX)/2))
  32. POSY=$((($FRAMEY-$RESY)/2))
  33.  
  34. # Video filter:
  35.  
  36. #VIDEO_CROP="crop=320:180:0:30,"
  37. VIDEO_SCALE="scale=$RESX:$RESY:sws_flags=bicubic+accurate_rnd,setsar=1:1,"
  38. #VIDEO_PAD="pad=$FRAMEX:$FRAMEY:$POSX:$POSY,"
  39.  
  40. # These filter options convert HDR10 color space to the more commmon SDR8 (yuv420)
  41.  
  42. #VIDEO_COLCONV="zscale=tin=smpte2084:min=bt2020nc:pin=bt2020:rin=tv:t=smpte2084:m=bt2020nc:p=bt2020:r=tv,"
  43. #VIDEO_COLCONV=$VIDEO_COLCONV"zscale=t=linear:npl=100,"
  44. #VIDEO_COLCONV=$VIDEO_COLCONV"format=gbrpf32le,"
  45. #VIDEO_COLCONV=$VIDEO_COLCONV"zscale=p=bt709,"
  46. #VIDEO_COLCONV=$VIDEO_COLCONV"tonemap=tonemap=mobius:param=0.1:desat=0,"
  47. #VIDEO_COLCONV=$VIDEO_COLCONV"zscale=t=bt709:m=bt709:r=tv:dither=none,"
  48. #VIDEO_COLCONV=$VIDEO_COLCONV"format=yuv420p,"
  49.  
  50. # This filter scales the framerate down to 25fps (PAL standard)
  51.  
  52. VIDEO_FPSCONV="fps=25,zscale=rangein=tv:range=tv -pix_fmt yuv420p -r 25/1"
  53.  
  54. VIDEO_FILTER="$VIDEO_CROP$VIDEO_SCALE$VIDEO_PAD$VIDEO_COLCONV$VIDEO_FPSCONV"
  55.  
  56. # Encoder:
  57.  
  58. XVID="libxvid -ssim_acc 0 -me_quality 6 -trellis 1 -g 250 -bf 1 -qmin 1 -q:v 4"
  59. #XVID="libxvid -variance_aq 1 -ssim_acc 0 -me_quality 6 -trellis 1 -g 250 -bf 1 -qmin 1 -q:v 4"
  60. AC3="ac3 -b:a 128k -ar 48000 -ac 2 -channel_coupling 1 -dmix_mode 3"
  61.  
  62. # Use this to limit the output to a certain number of frames
  63.  
  64. #VIDEO_LIMIT="-vframes 25"
  65.  
  66. FF_ARGS="-vf $VIDEO_FILTER -acodec $AC3 -vcodec $XVID $VIDEO_LIMIT -f avi"
  67. FF_INPUT=$1
  68. FF_OUTPUT=$2
  69. echo
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement