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. # Merge an audio asset into the audio track of a video asset
  4. #
  5. # Usage:
  6. #
  7. # jmergeaudio [-n|--no-exec] video-file audio-file out-file [at]
  8. #
  9. # -n or --no-exec : if set, do not execute ffmpeg but print what would have run
  10. # video-file : input video file
  11. # audio-file : audio file to insert into video
  12. # out-file : write output file here
  13. # at : when (on the video timeline) to start playing the audio
  14. # If omitted, audio will start when video starts
  15. #
  16. SCRIPT="${0}"
  17. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  18. . "${SCRIPT_DIR}"/jvc_common
  19. VIDEO_FILE="${1?no video-file provided}"
  20. AUDIO_FILE="${2?no audio-file provided}"
  21. OUT_FILE="${3?no out-file provided}"
  22. T_START="${4}"
  23. echo "
  24. {
  25. \"assets\": [
  26. { \"name\": \"video_file\", \"path\": \"${VIDEO_FILE}\" },
  27. { \"name\": \"audio_file\", \"path\": \"${AUDIO_FILE}\" }
  28. ],
  29. \"operations\": [
  30. {
  31. \"operation\": \"merge-audio\",
  32. \"creates\": {
  33. \"name\": \"with_audio\",
  34. \"dest\": \"${OUT_FILE}\"
  35. },
  36. \"source\": \"video_file\",
  37. \"insert\": \"audio_file\"$(if [[ -n "${T_START}" ]] ; then echo ",
  38. \"at\": \"${T_START}\""; fi)
  39. }
  40. ]
  41. }
  42. " | "${SCRIPT_DIR}"/jvc ${JVC_OPTIONS}