fixing encoding timing errors and restoring spx - why not
This commit is contained in:
parent
6f3c6c2596
commit
dd97a672aa
@ -22,9 +22,12 @@ piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/lessac/medium/en_US-less
|
|||||||
|
|
||||||
working_dir_bypass="false"
|
working_dir_bypass="false"
|
||||||
skip_post_show="false"
|
skip_post_show="false"
|
||||||
|
skip_media_encoding="false"
|
||||||
|
|
||||||
acceptable_duration_difference="2" # Seconds
|
acceptable_duration_difference="2" # Seconds
|
||||||
unsafe_episode_variables=( shownotes_json shownotes_html hostid artist email title summary series_id series_name explicit license ep_date ep_num tags host_license host_profile remote_media shownotes_json_sanatised )
|
unsafe_episode_variables=( shownotes_json shownotes_html hostid artist email title summary series_id series_name explicit license ep_date ep_num tags host_license host_profile remote_media shownotes_json_sanatised )
|
||||||
audio_formats=( flac wav mp3 ogg opus spx )
|
audio_formats=( flac wav mp3 ogg opus spx )
|
||||||
|
episode_formats=( flac wav mp3 ogg opus spx srt txt )
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Display Error message, display help and exit
|
# Display Error message, display help and exit
|
||||||
@ -133,7 +136,6 @@ function argument_override() {
|
|||||||
if [ "${this_key}" == "working_dir" ]
|
if [ "${this_key}" == "working_dir" ]
|
||||||
then
|
then
|
||||||
working_dir_bypass="true"
|
working_dir_bypass="true"
|
||||||
set_working_processing_dir
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -174,6 +176,10 @@ function check_variable_is_correct() {
|
|||||||
then
|
then
|
||||||
echo_error "The \"assets_csv\" variable has not a valid \"text/csv\" mime type."
|
echo_error "The \"assets_csv\" variable has not a valid \"text/csv\" mime type."
|
||||||
fi
|
fi
|
||||||
|
if [ "$( wc --lines ${assets_csv} | awk '{print $1}' )" -le "1" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"${assets_csv}\" file is empty."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
assets_json)
|
assets_json)
|
||||||
if [[ ! -s "${assets_json}" || -z "${assets_json}" ]]
|
if [[ ! -s "${assets_json}" || -z "${assets_json}" ]]
|
||||||
@ -230,6 +236,72 @@ function check_variable_is_correct() {
|
|||||||
echo_error "The \"email_unpadded\" variable is missing."
|
echo_error "The \"email_unpadded\" variable is missing."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
episode_body_flac)
|
||||||
|
if [ -z "${episode_body_flac}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_body_flac\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_body_srt)
|
||||||
|
if [ -z "${episode_body_srt}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_body_srt\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_final_flac)
|
||||||
|
if [ -z "${episode_final_flac}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_final_flac\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_intro_flac)
|
||||||
|
if [ -z "${episode_intro_flac}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_intro_flac\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_intro_srt)
|
||||||
|
if [ -z "${episode_intro_srt}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_intro_srt\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_outro_srt)
|
||||||
|
if [ -z "${episode_outro_srt}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_outro_srt\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_sandwitch_flac)
|
||||||
|
if [ -z "${episode_sandwitch_flac}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_sandwitch_flac\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_srt)
|
||||||
|
if [ -z "${episode_srt}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_srt\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_summary_flac)
|
||||||
|
if [ -z "${episode_summary_flac}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_summary_flac\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_tts_flac)
|
||||||
|
if [ -z "${episode_tts_flac}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_tts_flac\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
episode_tts_wav)
|
||||||
|
if [ -z "${episode_tts_wav}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"episode_tts_wav\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
episode_summary_json)
|
episode_summary_json)
|
||||||
if [[ ! -s "${episode_summary_json}" || -z "${episode_summary_json}" ]]
|
if [[ ! -s "${episode_summary_json}" || -z "${episode_summary_json}" ]]
|
||||||
then
|
then
|
||||||
@ -261,6 +333,12 @@ function check_variable_is_correct() {
|
|||||||
echo_error "The \"ep_num\" variable is not a valid number between 1 and 9999."
|
echo_error "The \"ep_num\" variable is not a valid number between 1 and 9999."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
expected_duration)
|
||||||
|
if [ -z "${expected_duration}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"expected_duration\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
explicit)
|
explicit)
|
||||||
if [[ -z "${explicit}" || "${explicit}" == "null" ]]
|
if [[ -z "${explicit}" || "${explicit}" == "null" ]]
|
||||||
then
|
then
|
||||||
@ -315,6 +393,12 @@ function check_variable_is_correct() {
|
|||||||
echo_error "The \"hostid\" variable is missing."
|
echo_error "The \"hostid\" variable is missing."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
intro_duration)
|
||||||
|
if [ -z "${intro_duration}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"intro_duration\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
intro_srt)
|
intro_srt)
|
||||||
if [[ ! -d "${intro_srt}" || -z "${intro_srt}" ]]
|
if [[ ! -d "${intro_srt}" || -z "${intro_srt}" ]]
|
||||||
then
|
then
|
||||||
@ -346,11 +430,35 @@ function check_variable_is_correct() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
media_basename)
|
media_basename)
|
||||||
if [[ ! -d "${media_basename}" || -z "${media_basename}" ]]
|
if [[ ! -s "${media_basename}" || -z "${media_basename}" ]]
|
||||||
then
|
then
|
||||||
echo_error "The \"media_basename\" variable is missing or is not a directory."
|
echo_error "The \"media_basename\" variable is missing or is not a directory."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
media_ffprobe)
|
||||||
|
if [ -z "${media_ffprobe}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"media_ffprobe\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
media_file_mime)
|
||||||
|
if [ -z "${media_file_mime}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"media_file_mime\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
media_file_mime_type)
|
||||||
|
if [ -z "${media_file_mime_type}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"media_file_mime_type\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
outro_duration)
|
||||||
|
if [ -z "${outro_duration}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"outro_duration\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
outro_flac)
|
outro_flac)
|
||||||
if [[ ! -s "${outro_flac}" || -z "${outro_flac}" ]]
|
if [[ ! -s "${outro_flac}" || -z "${outro_flac}" ]]
|
||||||
then
|
then
|
||||||
@ -422,6 +530,12 @@ function check_variable_is_correct() {
|
|||||||
echo_error "The \"silence\" variable is missing or file \"${silence}\" does not exist."
|
echo_error "The \"silence\" variable is missing or file \"${silence}\" does not exist."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
source_duration)
|
||||||
|
if [ -z "${source_duration}" ]
|
||||||
|
then
|
||||||
|
echo_error "The \"source_duration\" variable is missing."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
summary)
|
summary)
|
||||||
if [[ -z "${summary}" || "${summary}" == "null" ]]
|
if [[ -z "${summary}" || "${summary}" == "null" ]]
|
||||||
then
|
then
|
||||||
@ -470,12 +584,6 @@ function check_variable_is_correct() {
|
|||||||
echo_error "The \"working_dir\" variable is missing or is not a directory."
|
echo_error "The \"working_dir\" variable is missing or is not a directory."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
working_processing_dir)
|
|
||||||
if [[ ! -d "${working_processing_dir}" || -z "${working_processing_dir}" ]]
|
|
||||||
then
|
|
||||||
echo_error "The \"working_processing_dir\" variable is missing or is not a directory."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
year)
|
year)
|
||||||
if [[ -z "${year}" || "${year}" == "null" ]]
|
if [[ -z "${year}" || "${year}" == "null" ]]
|
||||||
then
|
then
|
||||||
@ -538,16 +646,7 @@ function get_next_show_from_hpr_hub() {
|
|||||||
ssh hpr -t "detox -v ${hpr_upload_dir}/"
|
ssh hpr -t "detox -v ${hpr_upload_dir}/"
|
||||||
rsync -ave ssh --partial --progress ${source_dir}/ ${working_dir}/
|
rsync -ave ssh --partial --progress ${source_dir}/ ${working_dir}/
|
||||||
|
|
||||||
|
check_variable_is_correct shownotes_json
|
||||||
if [ ! -s "${working_dir}/shownotes.json" ]
|
|
||||||
then
|
|
||||||
echo_error "The working dir is missing the shownotes file \"${working_dir}/shownotes.json\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$( file --brief --mime-type "${working_dir}/shownotes.json" | grep --count "application/json" )" -eq 0 ]
|
|
||||||
then
|
|
||||||
echo_error "The \"${working_dir}/shownotes.json\" is not a \"application/json\" file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +659,7 @@ function get_ep_num_from_local_dir() {
|
|||||||
|
|
||||||
check_variable_is_correct working_dir
|
check_variable_is_correct working_dir
|
||||||
|
|
||||||
if [ ! -s "${working_dir}/shownotes.json" ]
|
if [ ! -s "${shownotes_json}" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
echo_debug "Could not find a \"shownotes.json\" in the working directory \"${working_dir}/\""
|
echo_debug "Could not find a \"shownotes.json\" in the working directory \"${working_dir}/\""
|
||||||
@ -578,22 +677,19 @@ function get_ep_num_from_local_dir() {
|
|||||||
|
|
||||||
echo_debug "Attempting to download information for episode \"${ep_num}\""
|
echo_debug "Attempting to download information for episode \"${ep_num}\""
|
||||||
|
|
||||||
if [ "$( curl --silent --netrc-file ${HOME}/.netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/shownotes.php?id=${ep_num} --output "${working_dir}/shownotes.json" )" != 200 ]
|
if [ "$( curl --silent --netrc-file ${HOME}/.netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/shownotes.php?id=${ep_num} --output "${shownotes_json}" )" != 200 ]
|
||||||
then
|
then
|
||||||
echo_error "The Episode hpr${ep_num} has not been posted."
|
echo_error "The Episode hpr${ep_num} has not been posted."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s "${working_dir}/shownotes.json" ]
|
if [ ! -s "${shownotes_json}" ]
|
||||||
then
|
then
|
||||||
echo_error "The Episode information for hpr${ep_num} failed to download."
|
echo_error "The Episode information for hpr${ep_num} failed to download."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -s "${working_dir}/shownotes.json" && "$( file --brief --mime-type "${working_dir}/shownotes.json" | grep --count "application/json" )" -eq 0 ]]
|
check_variable_is_correct shownotes_json
|
||||||
then
|
|
||||||
echo_error "\"${working_dir}/shownotes.json\" is not a \"application/json\" file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,32 +714,34 @@ function get_working_dir() {
|
|||||||
check_variable_is_correct ep_num
|
check_variable_is_correct ep_num
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s "${working_dir}/shownotes.json" ]
|
|
||||||
then
|
|
||||||
echo_error "The working dir \"${working_dir}\" could not be found."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo_debug "Found working directory as \"${working_dir}\""
|
echo_debug "Found working directory as \"${working_dir}\""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Create a sub dir to store technical data.
|
# Once the working_dir is known, set the other variables
|
||||||
|
|
||||||
function set_working_processing_dir() {
|
function set_working_dir_variables() {
|
||||||
|
|
||||||
echo_debug "Checking the processing directory in the current working directory. set_working_processing_dir()"
|
echo_debug "Setting the other working directory and variables. set_working_dir_variables()"
|
||||||
|
|
||||||
check_variable_is_correct working_dir
|
check_variable_is_correct working_dir
|
||||||
|
|
||||||
working_processing_dir="${working_dir}/processing"
|
shownotes_json="${working_dir}/shownotes.json"
|
||||||
|
shownotes_html="${working_dir}/shownotes.html"
|
||||||
if [ ! -d "${working_processing_dir}/" ]
|
shownotes_edited="${working_dir}/shownotes_edited.html"
|
||||||
then
|
episode_tts_wav="${working_dir}/episode_tts.wav"
|
||||||
mkdir -v "${working_processing_dir}/"
|
episode_tts_flac="${working_dir}/episode_tts.flac"
|
||||||
fi
|
episode_summary_flac="${working_dir}/episode_summary.flac"
|
||||||
|
episode_intro_flac="${working_dir}/episode_intro.flac"
|
||||||
check_variable_is_correct working_processing_dir
|
episode_body_flac="${working_dir}/episode_body.flac"
|
||||||
|
episode_sandwitch_flac="${working_dir}/episode_sandwitch.flac"
|
||||||
|
episode_final_flac="${working_dir}/episode_final.flac"
|
||||||
|
episode_intro_srt="${working_dir}/episode_intro.srt"
|
||||||
|
episode_body_srt="${working_dir}/episode_body.srt"
|
||||||
|
episode_outro_srt="${working_dir}/episode_outro.srt"
|
||||||
|
episode_srt="${working_dir}/episode.srt"
|
||||||
}
|
}
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
@ -659,16 +757,9 @@ function get_episode_metadata() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_variable_is_correct working_dir
|
check_variable_is_correct working_dir shownotes_json
|
||||||
|
|
||||||
if [[ -s "${working_dir}/shownotes.json" && "$( file --brief --mime-type "${working_dir}/shownotes.json" | grep --count "application/json" )" -eq 0 ]]
|
set_working_dir_variables
|
||||||
then
|
|
||||||
echo_error "\"${working_dir}/shownotes.json\" is not a \"application/json\" file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
shownotes_json="${working_dir}/shownotes.json"
|
|
||||||
shownotes_html="${working_dir}/shownotes.html"
|
|
||||||
shownotes_edited="${working_dir}/shownotes_edited.html"
|
|
||||||
|
|
||||||
check_variable_is_correct shownotes_json
|
check_variable_is_correct shownotes_json
|
||||||
|
|
||||||
@ -884,7 +975,7 @@ function media_checks() {
|
|||||||
|
|
||||||
echo_debug "Running media checks. media_checks()"
|
echo_debug "Running media checks. media_checks()"
|
||||||
|
|
||||||
check_variable_is_correct working_dir working_processing_dir
|
check_variable_is_correct working_dir
|
||||||
|
|
||||||
if [[ -n "${remote_media}" && "${remote_media}" != "null" ]]
|
if [[ -n "${remote_media}" && "${remote_media}" != "null" ]]
|
||||||
then
|
then
|
||||||
@ -912,13 +1003,21 @@ function media_checks() {
|
|||||||
if [ "$( echo "${media}" | wc --lines )" -ne 1 ]
|
if [ "$( echo "${media}" | wc --lines )" -ne 1 ]
|
||||||
then
|
then
|
||||||
echo "Multiple files found. Which one do you want to use ?"
|
echo "Multiple files found. Which one do you want to use ?"
|
||||||
select this_media in $( echo "${media}" )
|
select this_media in "Skip asset creation" $( echo "${media}" )
|
||||||
do
|
do
|
||||||
|
if [ "${this_media}" == "Skip asset creation" ]
|
||||||
|
then
|
||||||
|
echo_debug "Skip asset creation"
|
||||||
|
check_derived_assets
|
||||||
|
skip_media_encoding="true"
|
||||||
|
return
|
||||||
|
fi
|
||||||
ls -al "${this_media}"
|
ls -al "${this_media}"
|
||||||
media="${this_media}"
|
media="${this_media}"
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo_debug "You selected \"${media}\"."
|
echo_debug "You selected \"${media}\"."
|
||||||
|
|
||||||
if [[ -z "${media}" || ! -s "${media}" ]]
|
if [[ -z "${media}" || ! -s "${media}" ]]
|
||||||
@ -955,32 +1054,28 @@ function media_checks() {
|
|||||||
echo_debug "The number of audio channels is \"${supplied_channels}\" from \"${media}\" ."
|
echo_debug "The number of audio channels is \"${supplied_channels}\" from \"${media}\" ."
|
||||||
|
|
||||||
# Gernerate the Spectrum and Waveform image
|
# Gernerate the Spectrum and Waveform image
|
||||||
ffmpeg -hide_banner -loglevel error -y -i "${media}" -lavfi "showspectrumpic=s=960x540" "${working_processing_dir}/${media_basename%.*}_spectrum.png"
|
ffmpeg -hide_banner -loglevel error -y -i "${media}" -lavfi "showspectrumpic=s=960x540" "${working_dir}/${media_basename%.*}_spectrum.png"
|
||||||
audio2image.bash "${media}" && mv -v "${media%.*}.png" "${working_processing_dir}/${media_basename%.*}_waveform.png"
|
audio2image.bash "${media}" && mv -v "${media%.*}.png" "${working_dir}/${media_basename%.*}_waveform.png"
|
||||||
|
|
||||||
# Getting metadata
|
# Getting metadata
|
||||||
|
|
||||||
mediainfo "${media}" > "${working_processing_dir}/${media_basename%.*}_mediainfo.txt"
|
mediainfo "${media}" > "${working_dir}/${media_basename%.*}_mediainfo.txt"
|
||||||
|
|
||||||
exiftool "${media}" > "${working_processing_dir}/${media_basename%.*}_exiftool.txt"
|
exiftool "${media}" > "${working_dir}/${media_basename%.*}_exiftool.txt"
|
||||||
|
|
||||||
for check_file in spectrum.png waveform.png mediainfo.txt exiftool.txt
|
for check_file in spectrum.png waveform.png mediainfo.txt exiftool.txt
|
||||||
do
|
do
|
||||||
if [ ! -s "${working_processing_dir}/${media_basename%.*}_${check_file}" ]
|
if [ ! -s "${working_dir}/${media_basename%.*}_${check_file}" ]
|
||||||
then
|
then
|
||||||
echo_error "The ${check_file} file was not generated for the \"${working_processing_dir}/${media_basename%.*}_${check_file}\"" >&2
|
echo_error "The ${check_file} file was not generated for the \"${working_dir}/${media_basename%.*}_${check_file}\"" >&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
ffprobe="$( ffprobe ${media} 2>&1 | grep Audio: | sed 's/^.\s//g' )"
|
media_ffprobe="$( ffprobe ${media} 2>&1 | grep Audio: | sed 's/^.\s//g' )"
|
||||||
file_mime="$( file --brief --mime ${media} )"
|
media_file_mime="$( file --brief --mime ${media} )"
|
||||||
file_mime_type="$( file --brief --mime-type ${media} )"
|
media_file_mime_type="$( file --brief --mime-type ${media} )"
|
||||||
|
|
||||||
if [[ -z "${ffprobe}" || -z ${file_mime} || -s ${file_mime_type} ]]
|
check_variable_is_correct media_ffprobe media_file_mime media_file_mime_type
|
||||||
then
|
|
||||||
echo "ffprobe: ${ffprobe}, file_mime: ${file_mime},file_mime_type: ${file_mime_type}"
|
|
||||||
echo_error "Wasn't able to find mime metadata from \"${media}/\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,11 +1086,11 @@ function generate_initial_report() {
|
|||||||
|
|
||||||
echo_debug "Generating the initial report. generate_initial_report()"
|
echo_debug "Generating the initial report. generate_initial_report()"
|
||||||
|
|
||||||
if [[ -n "${skip_post_show}" && "${skip_post_show}" == "true" ]]
|
# if [[ -n "${skip_post_show}" && "${skip_post_show}" == "true" ]]
|
||||||
then
|
# then
|
||||||
echo_debug "The Episode hpr${ep_num} has already been posted. Skipping generate_initial_report()"
|
# echo_debug "The Episode hpr${ep_num} has already been posted. Skipping generate_initial_report()"
|
||||||
return
|
# return
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
|
|
||||||
# TODO list the images.
|
# TODO list the images.
|
||||||
@ -1059,35 +1154,35 @@ ${shownotes_json_sanatised}
|
|||||||
<h3>mediainfo report</h3>
|
<h3>mediainfo report</h3>
|
||||||
<code>
|
<code>
|
||||||
<pre>
|
<pre>
|
||||||
$( cat "${working_processing_dir}/${media_basename%.*}_mediainfo.txt" )
|
$( cat "${working_dir}/${media_basename%.*}_mediainfo.txt" )
|
||||||
</pre>
|
</pre>
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
<h3>exiftool report</h3>
|
<h3>exiftool report</h3>
|
||||||
<code>
|
<code>
|
||||||
<pre>
|
<pre>
|
||||||
$( cat "${working_processing_dir}/${media_basename%.*}_exiftool.txt" )
|
$( cat "${working_dir}/${media_basename%.*}_exiftool.txt" )
|
||||||
</pre>
|
</pre>
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
<h3>Audio Spectrum</h3>
|
<h3>Audio Spectrum</h3>
|
||||||
<p>
|
<p>
|
||||||
<img src=\"${working_processing_dir}/${media_basename%.*}_spectrum.png\" alt=\"Spectrum\" />
|
<img src=\"${working_dir}/${media_basename%.*}_spectrum.png\" alt=\"Spectrum\" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Audio Waveform</h3>
|
<h3>Audio Waveform</h3>
|
||||||
<p>
|
<p>
|
||||||
<img src=\"${working_processing_dir}/${media_basename%.*}_waveform.png\" alt=\"Waveform\" />
|
<img src=\"${working_dir}/${media_basename%.*}_waveform.png\" alt=\"Waveform\" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
${ffprobe}
|
${media_ffprobe}
|
||||||
${file_mime}
|
${media_file_mime}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<audio controls=\"\" preload=\"none\" style=\"width:600px;\" >
|
<audio controls=\"\" preload=\"none\" style=\"width:600px;\" >
|
||||||
<source src=\"${media}\" type=\"${file_mime_type}\">
|
<source src=\"${media}\" type=\"${media_file_mime_type}\">
|
||||||
</audio>
|
</audio>
|
||||||
<br />
|
<br />
|
||||||
<a href=\"${media}\">${media}</a>
|
<a href=\"${media}\">${media}</a>
|
||||||
@ -1101,7 +1196,7 @@ $(cat "${shownotes_srt}" )
|
|||||||
</pre>
|
</pre>
|
||||||
<hr />
|
<hr />
|
||||||
</body>
|
</body>
|
||||||
</html>" > "${working_processing_dir}/${media_basename%.*}_media_report.html"
|
</html>" > "${working_dir}/${media_basename%.*}_media_report.html"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1118,10 +1213,10 @@ function manual_shownotes_review() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${shownotes_html}" || ! -s "${shownotes_html}" || ! -s "${working_processing_dir}/${media_basename%.*}_media_report.html" ]]
|
if [[ -z "${shownotes_html}" || ! -s "${shownotes_html}" || ! -s "${working_dir}/${media_basename%.*}_media_report.html" ]]
|
||||||
then
|
then
|
||||||
echo "shownotes_html: ${shownotes_html}"
|
echo "shownotes_html: ${shownotes_html}"
|
||||||
ls -al "${shownotes_html}" "${working_processing_dir}/${media_basename%.*}_media_report.html"
|
ls -al "${shownotes_html}" "${working_dir}/${media_basename%.*}_media_report.html"
|
||||||
echo_error "The files needed for to generate the inital report information are not available."
|
echo_error "The files needed for to generate the inital report information are not available."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1139,7 +1234,7 @@ function manual_shownotes_review() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
kate "${shownotes_edited}" >/dev/null 2>&1 &
|
kate "${shownotes_edited}" >/dev/null 2>&1 &
|
||||||
librewolf "${working_processing_dir}/${media_basename%.*}_media_report.html" >/dev/null 2>&1 &
|
librewolf "${working_dir}/${media_basename%.*}_media_report.html" >/dev/null 2>&1 &
|
||||||
seamonkey "${shownotes_edited}" >/dev/null 2>&1 &
|
seamonkey "${shownotes_edited}" >/dev/null 2>&1 &
|
||||||
# # # # bluefish "${shownotes_edited}" >/dev/null 2>&1 &
|
# # # # bluefish "${shownotes_edited}" >/dev/null 2>&1 &
|
||||||
# https://markdowntohtml.com/
|
# https://markdowntohtml.com/
|
||||||
@ -1251,9 +1346,7 @@ function get_variables_from_episode_summary_json() {
|
|||||||
|
|
||||||
check_variable_is_correct ep_num working_dir
|
check_variable_is_correct ep_num working_dir
|
||||||
|
|
||||||
shownotes_json="${working_dir}/shownotes.json"
|
set_working_dir_variables
|
||||||
shownotes_html="${working_dir}/shownotes.html"
|
|
||||||
shownotes_edited="${working_dir}/shownotes_edited.html"
|
|
||||||
|
|
||||||
if [ -z "${episode_summary_json}" ]
|
if [ -z "${episode_summary_json}" ]
|
||||||
then
|
then
|
||||||
@ -1292,16 +1385,19 @@ function create_tts_summary() {
|
|||||||
|
|
||||||
echo_debug "Creating Text to Speech summary. create_tts_summary()"
|
echo_debug "Creating Text to Speech summary. create_tts_summary()"
|
||||||
|
|
||||||
check_variable_is_correct working_dir duration synopsis piper_bin piper_voice working_processing_dir
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
|
then
|
||||||
|
echo_debug "Skipping media creation from create_tts_summary()"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_variable_is_correct working_dir duration synopsis piper_bin piper_voice
|
||||||
|
|
||||||
echo_debug "Converting text synopsis \"${synopsis}\" to speech."
|
echo_debug "Converting text synopsis \"${synopsis}\" to speech."
|
||||||
|
|
||||||
echo "${synopsis}" | "${piper_bin}" --model "${piper_voice}" --output_file "${working_processing_dir}/episode_tts.wav"
|
echo "${synopsis}" | "${piper_bin}" --model "${piper_voice}" --output_file "${episode_tts_wav}"
|
||||||
|
|
||||||
if [ ! -s "${working_processing_dir}/episode_tts.wav" ]
|
check_variable_is_correct episode_tts_wav
|
||||||
then
|
|
||||||
echo_error "The text to speech episode summary was not created \"${working_processing_dir}/episode_tts.wav\"."
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1312,22 +1408,25 @@ function generate_intro() {
|
|||||||
|
|
||||||
echo_debug "Generating the intro. generate_intro()"
|
echo_debug "Generating the intro. generate_intro()"
|
||||||
|
|
||||||
check_variable_is_correct working_dir working_processing_dir theme media outro_flac
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
|
then
|
||||||
|
echo_debug "Skipping media creation from generate_intro()"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_variable_is_correct working_dir theme media outro_flac
|
||||||
|
|
||||||
# Everything needs to be in the same format for the intro, 1 channel (mono) Sampling rate 44.1 kHz
|
# Everything needs to be in the same format for the intro, 1 channel (mono) Sampling rate 44.1 kHz
|
||||||
ffmpeg -hide_banner -loglevel error -y -i "${working_processing_dir}/episode_tts.wav" -ar 44100 -ac 1 "${working_processing_dir}//episode_tts.flac"
|
ffmpeg -hide_banner -loglevel error -y -i "${episode_tts_wav}" -ar 44100 -ac 1 "${episode_tts_flac}"
|
||||||
|
check_variable_is_correct episode_tts_flac
|
||||||
|
|
||||||
# A level of silence is added at the beginning of the text to speech
|
# A level of silence is added at the beginning of the text to speech
|
||||||
sox -V2 "${silence}" "${working_processing_dir}//episode_tts.flac" "${working_processing_dir}/episode_summary.flac"
|
sox -V2 "${silence}" "${episode_tts_flac}" "${episode_summary_flac}"
|
||||||
|
check_variable_is_correct episode_summary_flac
|
||||||
|
|
||||||
# The tracks are merged together resulting in the theme playing first, then after a period of silence the text to speech enters
|
# The tracks are merged together resulting in the theme playing first, then after a period of silence the text to speech enters
|
||||||
sox -V2 -m "${working_processing_dir}/episode_summary.flac" "${theme}" "${working_processing_dir}/episode_intro.flac"
|
sox -V2 -m "${episode_summary_flac}" "${theme}" ${episode_intro_flac}
|
||||||
|
check_variable_is_correct episode_intro_flac
|
||||||
if [[ ! -s "${working_processing_dir}//episode_tts.flac" || ! -s "${working_processing_dir}/episode_summary.flac" || ! -s "${working_processing_dir}/episode_intro.flac" ]]
|
|
||||||
then
|
|
||||||
echo_error "The files for the theme audio sandwich are not available."
|
|
||||||
ls -al "${working_processing_dir}//episode_tts.flac" "${working_processing_dir}/episode_summary.flac" "${theme}" "${working_processing_dir}/episode_intro.flac"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1338,20 +1437,24 @@ function generate_parent_audio() {
|
|||||||
|
|
||||||
echo_debug "Generating the parent audio - the sandwitch. generate_parent_audio()"
|
echo_debug "Generating the parent audio - the sandwitch. generate_parent_audio()"
|
||||||
|
|
||||||
if [[ ! -s "${working_processing_dir}/episode_intro.flac" || ! -s "${media}" || ! -s "${outro_flac}" ]]
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
then
|
then
|
||||||
echo_error "The files for the sandwich are not available."
|
echo_debug "Skipping media creation from generate_parent_audio()"
|
||||||
ls -al
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_variable_is_correct episode_intro_flac media outro_flac
|
||||||
|
|
||||||
# Everything needs to be in the same format so the text to speech needs to be converted to 2 channel Sampling rate 44.1 kHz
|
# Everything needs to be in the same format so the text to speech needs to be converted to 2 channel Sampling rate 44.1 kHz
|
||||||
ffmpeg -hide_banner -loglevel error -y -i "${media}" -ar 44100 -ac 1 "${working_processing_dir}/episode_body.flac"
|
ffmpeg -hide_banner -loglevel error -y -i "${media}" -ar 44100 -ac 1 "${episode_body_flac}"
|
||||||
|
check_variable_is_correct episode_body_flac
|
||||||
|
|
||||||
# Combine the components together
|
# Combine the components together
|
||||||
sox -V2 "${working_processing_dir}/episode_intro.flac" "${working_processing_dir}/episode_body.flac" "${outro_flac}" "${working_processing_dir}/episode_sandwitch.flac"
|
sox -V2 ${episode_intro_flac} "${episode_body_flac}" "${outro_flac}" "${episode_sandwitch_flac}"
|
||||||
|
check_variable_is_correct episode_sandwitch_flac
|
||||||
# Normalise the audio
|
# Normalise the audio
|
||||||
ffmpeg -hide_banner -loglevel error -y -i "${working_processing_dir}/episode_sandwitch.flac" -af loudnorm=I=-16:LRA=11:TP=-1.5 "${working_processing_dir}/episode_final.flac"
|
ffmpeg -hide_banner -loglevel error -y -i "${episode_sandwitch_flac}" -af loudnorm=I=-16:LRA=11:TP=-1.5 "${episode_final_flac}"
|
||||||
|
check_variable_is_correct episode_final_flac
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1362,9 +1465,15 @@ function generate_derived_media() {
|
|||||||
|
|
||||||
echo_debug "Generating derived audio. generate_derived_media()"
|
echo_debug "Generating derived audio. generate_derived_media()"
|
||||||
|
|
||||||
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
|
then
|
||||||
|
echo_debug "Skipping media creation from generate_derived_media()"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
check_variable_is_correct media working_dir ep_num title artist license
|
check_variable_is_correct media working_dir ep_num title artist license
|
||||||
|
|
||||||
if [[ ! -s "${working_processing_dir}/episode_final.flac" ]]
|
if [[ ! -s "${episode_final_flac}" ]]
|
||||||
then
|
then
|
||||||
ls -al
|
ls -al
|
||||||
echo_error "The final cut is not available."
|
echo_error "The final cut is not available."
|
||||||
@ -1374,10 +1483,10 @@ function generate_derived_media() {
|
|||||||
|
|
||||||
# https://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata
|
# https://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata
|
||||||
|
|
||||||
for extension in flac wav mp3 ogg opus spx
|
for extension in "${audio_formats[@]}"
|
||||||
do
|
do
|
||||||
echo_debug "Generating \"hpr${ep_num}.${extension}\"."
|
echo_debug "Generating \"hpr${ep_num}.${extension}\"."
|
||||||
ffmpeg -hide_banner -loglevel error -y -i "${working_processing_dir}/episode_final.flac" \
|
ffmpeg -hide_banner -loglevel error -y -i "${episode_final_flac}" \
|
||||||
-metadata title="${title}" \
|
-metadata title="${title}" \
|
||||||
-metadata artist="${artist}" \
|
-metadata artist="${artist}" \
|
||||||
-metadata author="${artist}" \
|
-metadata author="${artist}" \
|
||||||
@ -1401,15 +1510,44 @@ function generate_derived_media() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
#TODO fix close duration
|
#TODO fix close duration
|
||||||
lengths=$( for extension in flac wav mp3 ogg opus
|
|
||||||
|
# shownotes_json="${working_dir}/shownotes.json"
|
||||||
|
# shownotes_html="${working_dir}/shownotes.html"
|
||||||
|
# shownotes_edited="${working_dir}/shownotes_edited.html"
|
||||||
|
# episode_tts_wav="${working_dir}/episode_tts.wav"
|
||||||
|
# episode_tts_flac="${working_dir}/episode_tts.flac"
|
||||||
|
# episode_summary_flac="${working_dir}/episode_summary.flac"
|
||||||
|
# episode_intro_flac="${working_dir}/episode_intro.flac"
|
||||||
|
# episode_body_flac="${working_dir}/episode_body.flac"
|
||||||
|
# episode_sandwitch_flac="${working_dir}/episode_sandwitch.flac"
|
||||||
|
# episode_final_flac="${working_dir}/episode_final.flac"
|
||||||
|
# episode_intro_srt="${working_dir}/episode_intro.srt"
|
||||||
|
# episode_body_srt="${working_dir}/episode_body.srt"
|
||||||
|
# episode_outro_srt="${working_dir}/episode_outro.srt"
|
||||||
|
# episode_srt="${working_dir}/episode.srt"
|
||||||
|
|
||||||
|
check_variable_is_correct episode_intro_flac outro_flac media duration
|
||||||
|
|
||||||
|
|
||||||
|
intro_duration="$( mediainfo --Output=XML --Full "${episode_intro_flac}" | xmlstarlet sel -T -t -m '/_:MediaInfo/_:media/_:track[@type="Audio"]' -v '_:Duration' -n | awk -F '.' '{print $1}' )"
|
||||||
|
outro_duration="$( mediainfo --Output=XML --Full "${outro_flac}" | xmlstarlet sel -T -t -m '/_:MediaInfo/_:media/_:track[@type="Audio"]' -v '_:Duration' -n | awk -F '.' '{print $1}' )"
|
||||||
|
source_duration="$( mediainfo --Output=XML --Full "${media}" | xmlstarlet sel -T -t -m '/_:MediaInfo/_:media/_:track[@type="Audio"]' -v '_:Duration' -n | awk -F '.' '{print $1}' )"
|
||||||
|
expected_duration=$(( ${intro_duration} + ${duration} + ${outro_duration} ))
|
||||||
|
check_variable_is_correct intro_duration outro_duration source_duration expected_duration
|
||||||
|
|
||||||
|
echo_debug "Intro(${intro_duration}) + Show(${duration}) + Outro(${outro_duration}) = ${expected_duration}"
|
||||||
|
|
||||||
|
for extension in "${audio_formats[@]}"
|
||||||
do
|
do
|
||||||
mediainfo --full --Output=XML "${working_dir}/hpr${ep_num}.${extension}" | xmlstarlet sel -T -t -m "_:MediaInfo/_:media/_:track[@type='Audio']/_:Duration[1]" -v "." -n - | awk -F '.' '{print $1}'
|
this_duration=$( mediainfo --full --Output=XML "${working_dir}/hpr${ep_num}.${extension}" | xmlstarlet sel -T -t -m "_:MediaInfo/_:media/_:track[@type='Audio']/_:Duration[1]" -v "." -n - | awk -F '.' '{print $1}' )
|
||||||
done | sort | uniq | wc -l )
|
if [ $( abs_diff "${this_duration}" "${expected_duration}" ) -le "${acceptable_duration_difference}" ]
|
||||||
if [ "${lengths}" -ne "1" ]
|
then
|
||||||
then
|
echo_debug "The file \"hpr${ep_num}.${extension}\" duration of ${this_duration} is close enough to ${expected_duration}"
|
||||||
echo_error "The duration of the derived media is not correct."
|
else
|
||||||
fi
|
echo_error "The file \"hpr${ep_num}.${extension}\" actual duration of ${this_duration} is not close enough to posted duration of ${expected_duration}. Fix or update the posted duration to ${source_duration}."
|
||||||
#TODO fix close duration
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
cp -v "${media}" "${working_dir}/hpr${ep_num}_source.${media##*.}"
|
cp -v "${media}" "${working_dir}/hpr${ep_num}_source.${media##*.}"
|
||||||
|
|
||||||
if [[ ! -s "${working_dir}/hpr${ep_num}_source.${media##*.}" ]]
|
if [[ ! -s "${working_dir}/hpr${ep_num}_source.${media##*.}" ]]
|
||||||
@ -1427,11 +1565,17 @@ function generate_show_transcript() {
|
|||||||
|
|
||||||
echo_debug "Generate show transcript and subtitles. generate_show_transcript()"
|
echo_debug "Generate show transcript and subtitles. generate_show_transcript()"
|
||||||
|
|
||||||
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
|
then
|
||||||
|
echo_debug "Skipping media creation from generate_show_transcript()"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# TODO Currently processed elsewhere by hpr-get-and-transcode.bash and uploaded to hpr:upload/ to be synced with media above
|
# TODO Currently processed elsewhere by hpr-get-and-transcode.bash and uploaded to hpr:upload/ to be synced with media above
|
||||||
|
|
||||||
if [[ ! -s "${media}" || ! -s "${media%.*}.srt" || ! -s "${intro_srt}" || ! -s "${outro_srt}" || ! -s "${working_processing_dir}/episode_intro.flac" || ! -s "${working_processing_dir}/episode_body.flac" ]]
|
if [[ ! -s "${media}" || ! -s "${media%.*}.srt" || ! -s "${intro_srt}" || ! -s "${outro_srt}" || ! -s ${episode_intro_flac} || ! -s "${episode_body_flac}" ]]
|
||||||
then
|
then
|
||||||
ls -al "${media}" "${media%.*}.srt" "${intro_srt}" "${outro_srt}" "${working_processing_dir}/episode_intro.flac" "${working_processing_dir}/episode_body.flac"
|
ls -al "${media}" "${media%.*}.srt" "${intro_srt}" "${outro_srt}" ${episode_intro_flac} "${episode_body_flac}"
|
||||||
echo_error "The transcriptions files are not available."
|
echo_error "The transcriptions files are not available."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1458,32 +1602,32 @@ function generate_show_transcript() {
|
|||||||
REPLACE_LINE_4="The flag is ${explicit}, and the license is ${license}"
|
REPLACE_LINE_4="The flag is ${explicit}, and the license is ${license}"
|
||||||
REPLACE_LINE_5="The summary is \"${summary}\""
|
REPLACE_LINE_5="The summary is \"${summary}\""
|
||||||
|
|
||||||
cp -v ${intro_srt} "${working_processing_dir}/episode_intro.srt"
|
cp -v ${intro_srt} "${episode_intro_srt}"
|
||||||
cp -v ${outro_srt} "${working_processing_dir}/episode_outro.srt"
|
cp -v ${outro_srt} "${episode_outro_srt}"
|
||||||
|
|
||||||
sed -e "s~REPLACE_LINE_1~${REPLACE_LINE_1}~g" -e "s~REPLACE_LINE_2~${REPLACE_LINE_2}~g" -e "s~REPLACE_LINE_3~${REPLACE_LINE_3}~g" -e "s~REPLACE_LINE_4~${REPLACE_LINE_4}~g" -e "s~REPLACE_LINE_5~${REPLACE_LINE_5}~g" -i "${working_processing_dir}/episode_intro.srt"
|
sed -e "s~REPLACE_LINE_1~${REPLACE_LINE_1}~g" -e "s~REPLACE_LINE_2~${REPLACE_LINE_2}~g" -e "s~REPLACE_LINE_3~${REPLACE_LINE_3}~g" -e "s~REPLACE_LINE_4~${REPLACE_LINE_4}~g" -e "s~REPLACE_LINE_5~${REPLACE_LINE_5}~g" -i "${episode_intro_srt}"
|
||||||
|
|
||||||
if [ "$( grep --count REPLACE_LINE "${working_processing_dir}/episode_intro.srt" )" -ne "0" ]
|
if [ "$( grep --count REPLACE_LINE "${episode_intro_srt}" )" -ne "0" ]
|
||||||
then
|
then
|
||||||
echo_error "The intro subtitles were not correctly generated \"${working_processing_dir}/episode_intro.srt\"."
|
echo_error "The intro subtitles were not correctly generated \"${episode_intro_srt}\"."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Time shift the media subtitles on by the duration of the intro wav file
|
# Time shift the media subtitles on by the duration of the intro wav file
|
||||||
# https://trac.ffmpeg.org/wiki/UnderstandingItsoffset
|
# https://trac.ffmpeg.org/wiki/UnderstandingItsoffset
|
||||||
|
|
||||||
itsoffset_intro="$( mediainfo --full --Output=JSON "${working_processing_dir}/episode_intro.flac" | jq --raw-output '.media.track | .[] | select(."@type"=="Audio") | .Duration' | awk -F '.' '{print $1}' )"
|
itsoffset_intro="$( mediainfo --full --Output=JSON ${episode_intro_flac} | jq --raw-output '.media.track | .[] | select(."@type"=="Audio") | .Duration' | awk -F '.' '{print $1}' )"
|
||||||
|
|
||||||
if [[ -z "${itsoffset_intro}" || "${itsoffset_intro}" == "null" ]]
|
if [[ -z "${itsoffset_intro}" || "${itsoffset_intro}" == "null" ]]
|
||||||
then
|
then
|
||||||
echo_error "Could not retrieve the itsoffset_intro to correct the timing of the subtitles."
|
echo_error "Could not retrieve the itsoffset_intro to correct the timing of the subtitles."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ffmpeg -hide_banner -loglevel error -y -itsoffset "${itsoffset_intro}" -i "${media%.*}.srt" -c copy "${working_processing_dir}/episode_body.srt"
|
ffmpeg -hide_banner -loglevel error -y -itsoffset "${itsoffset_intro}" -i "${media%.*}.srt" -c copy "${episode_body_srt}"
|
||||||
|
|
||||||
# Timeshift the outro by the duration of the intro and the supplied media
|
# Timeshift the outro by the duration of the intro and the supplied media
|
||||||
|
|
||||||
itsoffset_body="$( mediainfo --full --Output=JSON "${working_processing_dir}/episode_body.flac" | jq --raw-output '.media.track | .[] | select(."@type"=="Audio") | .Duration' | awk -F '.' '{print $1}' )"
|
itsoffset_body="$( mediainfo --full --Output=JSON "${episode_body_flac}" | jq --raw-output '.media.track | .[] | select(."@type"=="Audio") | .Duration' | awk -F '.' '{print $1}' )"
|
||||||
|
|
||||||
if [[ -z "${itsoffset_body}" || "${itsoffset_body}" == "null" ]]
|
if [[ -z "${itsoffset_body}" || "${itsoffset_body}" == "null" ]]
|
||||||
then
|
then
|
||||||
@ -1492,18 +1636,18 @@ function generate_show_transcript() {
|
|||||||
|
|
||||||
itsoffset_body=$((itsoffset_intro + $itsoffset_body))
|
itsoffset_body=$((itsoffset_intro + $itsoffset_body))
|
||||||
|
|
||||||
ffmpeg -hide_banner -loglevel error -y -itsoffset "${itsoffset_body}" -i "${working_processing_dir}/episode_outro.srt" -c copy "${working_processing_dir}/episode_outro_shifted.srt"
|
ffmpeg -hide_banner -loglevel error -y -itsoffset "${itsoffset_body}" -i "${episode_outro_srt}" -c copy "${working_dir}/episode_outro_shifted.srt"
|
||||||
|
|
||||||
# Combine the intro, timeshifted media subtitles, and the timeshifted outro subtitles.
|
# Combine the intro, timeshifted media subtitles, and the timeshifted outro subtitles.
|
||||||
|
|
||||||
cat "${working_processing_dir}/episode_intro.srt" "${working_processing_dir}/episode_body.srt" "${working_processing_dir}/episode_outro_shifted.srt" > "${working_processing_dir}/episode.srt"
|
cat "${episode_intro_srt}" "${episode_body_srt}" "${working_dir}/episode_outro_shifted.srt" > "${episode_srt}"
|
||||||
|
|
||||||
# Parse the resulting subtitle file fixing the numberic counter
|
# Parse the resulting subtitle file fixing the numberic counter
|
||||||
# https://en.wikipedia.org/wiki/SubRip
|
# https://en.wikipedia.org/wiki/SubRip
|
||||||
|
|
||||||
count=1
|
count=1
|
||||||
|
|
||||||
cat "${working_processing_dir}/episode.srt" | while read this_line
|
cat "${episode_srt}" | while read this_line
|
||||||
do
|
do
|
||||||
if [ "$( echo "${this_line}" | grep -c --perl-regexp '^[0-9]+$' )" -eq "1" ]
|
if [ "$( echo "${this_line}" | grep -c --perl-regexp '^[0-9]+$' )" -eq "1" ]
|
||||||
then
|
then
|
||||||
@ -1533,17 +1677,17 @@ function generate_final_report() {
|
|||||||
|
|
||||||
echo_debug "Generating the final report. generate_final_report()"
|
echo_debug "Generating the final report. generate_final_report()"
|
||||||
|
|
||||||
if [[ -n "${skip_post_show}" && "${skip_post_show}" == "true" ]]
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
then
|
then
|
||||||
echo_debug "The Episode hpr${ep_num} has already been posted. Skipping generate_final_report()"
|
echo_debug "Skipping media creation from ()"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_variable_is_correct working_dir working_processing_dir ep_num media_basename shownotes_edited synopsis
|
check_variable_is_correct working_dir ep_num media_basename shownotes_edited synopsis
|
||||||
|
|
||||||
final_report="${working_processing_dir}/hpr${ep_num}_report.html"
|
final_report="${working_dir}/hpr${ep_num}_report.html"
|
||||||
|
|
||||||
for this_file_extension_to_check in flac mp3 ogg opus srt txt wav
|
for this_file_extension_to_check in "${episode_formats[@]}"
|
||||||
do
|
do
|
||||||
if [[ ! -s "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" ]]
|
if [[ ! -s "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" ]]
|
||||||
then
|
then
|
||||||
@ -1552,13 +1696,13 @@ function generate_final_report() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ! -s "${working_processing_dir}/${media_basename%.*}_media_report.html" ]]
|
if [[ ! -s "${working_dir}/${media_basename%.*}_media_report.html" ]]
|
||||||
then
|
then
|
||||||
ls -al "${working_processing_dir}/${media_basename%.*}_media_report.html"
|
ls -al "${working_dir}/${media_basename%.*}_media_report.html"
|
||||||
echo_error "The initial report is not available.\"${working_processing_dir}/${media_basename%.*}_media_report.html\""
|
echo_error "The initial report is not available.\"${working_dir}/${media_basename%.*}_media_report.html\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
grep -Pv '</body>|</html>' "${working_processing_dir}/${media_basename%.*}_media_report.html" > "${final_report}"
|
grep -Pv '</body>|</html>' "${working_dir}/${media_basename%.*}_media_report.html" > "${final_report}"
|
||||||
|
|
||||||
echo "<h3 id=\"derived_media\" >Text To Speech</h3>
|
echo "<h3 id=\"derived_media\" >Text To Speech</h3>
|
||||||
<p>
|
<p>
|
||||||
@ -1566,33 +1710,33 @@ $( echo "${synopsis}" )
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<audio controls=\"\" preload=\"none\" style=\"width:600px;\" >
|
<audio controls=\"\" preload=\"none\" style=\"width:600px;\" >
|
||||||
<source src=\"${working_processing_dir}//episode_tts.flac\" type=\"audio/flac\">
|
<source src=\"${episode_tts_flac}\" type=\"audio/flac\">
|
||||||
</audio>
|
</audio>
|
||||||
<br />
|
<br />
|
||||||
<a href=\"${working_processing_dir}//episode_tts.flac\">${working_processing_dir}//episode_tts.flac</a>
|
<a href=\"${episode_tts_flac}\">${episode_tts_flac}</a>
|
||||||
</p>
|
</p>
|
||||||
<hr />" >> "${final_report}"
|
<hr />" >> "${final_report}"
|
||||||
|
|
||||||
|
|
||||||
for this_file_extension_to_check in flac mp3 ogg opus wav
|
for this_file_extension_to_check in "${audio_formats[@]}"
|
||||||
do
|
do
|
||||||
ffmpeg -hide_banner -loglevel error -y -i "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" -lavfi "showspectrumpic=s=960x540" "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_spectrum.png"
|
ffmpeg -hide_banner -loglevel error -y -i "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" -lavfi "showspectrumpic=s=960x540" "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_spectrum.png"
|
||||||
|
|
||||||
audio2image.bash "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" && mv -v "${working_dir}/hpr${ep_num}.png" "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_waveform.png"
|
audio2image.bash "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" && mv -v "${working_dir}/hpr${ep_num}.png" "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_waveform.png"
|
||||||
|
|
||||||
mediainfo "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" > "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_mediainfo.txt"
|
mediainfo "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" > "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_mediainfo.txt"
|
||||||
|
|
||||||
exiftool "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" > "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_exiftool.txt"
|
exiftool "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" > "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_exiftool.txt"
|
||||||
|
|
||||||
ffprobe "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" 2>&1 | grep Audio: | sed 's/^.\s//g' > "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_ffprobe.txt"
|
ffprobe "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" 2>&1 | grep Audio: | sed 's/^.\s//g' > "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_ffprobe.txt"
|
||||||
file --brief --mime "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" >> "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_ffprobe.txt"
|
file --brief --mime "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" >> "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_ffprobe.txt"
|
||||||
this_file_mime_type="$( file --brief --mime-type "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" )"
|
this_file_mime_type="$( file --brief --mime-type "${working_dir}/hpr${ep_num}.${this_file_extension_to_check}" )"
|
||||||
|
|
||||||
for this_file_to_check in spectrum.png waveform.png mediainfo.txt exiftool.txt ffprobe.txt
|
for this_file_to_check in spectrum.png waveform.png mediainfo.txt exiftool.txt ffprobe.txt
|
||||||
do
|
do
|
||||||
if [[ ! -s "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_${this_file_to_check}" ]]
|
if [[ ! -s "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_${this_file_to_check}" ]]
|
||||||
then
|
then
|
||||||
ls -al "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_${this_file_to_check}"
|
ls -al "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_${this_file_to_check}"
|
||||||
echo_error "The inital report information is missing \"${this_file_to_check}\"."
|
echo_error "The inital report information is missing \"${this_file_to_check}\"."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -1602,29 +1746,29 @@ $( echo "${synopsis}" )
|
|||||||
<h3>mediainfo report</h3>
|
<h3>mediainfo report</h3>
|
||||||
<code>
|
<code>
|
||||||
<pre>
|
<pre>
|
||||||
$( cat "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_mediainfo.txt" )
|
$( cat "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_mediainfo.txt" )
|
||||||
</pre>
|
</pre>
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
<h3>exiftool report</h3>
|
<h3>exiftool report</h3>
|
||||||
<code>
|
<code>
|
||||||
<pre>
|
<pre>
|
||||||
$( cat "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_exiftool.txt" )
|
$( cat "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_exiftool.txt" )
|
||||||
</pre>
|
</pre>
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
<h3>Audio Spectrum</h3>
|
<h3>Audio Spectrum</h3>
|
||||||
<p>
|
<p>
|
||||||
<img src=\"${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_spectrum.png\" alt=\"Spectrum\" />
|
<img src=\"${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_spectrum.png\" alt=\"Spectrum\" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Audio Waveform</h3>
|
<h3>Audio Waveform</h3>
|
||||||
<p>
|
<p>
|
||||||
<img src=\"${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_waveform.png\" alt=\"Waveform\" />
|
<img src=\"${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_waveform.png\" alt=\"Waveform\" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
$( cat "${working_processing_dir}/hpr${ep_num}_${this_file_extension_to_check}_ffprobe.txt" )
|
$( cat "${working_dir}/hpr${ep_num}_${this_file_extension_to_check}_ffprobe.txt" )
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -1677,9 +1821,9 @@ function manual_final_review() {
|
|||||||
|
|
||||||
echo_debug "Validating the final report. manual_final_review()"
|
echo_debug "Validating the final report. manual_final_review()"
|
||||||
|
|
||||||
if [[ -n "${skip_post_show}" && "${skip_post_show}" == "true" ]]
|
if [[ -n "${skip_media_encoding}" && "${skip_media_encoding}" == "true" ]]
|
||||||
then
|
then
|
||||||
echo_debug "The Episode hpr${ep_num} has already been posted. Skipping generate_final_report()"
|
echo_debug "Skipping media creation from ()"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1703,6 +1847,28 @@ function manual_final_review() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#################################################
|
||||||
|
# Checks derived assets are correct
|
||||||
|
|
||||||
|
function check_derived_assets () {
|
||||||
|
|
||||||
|
check_variable_is_correct working_dir ep_num
|
||||||
|
|
||||||
|
#TODO Extend checks to media internals
|
||||||
|
|
||||||
|
for extension in "${audio_formats[@]}"
|
||||||
|
do
|
||||||
|
echo_debug "Checking \"hpr${ep_num}.${extension}\"."
|
||||||
|
|
||||||
|
if [[ ! -s "${working_dir}/hpr${ep_num}.${extension}" ]]
|
||||||
|
then
|
||||||
|
ls -al "${working_dir}/hpr${ep_num}.${extension}"
|
||||||
|
echo_error "Failed to locate \"${working_dir}/hpr${ep_num}.${extension}\"."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Register the assets with the hpr database
|
# Register the assets with the hpr database
|
||||||
|
|
||||||
@ -1712,6 +1878,8 @@ function register_assets() {
|
|||||||
|
|
||||||
check_variable_is_correct working_dir ep_num
|
check_variable_is_correct working_dir ep_num
|
||||||
|
|
||||||
|
check_derived_assets
|
||||||
|
|
||||||
assets_csv="${working_dir}/hpr${ep_num}_assets.csv"
|
assets_csv="${working_dir}/hpr${ep_num}_assets.csv"
|
||||||
assets_json="${working_dir}/hpr${ep_num}_assets.json"
|
assets_json="${working_dir}/hpr${ep_num}_assets.json"
|
||||||
|
|
||||||
@ -1723,7 +1891,8 @@ function register_assets() {
|
|||||||
|
|
||||||
echo '"episode_id","filename","extension","size", "sha1sum", "mime_type", "file_type"' | tee "${assets_csv}"
|
echo '"episode_id","filename","extension","size", "sha1sum", "mime_type", "file_type"' | tee "${assets_csv}"
|
||||||
|
|
||||||
for this_asset_filename in hpr${ep_num}.flac hpr${ep_num}.wav hpr${ep_num}.mp3 hpr${ep_num}.ogg hpr${ep_num}.opus hpr${ep_num}.srt hpr${ep_num}.txt $( find "${working_dir}/" -maxdepth 1 -type f -iname "hpr${ep_num}_image_*.*" )
|
find "${working_dir}/" -maxdepth 1 -type f \( -iname "hpr${ep_num}.*" -or -iname "hpr${ep_num}_image_*.*" \) | \
|
||||||
|
while read for this_asset_filename
|
||||||
do
|
do
|
||||||
this_asset_filename="$( basename "${this_asset_filename}" )"
|
this_asset_filename="$( basename "${this_asset_filename}" )"
|
||||||
echo_debug "Registering \"${this_asset_filename}\"."
|
echo_debug "Registering \"${this_asset_filename}\"."
|
||||||
@ -1762,7 +1931,9 @@ function register_assets() {
|
|||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -s "${assets_csv}" ]
|
check_variable_is_correct assets_csv
|
||||||
|
|
||||||
|
if [[ -s "${assets_csv}" && "$( wc -l "${assets_csv}" )" -gt "1" ]]
|
||||||
then
|
then
|
||||||
cat "${assets_csv}" | csvtojson | jq '{"assets":[.[]]}' | tee "${assets_json}"
|
cat "${assets_csv}" | csvtojson | jq '{"assets":[.[]]}' | tee "${assets_json}"
|
||||||
fi
|
fi
|
||||||
@ -2095,13 +2266,8 @@ echo "hidden"
|
|||||||
#
|
#
|
||||||
# This tool will process the HPR shows allowing the janitor to review the media and fix shownotes.
|
# This tool will process the HPR shows allowing the janitor to review the media and fix shownotes.
|
||||||
|
|
||||||
|
|
||||||
argument_override "$@"
|
argument_override "$@"
|
||||||
|
|
||||||
########################################################################################
|
|
||||||
# Posting show
|
|
||||||
|
|
||||||
|
|
||||||
program_checks # We know that all the programs and variables are set
|
program_checks # We know that all the programs and variables are set
|
||||||
|
|
||||||
if [[ -z "${working_dir_bypass}" || "${working_dir_bypass}" != "true" ]]
|
if [[ -z "${working_dir_bypass}" || "${working_dir_bypass}" != "true" ]]
|
||||||
@ -2111,8 +2277,6 @@ else
|
|||||||
echo_debug "Skipping get_working_dir()"
|
echo_debug "Skipping get_working_dir()"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_working_processing_dir
|
|
||||||
|
|
||||||
if [ "$( curl --silent --netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/say.php?id=${ep_num} --output /dev/null )" == 200 ]
|
if [ "$( curl --silent --netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/say.php?id=${ep_num} --output /dev/null )" == 200 ]
|
||||||
then
|
then
|
||||||
skip_post_show="true"
|
skip_post_show="true"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user