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.

45 lines
1.2 KiB

  1. #!/bin/bash
  2. #
  3. # Adjust the speed of a video, optionally adjusting the audio as well.
  4. #
  5. # Usage:
  6. #
  7. # jspeed [-n|--no-exec] in-file out-file speed-factor [audio-speed]
  8. #
  9. # -n or --no-exec : if set, do not execute ffmpeg but print what would have run
  10. # in-file : input video file
  11. # out-file : write output file here
  12. # speed-factor : factor=1 is unchanged, factor>1 is faster, factor<1 is slower
  13. # audio-speed : can be: silent (default), unchanged, or match
  14. #
  15. # Note: if audio-speed is match, then speed-factor must be between 0.5 and 100
  16. #
  17. SCRIPT="${0}"
  18. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  19. . "${SCRIPT_DIR}"/jvc_common
  20. IN_FILE="${1?no video-file provided}"
  21. OUT_FILE="${2?no out-file provided}"
  22. SPEED_FACTOR="${3?no speed-factor provided}"
  23. AUDIO_SPEED="${4}"
  24. echo "
  25. {
  26. \"assets\": [
  27. { \"name\": \"input\", \"path\": \"${IN_FILE}\" }
  28. ],
  29. \"operations\": [
  30. {
  31. \"operation\": \"adjust-speed\",
  32. \"creates\": {
  33. \"name\": \"speed_adjusted\",
  34. \"dest\": \"${OUT_FILE}\"
  35. },
  36. \"source\": \"input\",
  37. \"factor\": \"${SPEED_FACTOR}\"$(if [[ -n "${AUDIO_SPEED}" ]] ; then echo ",
  38. \"audio\": \"${AUDIO_SPEED}\"" ; fi)
  39. }
  40. ]
  41. }
  42. " | "${SCRIPT_DIR}"/jvc ${JVC_OPTIONS}