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.

63 lines
2.0 KiB

  1. #!/bin/bash
  2. #
  3. # Apply zoom-pan effect to a still image to create a video
  4. #
  5. # Usage:
  6. #
  7. # jkenburns in-file out-file duration [zoom] [x] [y] [start] [end] [fps] [width] [height]
  8. #
  9. # in-file : file to trim
  10. # out-file : write scaled file here
  11. # duration : how long the output video will be
  12. # zoom : zoom factor, default is 1 (no zoom)
  13. # x : zoom focus X point, default is center
  14. # y : zoom focus Y point, default is center
  15. # start : when to start zooming, default is beginning of video
  16. # end : when to end zooming, default is end of video
  17. # fps : frame per second for output video, default is 25
  18. # width : output width, default is in-file width
  19. # height : output height, default is in-file height
  20. #
  21. SCRIPT="${0}"
  22. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  23. . "${SCRIPT_DIR}"/jvc_common
  24. IN_FILE="${1?no in-file provided}"
  25. OUT_FILE="${2?no out-file provided}"
  26. DURATION="${3:?no duration provided}"
  27. ZOOM="${4}"
  28. X_POS="${5}"
  29. Y_POS="${6}"
  30. T_START="${7}"
  31. T_END="${8}"
  32. FRAMES_PER_SEC="${9}"
  33. WIDTH="${10}"
  34. HEIGHT="${11}"
  35. echo "
  36. {
  37. \"assets\": [
  38. { \"name\": \"input\", \"path\": \"${IN_FILE}\" }
  39. ],
  40. \"operations\": [
  41. {
  42. \"operation\": \"ken-burns\",
  43. \"creates\": {
  44. \"name\": \"zoompan\",
  45. \"dest\": \"${OUT_FILE}\"
  46. },
  47. \"source\": \"input\",
  48. \"duration\": \"${DURATION}\"$(if [[ -n "${ZOOM}" ]] ; then echo ",
  49. \"zoom\": \"${ZOOM}\""; fi)$(if [[ -n "${X_POS}" ]] ; then echo ",
  50. \"x\": \"${X_POS}\""; fi)$(if [[ -n "${Y_POS}" ]] ; then echo ",
  51. \"y\": \"${Y_POS}\""; fi)$(if [[ -n "${T_START}" ]] ; then echo ",
  52. \"start\": \"${T_START}\""; fi)$(if [[ -n "${T_END}" ]] ; then echo ",
  53. \"end\": \"${T_END}\""; fi)$(if [[ -n "${FRAMES_PER_SEC}" ]] ; then echo ",
  54. \"fps\": \"${FRAMES_PER_SEC}\""; fi)$(if [[ -n "${WIDTH}" ]] ; then echo ",
  55. \"width\": \"${WIDTH}\""; fi)$(if [[ -n "${HEIGHT}" ]] ; then echo ",
  56. \"height\": \"${HEIGHT}\""; fi)
  57. }
  58. ]
  59. }
  60. " | "${SCRIPT_DIR}"/jvc ${JVC_OPTIONS}