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.

67 regels
1.4 KiB

  1. #!/bin/bash
  2. #
  3. # Concatenate media files
  4. #
  5. # Usage:
  6. #
  7. # jconcat out-file in-file-1 [in-file-2 ...]
  8. #
  9. # out-file : output file
  10. # in-file-N : input files
  11. #
  12. # BEWARE SHELL WILDCARDS!
  13. # Shell wildcards will match files in non-deterministic order, meaning that
  14. # your combined file will be assembled out of order.
  15. #
  16. # If you are combining files that were split with `jvc` (or `jsplit`), then
  17. # sorting them by time (oldest first) is sufficient.
  18. #
  19. # For example, do this:
  20. #
  21. # jconcat combined-file.mp4 $(ls -1tr path/to/parts*.mp4)
  22. #
  23. # NOT THIS:
  24. #
  25. # jconcat combined-file.mp4 path/to/parts*.mp4 # args not ordered!
  26. #
  27. SCRIPT="${0}"
  28. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  29. . "${SCRIPT_DIR}"/jvc_common
  30. OUT_FILE="${1?no out-file provided}"
  31. shift
  32. IN_FILE="${1?no in-file(s) provided}"
  33. echo "
  34. {
  35. \"assets\": [
  36. $(
  37. F_INDEX=0
  38. for path in "$@" ; do
  39. if [[ ${F_INDEX} -gt 0 ]] ; then
  40. echo ","
  41. fi
  42. F_INDEX=$((F_INDEX + 1))
  43. echo -n " { \"name\": \"input_${F_INDEX}\", \"path\": \"${path}\" }"
  44. shift
  45. done)
  46. ],
  47. \"operations\": [
  48. {
  49. \"operation\": \"concat\",
  50. \"creates\": {
  51. \"name\": \"combined\",
  52. \"dest\": \"${OUT_FILE}\"
  53. },
  54. \"sources\": [$(END=$#
  55. for ((i=1;i<=END;i++)); do
  56. if [[ ${i} -gt 1 ]] ; then echo -n "," ; fi
  57. echo -n "
  58. \"input_${i}\""
  59. done)
  60. ]
  61. }
  62. ]
  63. }
  64. " | "${SCRIPT_DIR}"/jvc -z ${JVC_OPTIONS}