parallel-rh265.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/data/data/com.termux/files/usr/bin/bash
  2. CUR_DIR="$(dirname "$(readlink -f "$0")")"
  3. # 列出所有非hevc的视频文件,合理控制个数,并行执行远程转码。
  4. # 还支持随机选择远程机器(最好能了解机器负载情况,和ffmpeg任务数)
  5. # for i in `ls *.mp4`; do echo "rh265 -swebdev $i 2>&1 > $i.nohup" >> list; done
  6. # for i in `ls *.mp4`; do echo "nohup rh265 -sgzz $i 2>&1 > $i.nohup &" >> list; done
  7. # 参数
  8. # -c 可定制 ffmpeg 的crf参数值 (可选)
  9. # -s 指定配置文件的简称,例如 -s mm 会指定 rh265.mm.conf (可选)
  10. CRF="" # ffmpeg命令的crf残片
  11. SERV="" # 带有服务器简称的文件名中缀残片
  12. while getopts "c:s:" optname; do
  13. case "$optname" in
  14. c)
  15. CRF=" -c ${OPTARG} "
  16. ;;
  17. s)
  18. SERV=" -s ${OPTARG} "
  19. ;;
  20. *)
  21. echo 'error arg option: -${optname}.'
  22. exit
  23. ;;
  24. esac
  25. done
  26. listname=`date +%Y%m%d-%H%M%S`-$((RANDOM%10000)).list
  27. ls *.mp4 2>/dev/null >> $listname
  28. ls *.MP4 2>/dev/null >> $listname
  29. ls *.mov 2>/dev/null >> $listname
  30. ls *.MOV 2>/dev/null >> $listname
  31. ls *.avi 2>/dev/null >> $listname
  32. ls *.AVI 2>/dev/null >> $listname
  33. ls *.rmvb 2>/dev/null >> $listname
  34. ls *.RMVB 2>/dev/null >> $listname
  35. ls *.wmv 2>/dev/null >> $listname
  36. ls *.WMV 2>/dev/null >> $listname
  37. ls *.m4v 2>/dev/null >> $listname
  38. ls *.M4A 2>/dev/null >> $listname
  39. ls *.ts 2>/dev/null >> $listname
  40. ls *.TS 2>/dev/null >> $listname
  41. while read row; do
  42. echo $row
  43. echo bash "${CUR_DIR}"/rh265.sh $SERV $CRF "$row"
  44. done < $listname