nrh265.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. CUR_DIR="$(dirname "$(readlink -f "$0")")"
  2. ARGS=("$@")
  3. if [[ $# = 0 ]]; then less "$CUR_DIR"/readme.md; exit; fi
  4. VDPATH=${ARGS[$(($#-1))]} # 输入文件名
  5. c="" # ffmpeg命令的crf残片
  6. s="" # 本地生成文件名后缀的crf部分
  7. p="" # ffmpeg命令的preset残片
  8. while getopts "c:s:p:" optname; do
  9. case "$optname" in
  10. c)
  11. c=" -c ${OPTARG} "
  12. ;;
  13. s)
  14. s=" -s ${OPTARG} "
  15. ;;
  16. p)
  17. p=" -p ${OPTARG} "
  18. ;;
  19. *)
  20. echo "error arg option: -${optname}."
  21. exit
  22. ;;
  23. esac
  24. done
  25. # 文件参数拦截
  26. # 允许:
  27. # nrh265 [..options..] rawfile_exists.mp4
  28. # nrh265 [..options..] rawfile_exists.mp4 movetofile_not_exists.mp4
  29. # 禁止:
  30. # nrh265 [..options..] rawfile_not_exists.mp4
  31. # nrh265 [..options..] rawfile_exists.mp4 movetofile_exists.mp4
  32. if ! [[ -e "${VDPATH}" ]]; then
  33. if [[ $# -eq 1 ]]; then
  34. echo "错误:输入的文件不存在"
  35. exit
  36. fi
  37. # 可能采用了 【rh265 [...] rawfile.mp4 movetofile.mp4】的调用形式(先改名,再转码)
  38. # MOVETO=$VDPATH
  39. # VDPATH=${ARGS[$(($#-2))]}
  40. if ! [[ -e "${ARGS[$(($#-2))]}" ]]; then
  41. echo "错误:输入的文件不存在"
  42. exit
  43. else
  44. nohup "$CUR_DIR"/rh265.sh $c $s $p "${ARGS[$(($#-2))]}" "$VDPATH" 2>&1 > "$VDPATH.nohup" &
  45. # echo "nohup \"$CUR_DIR\"/rh265.sh $c $s $p \"${ARGS[$(($#-2))]}\" \"$VDPATH\" 2>&1 > \"$VDPATH.nohup\" &"
  46. fi
  47. else
  48. if [[ $# -eq 1 ]]; then
  49. nohup "$CUR_DIR"/rh265.sh $c $s $p "$VDPATH" 2>&1 > "$VDPATH.nohup" &
  50. # echo "nohup \"$CUR_DIR\"/rh265.sh $c $s $p \"$VDPATH\" 2>&1 > \"$VDPATH.nohup\" &"
  51. else
  52. if [[ -e "${ARGS[$(($#-2))]}" ]]; then
  53. echo "错误:转码前文件改新名失败,因新名所指文件在以前就已存在"
  54. exit
  55. else
  56. nohup "$CUR_DIR"/rh265.sh $c $s $p NOPENOPENOPE "$VDPATH" 2>&1 > "$VDPATH.nohup" &
  57. # echo "nohup \"$CUR_DIR\"/rh265.sh $c $s $p NOPENOPENOPE \"$VDPATH\" 2>&1 > \"$VDPATH.nohup\" &"
  58. fi
  59. fi
  60. fi
  61. echo "________________________________"
  62. echo "tail -f -n 50 \"$VDPATH.nohup\""
  63. echo "────────────────────────────────"
  64. sleep 1
  65. tail -f -n 50 "$VDPATH.nohup"