From a7356d9c051c6d53ea294aef88154c5e21c39e80 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Wed, 16 Nov 2022 12:06:54 -0500 Subject: [PATCH 1/9] support a text list of files as input similar to a directory input --- astataudit | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/astataudit b/astataudit index 6800079..6ce8963 100755 --- a/astataudit +++ b/astataudit @@ -9,11 +9,13 @@ Provide visual and information reporting on audio files. Usage: ${THIS_NAME} [options] file1.wav [file2.wav ...] or + ${THIS_NAME} [options] list_of_wave_filepaths_to_process.txt + or ${THIS_NAME} [options] directory/ -The input can be a list of files or a directory of audio files. If the input is -a directory, then ${THIS_NAME} will review all audio files immediately within -that directory. +The input can be a list of files, a text document that contains a list of files +or a directory of audio files. If the input is a directory, then ${THIS_NAME} +will review all audio files immediately within that directory. Options: By analyzing audio files, ${THIS_NAME} will provide the following outputs. @@ -697,7 +699,9 @@ CSV_ROW="" INPUT="$1" FFPROBE_SETTINGS=(-of xml=x=1:q=1 -noprivate -show_format -show_streams -show_chapters) NOW="$(_get_iso8601_c)" -if [[ -f "${INPUT}" ]] ; then +INPUT_EXT="${INPUT##*.}" + +if [[ -f "${INPUT}" && "${INPUT_EXT}" != "txt" ]] ; then _report -d "${THIS_NAME} will process this list of files: ${@}" OUTPUT_CSV="astatsaudit_${NOW}.csv" while [[ "${@}" != "" ]] ; do @@ -722,7 +726,7 @@ if [[ -f "${INPUT}" ]] ; then fi shift done -elif [[ -d "${INPUT}" ]] ; then +elif [[ -d "${INPUT}" || ( -f "${INPUT}" && "${INPUT_EXT}" == "txt" ) ]] ; then if [[ -n "${SET_OUTPUT_DIR}" ]] ; then OUTPUT_DIR="${SET_OUTPUT_DIR}" else @@ -739,6 +743,7 @@ elif [[ -d "${INPUT}" ]] ; then OUTPUT_XML="${OUTPUT_DIR}/astatsaudit_${NOW}.xml" OUTPUT_CSV="${OUTPUT_DIR}/astatsaudit_${NOW}.csv" echo "" > "${FILES_XML_TMP}" + if [[ -d "${INPUT}" ]] ; then while read FILE ; do IS_AUDIO="$(ffprobe "${FFMPEG_VERBOSE[@]}" -v 0 "${FILE}" -show_entries stream=codec_type -select_streams a:0 -of default=nk=1:nw=1)" if [[ "${IS_AUDIO}" = "audio" ]] ; then @@ -748,6 +753,17 @@ elif [[ -d "${INPUT}" ]] ; then _report -d "Skipping: ${FILE} (no audio stream found)" fi done < <(find "${INPUT}" -maxdepth 1 -type f ! -name ".*") + else + while read FILE ; do + IS_AUDIO="$(ffprobe "${FFMPEG_VERBOSE[@]}" -v 0 "${FILE}" -show_entries stream=codec_type -select_streams a:0 -of default=nk=1:nw=1)" + if [[ "${IS_AUDIO}" = "audio" ]] ; then + _process_file -o "${OUTPUT_DIR}" "${FILE}" + ((FILE_NUMBER++)) + else + _report -d "Skipping: ${FILE} (no audio stream found)" + fi + done < "${INPUT}" + fi echo "" >> "${FILES_XML_TMP}" if [[ "${XML_OUTPUT}" = "y" ]] ; then _finish_xml "${FILES_XML_TMP}" > "${OUTPUT_XML}" From ef7fbd124872d197f7d5fdbbee59d258f139059b Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Wed, 16 Nov 2022 12:07:19 -0500 Subject: [PATCH 2/9] indent after previous --- astataudit | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/astataudit b/astataudit index 6ce8963..7ddab76 100755 --- a/astataudit +++ b/astataudit @@ -744,15 +744,15 @@ elif [[ -d "${INPUT}" || ( -f "${INPUT}" && "${INPUT_EXT}" == "txt" ) ]] ; then OUTPUT_CSV="${OUTPUT_DIR}/astatsaudit_${NOW}.csv" echo "" > "${FILES_XML_TMP}" if [[ -d "${INPUT}" ]] ; then - while read FILE ; do - IS_AUDIO="$(ffprobe "${FFMPEG_VERBOSE[@]}" -v 0 "${FILE}" -show_entries stream=codec_type -select_streams a:0 -of default=nk=1:nw=1)" - if [[ "${IS_AUDIO}" = "audio" ]] ; then - _process_file -o "${OUTPUT_DIR}" "${FILE}" - ((FILE_NUMBER++)) - else - _report -d "Skipping: ${FILE} (no audio stream found)" - fi - done < <(find "${INPUT}" -maxdepth 1 -type f ! -name ".*") + while read FILE ; do + IS_AUDIO="$(ffprobe "${FFMPEG_VERBOSE[@]}" -v 0 "${FILE}" -show_entries stream=codec_type -select_streams a:0 -of default=nk=1:nw=1)" + if [[ "${IS_AUDIO}" = "audio" ]] ; then + _process_file -o "${OUTPUT_DIR}" "${FILE}" + ((FILE_NUMBER++)) + else + _report -d "Skipping: ${FILE} (no audio stream found)" + fi + done < <(find "${INPUT}" -maxdepth 1 -type f ! -name ".*") else while read FILE ; do IS_AUDIO="$(ffprobe "${FFMPEG_VERBOSE[@]}" -v 0 "${FILE}" -show_entries stream=codec_type -select_streams a:0 -of default=nk=1:nw=1)" From ebb2270db7be5fa0f32efaa0fb4bc274aab009dd Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 09:58:02 -0500 Subject: [PATCH 3/9] use numerical comparison --- astataudit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astataudit b/astataudit index 7ddab76..c3d7c14 100755 --- a/astataudit +++ b/astataudit @@ -207,7 +207,7 @@ _flat_ffprobe_parse(){ KEY="${2}" VALUE="$(grep "^${KEY}=" "${FFPROBE_DOC}" | cut -d "=" -f2- | sed -e 's/^"//' -e 's/"$//')" VALUE_LINE_COUNT="$(echo -n "${VALUE}" | grep -c '^')" - if [[ "${VALUE_LINE_COUNT}" > 1 ]] ; then + if [[ "${VALUE_LINE_COUNT}" -gt 1 ]] ; then _report -w "The parsed value for '${KEY}' is in ${VALUE_LINE_COUNT} lines, which may be unintended" fi echo -n "${VALUE}" @@ -229,7 +229,7 @@ _astats_parse(){ VALUE="$(grep "${FILTER_PREFIX}" "${ASTATS_DOC}" | sed -n "s/Overall$/Channel: X/g;/Channel: ${SECTION}/,/Channel/p" | grep "] ${KEY}:" | cut -d : -f2- | sed 's/ //g')" fi VALUE_LINE_COUNT="$(echo -n "${VALUE}" | grep -c '^')" - if [[ "${VALUE_LINE_COUNT}" > 1 ]] ; then + if [[ "${VALUE_LINE_COUNT}" -gt 1 ]] ; then _report -w "The parsed value for '${KEY}' is in ${VALUE_LINE_COUNT} lines, which may be unintended" fi echo -n "${VALUE}" From f2334fb9d1945744062617a0966a7e7389444bce Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 09:58:16 -0500 Subject: [PATCH 4/9] correct order of argument processing --- astataudit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astataudit b/astataudit index c3d7c14..b8d986c 100755 --- a/astataudit +++ b/astataudit @@ -489,8 +489,8 @@ _make_astats_csv(){ while getopts "o:" opt ; do case "${opt}" in o) OUTPUT_DIR="${OPTARG}" ;; - *) echo "bad option -${OPTARG}" ; _usage ; exit 1 ;; :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; + *) echo "bad option -${OPTARG}" ; _usage ; exit 1 ;; esac done shift "$((OPTIND-1))" @@ -640,8 +640,8 @@ _process_file(){ while getopts "o:" opt ; do case "${opt}" in o) OUTPUT_DIR="${OPTARG}" ;; - *) echo "bad option -${OPTARG}" ; _usage ; exit 1 ;; :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; + *) echo "bad option -${OPTARG}" ; _usage ; exit 1 ;; esac done shift "$((OPTIND-1))" From 05184b6ae05b36dc5baa13e2e847c1dacfe962a1 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 09:58:22 -0500 Subject: [PATCH 5/9] removed unused variable --- astataudit | 1 - 1 file changed, 1 deletion(-) diff --git a/astataudit b/astataudit index b8d986c..44749e8 100755 --- a/astataudit +++ b/astataudit @@ -539,7 +539,6 @@ _make_graph(){ DRAWGRAPH_SETTINGS="bg=Black" BORDER_COLOR="LightGrey" HORIZONTAL_MARKINGS_240="drawgrid=thickness=1:color=${BORDER_COLOR}@0.2:height=ih/16,drawgrid=thickness=1:color=${BORDER_COLOR}@0.5:height=ih/4,drawgrid=thickness=1:color=${BORDER_COLOR}@0.8:height=ih/2" - HORIZONTAL_MARKINGS_120="drawgrid=thickness=1:color=${BORDER_COLOR}@0.2:height=ih/8,drawgrid=thickness=1:color=${BORDER_COLOR}@0.5:height=ih/4,drawgrid=thickness=1:color=${BORDER_COLOR}@0.8:height=ih/2" GRAPH_W=6000 AUDIO_FRAME_SIZE="$(echo "((${DURATION}*${AUDIO_SAMPLE_RATE})/${GRAPH_W})+1" | bc)" # adding 0.5 in the above equation to ensure that the result is rounded to the nearest integer, rather than simply rounded down From 4bc596da05eb7cb1285207ed7381526e3c4b6b89 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 13:32:45 -0500 Subject: [PATCH 6/9] add asubcut before aphasemeter in png creation --- astataudit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astataudit b/astataudit index 44749e8..08abb69 100755 --- a/astataudit +++ b/astataudit @@ -601,7 +601,7 @@ _make_graph(){ min=-0.01:max=0.01: slide=picture: s=${GRAPH_W}x${GRAPH_H},${HORIZONTAL_MARKINGS_240}[dcoff1]; - [l]${AUDIOFORMAT},aphasemeter=video=0, + [l]${AUDIOFORMAT},asubcut=order=6:cutoff=25,aphasemeter=video=0, adrawgraph=${DRAWGRAPH_SETTINGS}: m1=lavfi.aphasemeter.phase:fg1=if(gte(VAL\,0.9)\,0xFF00FF00\,if(gte(VAL\,0)\,0xFF00FFFF\,if(gte(VAL\,-0.5)\,0xFF0096FF\,0xFF0000FF))): max=1:min=-1: From 79b05488e48cff00c935939bea661c36c050068f Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 13:35:12 -0500 Subject: [PATCH 7/9] remember xmlstarlet location and call by path --- astataudit | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/astataudit b/astataudit index 08abb69..6b9abe5 100755 --- a/astataudit +++ b/astataudit @@ -179,7 +179,7 @@ _find_a_font(){ _finish_xml(){ INVENTORY_XML="${1}" _report -d "Finalizing xml output at ${INVENTORY_XML}" - xmlstarlet select \ + "${XMLSTARLET_PATH}" select \ -N "rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#" \ -N "asa=https://github.com/amiaopensource/astatsaudit" \ -N "ffprobe=http://www.ffmpeg.org/schema/ffprobe" \ @@ -199,7 +199,7 @@ _finish_xml(){ --elem "astats:report" --copy-of "document(@astats)/astats/text()" -b \ --elem "bwfme:fullReport" \ --copy-of "document(@bwf)/*" \ - "${INVENTORY_XML}" | xmlstarlet fo + "${INVENTORY_XML}" | "${XMLSTARLET_PATH}" fo } _flat_ffprobe_parse(){ @@ -689,6 +689,7 @@ _process_file(){ } _check_dependencies bwfmetaedit ffmpeg ffprobe bc xmlstarlet +XMLSTARLET_PATH="$(which xmlstarlet)" _find_a_font FILE_NUMBER="0" From 6ce0168fba114da2775be4092fceb7dc765f59ca Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 13:47:26 -0500 Subject: [PATCH 8/9] let phase = 1 to be viewable --- astataudit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astataudit b/astataudit index 6b9abe5..e21e459 100755 --- a/astataudit +++ b/astataudit @@ -604,7 +604,7 @@ _make_graph(){ [l]${AUDIOFORMAT},asubcut=order=6:cutoff=25,aphasemeter=video=0, adrawgraph=${DRAWGRAPH_SETTINGS}: m1=lavfi.aphasemeter.phase:fg1=if(gte(VAL\,0.9)\,0xFF00FF00\,if(gte(VAL\,0)\,0xFF00FFFF\,if(gte(VAL\,-0.5)\,0xFF0096FF\,0xFF0000FF))): - max=1:min=-1: + max=1.01:min=-1: slide=picture: s=${GRAPH_W}x${GRAPH_H},${HORIZONTAL_MARKINGS_240}[phase1]; [Header] From 4e15bbc17d36a0f362149401f2f455fcb5871318 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sat, 19 Nov 2022 13:49:25 -0500 Subject: [PATCH 9/9] display bit depth overall again and change its location --- astataudit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astataudit b/astataudit index e21e459..40a97c7 100755 --- a/astataudit +++ b/astataudit @@ -358,7 +358,6 @@ _get_csv_row(){ _add_column -f ffprobe streams stream.0.codec_name _add_column -f astats 1 "Bit depth" _add_column -f astats 2 "Bit depth" - _add_column -f astats Overall "Bit depth" _add_column -f astats 1 "Crest factor" _add_column -f astats 2 "Crest factor" _add_column -P astats 1 "DC offset" @@ -429,6 +428,7 @@ _get_csv_row(){ _add_column bwfmetaedit Tech SampleRate _add_column bwfmetaedit Tech BitRate _add_column bwfmetaedit Tech BitPerSample + _add_column astats Overall "Bit depth" _add_column bwfmetaedit Tech Duration _add_column bwfmetaedit Tech UnsupportedChunks _add_column bwfmetaedit Tech bext