Browse Source

add command help, add jtrim command

master
Jonathan Cobb 3 years ago
parent
commit
6194834138
3 changed files with 82 additions and 15 deletions
  1. +42
    -0
      bin/jtrim
  2. +4
    -15
      bin/jvcl
  3. +36
    -0
      bin/jvcl_common

+ 42
- 0
bin/jtrim View File

@@ -0,0 +1,42 @@
#!/bin/bash
#
# Trim a media file
#
# Usage:
#
# jtrim in-file out-file [start] [end]
#
# in-file : file to trim
# out-file : write trimmed file here
# start : seconds to trim from the beginning. if omitted, default value is start of the file
# end : retain the file until this number of seconds. if omitted, default is to end of file
#
SCRIPT="${0}"
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
. "${SCRIPT_DIR}"/jvcl_common

IN_FILE="${1?no in-file provided}"
OUT_FILE="${2?no out-file provided}"
T_START="${3}"
T_END="${4}"
echo "
{
\"assets\": [
{ \"name\": \"input\", \"path\": \"${IN_FILE}\" }
],
\"operations\": [
{
\"operation\": \"trim\",
\"creates\": {
\"name\": \"trimmed\",
\"dest\": \"${OUT_FILE}\"
},
\"perform\": {
\"trim\": \"input\",
\"start\": \"${T_START}\",
\"end\": \"${T_END}\"
}
}
]
}
" | "${SCRIPT_DIR}"/jvcl

+ 4
- 15
bin/jvcl View File

@@ -15,19 +15,8 @@
# Note: this command will build the jvcl jar file if needed. The first time you run it, it might
# take a long time to start up.
#
function die () {
echo 1>&2 "${1}"
exit 1
}
SCRIPT="${0}"
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
. "${SCRIPT_DIR}"/jvcl_common

JVCL_DIR="$(cd "$(dirname "${0}")"/.. && pwd)"
JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*.jar" | head -1)"
if [[ -z "${JVCL_JAR}" ]] ; then
mvn -DskipTests=true clean package || die "Error building JVCL jar"
JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*.jar" | head -1)"
if [[ -z "${JVCL_JAR}" ]] ; then
die "No JVCL jar file found after successful build"
fi
fi

java -cp "${JVCL_JAR}" jvcl.main.Jvcl "${@}"
java -cp "${JVCL_JAR}" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 jvcl.main.Jvcl "${@}"

+ 36
- 0
bin/jvcl_common View File

@@ -0,0 +1,36 @@
#!/bin/bash
function die () {
echo 1>&2 "${1}"
exit 1
}

function handle_help_request() {
if [[ -z "${2}" ]]; then
return
fi

if [[ ${2} == "-h" || ${2} == "--help" ]]; then
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ ${line} =~ ^#.* ]]; then
if [[ ! ${line} =~ ^#!/bin/bash.* ]]; then
echo "${line}"
fi
else
break
fi
done <"${1}"
exit 1
fi
}

JVCL_DIR="$(cd "$(dirname "${0}")"/.. && pwd)"
JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*-prod.jar" | head -1)"
if [[ -z "${JVCL_JAR}" ]] ; then
mvn -DskipTests=true -Puberjar clean package || die "Error building JVCL jar"
JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*-prod.jar" | head -1)"
if [[ -z "${JVCL_JAR}" ]] ; then
die "No JVCL jar file found after successful build"
fi
fi

handle_help_request "${0}" "${1}"

Loading…
Cancel
Save