Javicle - a JSON Video Composition Language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.4 KiB

  1. #!/bin/bash
  2. #
  3. # Scale a media file
  4. #
  5. # Usage:
  6. #
  7. # jscale [-n|--no-exec] in-file out-file factor
  8. # or
  9. # jscale [-n|--no-exec] in-file out-file width height
  10. #
  11. # -n or --no-exec : if set, do not execute ffmpeg but print what would have run
  12. # in-file : file to trim
  13. # out-file : write scaled file here
  14. # factor : scale factor
  15. # width : output width
  16. # height : output height
  17. #
  18. SCRIPT="${0}"
  19. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  20. . "${SCRIPT_DIR}"/jvc_common
  21. IN_FILE="${1?no in-file provided}"
  22. OUT_FILE="${2?no out-file provided}"
  23. WIDTH="${3}"
  24. HEIGHT="${4}"
  25. FACTOR=""
  26. if [[ -z "${HEIGHT}" ]] ; then
  27. FACTOR=${WIDTH}
  28. echo "
  29. {
  30. \"assets\": [
  31. { \"name\": \"input\", \"path\": \"${IN_FILE}\" }
  32. ],
  33. \"operations\": [
  34. {
  35. \"operation\": \"scale\",
  36. \"creates\": {
  37. \"name\": \"scaled\",
  38. \"dest\": \"${OUT_FILE}\"
  39. },
  40. \"source\": \"input\",
  41. \"factor\": \"${FACTOR}\"
  42. }
  43. ]
  44. }
  45. " | "${SCRIPT_DIR}"/jvc ${JVC_OPTIONS}
  46. else
  47. echo "
  48. {
  49. \"assets\": [
  50. { \"name\": \"input\", \"path\": \"${IN_FILE}\" }
  51. ],
  52. \"operations\": [
  53. {
  54. \"operation\": \"scale\",
  55. \"creates\": {
  56. \"name\": \"scaled\",
  57. \"dest\": \"${OUT_FILE}\"
  58. },
  59. \"source\": \"input\",
  60. \"width\": \"${WIDTH}\",
  61. \"height\": \"${HEIGHT}\"
  62. }
  63. ]
  64. }
  65. " | "${SCRIPT_DIR}"/jvc ${JVC_OPTIONS}
  66. fi