Javicle - a JSON Video Composition Language
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

51 рядки
1.5 KiB

  1. #!/bin/bash
  2. #
  3. # Split a media file into multiple files of equal time length
  4. #
  5. # Usage:
  6. #
  7. # jsplit [-n|--no-exec] in-file out-dir interval [start] [end]
  8. #
  9. # -n or --no-exec : if set, do not execute ffmpeg but print what would have run
  10. # in-file : file to trim
  11. # out-dir : write split files to this directory (will be created if it does not exist)
  12. # interval : time duration of output files, in seconds
  13. # start : when to start splitting the in-file. default is 0 (start)
  14. # end : when to stop splitting the in-file. default is to continue until end of file is reached
  15. #
  16. SCRIPT="${0}"
  17. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  18. . "${SCRIPT_DIR}"/jvc_common
  19. IN_FILE="${1?no in-file provided}"
  20. OUT_DIR="${2?no out-dir provided}"
  21. if [[ -e "${OUT_DIR}" && ! -d "${OUT_DIR}" ]] ; then
  22. die "Not a directory: ${OUT_DIR}"
  23. fi
  24. mkdir -p "${OUT_DIR}" || die "Error creating ${OUT_DIR}"
  25. INTERVAL="${3?no interval provided}"
  26. T_START="${4}"
  27. T_END="${5}"
  28. echo "
  29. {
  30. \"assets\": [
  31. { \"name\": \"input\", \"path\": \"${IN_FILE}\" }
  32. ],
  33. \"operations\": [
  34. {
  35. \"operation\": \"split\",
  36. \"creates\": {
  37. \"name\": \"splits\",
  38. \"dest\": \"${OUT_DIR}/\"
  39. },
  40. \"source\": \"input\",
  41. \"interval\": \"${INTERVAL}\"$(if [[ -n "${T_START}" ]] ; then echo ",
  42. \"start\": \"${T_START}\"" ; fi)$(if [[ -n "${T_END}" ]] ; then echo ",
  43. \"end\": \"${T_END}\"," ; fi)
  44. }
  45. ]
  46. }
  47. " | "${SCRIPT_DIR}"/jvc ${JVC_OPTIONS}