diff --git a/Resources/vrecord_functions b/Resources/vrecord_functions index 5eed321e..66754f69 100644 --- a/Resources/vrecord_functions +++ b/Resources/vrecord_functions @@ -38,10 +38,10 @@ _check_ffmpeg_install(){ } _update_config_file(){ + CONFIG_FILE="${PROFILE_DIR}/$(cat "${PROFILE_SELECTED_FILE}").conf" # write config file { echo "# Set these variables to a valid option or leave as empty quotes (like \"\") to request each run." - echo "STARTUP_VIEW=\"${STARTUP_VIEW}\"" echo "DEVICE_INPUT_CHOICE=\"${DEVICE_INPUT_CHOICE}\"" echo "VIDEO_INPUT_CHOICE=\"${VIDEO_INPUT_CHOICE}\"" echo "AUDIO_INPUT_CHOICE=\"${AUDIO_INPUT_CHOICE}\"" @@ -95,15 +95,29 @@ _update_config_file(){ } _validate_form(){ - if [ "${VIDEO_CODEC_CHOICE}" = "FFV1 version 3" ] && [ "${CONTAINER_CHOICE}" = "MXF" ] ; then echo "ERROR: Incompatible video codecs and containers have been selected." elif [ "${AUDIO_CODEC_CHOICE}" = "24-bit FLAC" ] && [ "${CONTAINER_CHOICE}" = "QuickTime" ] ; then echo "ERROR: Incompatible audio codecs and containers have been selected." fi if [ -z "${DIR}" ] ; then - echo "WARNING: The recording directory is not set. $(pwd) will be used." - elif [ ! -d "${DIR}" ] ; then + NEW_DEFAULT_DIR="$(pwd)" + echo "WARNING: The recording directory is not set. ${NEW_DEFAULT_DIR} will be used." + DIR="${NEW_DEFAULT_DIR}" + fi + if [ -d "${DIR}" ] ; then + if [ $(mount | grep $(df -P "${DIR}" | tail +2 | awk '{print $1}') | grep -c "(.*local,") = "0" ] && [ "${OS_TYPE}" != "linux" ] ; then + echo "WARNING: The recording directory at ${DIR} is not a local directory. Please verify that you can write to the disk fast enough." + fi + if [ "${OS_TYPE}" = "linux" ] ; then + FREE_SPACE="$(df -BG "${DIR}" | tail +2 | awk '{print $4}' | tr 'G' ' ')" + else + FREE_SPACE="$(df -g "${DIR}" | tail +2 | awk '{print $4}')" + fi + if [ "${FREE_SPACE}" -le 40 ] ; then + echo "WARNING: The recording directory at ${DIR} only has ${FREE_SPACE} gigabytes available." + fi + else echo "ERROR: The recording directory (${DIR}) does not exist. Please set or $(pwd) will be used instead." fi if [ ! -d "${LOGDIR}" ] && [ -n "${LOGDIR}" ] ; then @@ -124,18 +138,6 @@ _validate_form(){ if [ "${INVERT_PHASE_4}" = "true" ] ; then echo "WARNING: Option to invert phase of fourth audio channel has been selected." fi - - if [ $(mount | grep $(df -P "${DIR}" | tail +2 | awk '{print $1}') | grep -c "(.*local,") = "0" ] && [ "${OS_TYPE}" != "linux" ] ; then - echo "WARNING: The recording directory at ${DIR} is not a local directory. Please verify that you can write to the disk fast enough." - fi - if [ "${OS_TYPE}" = "linux" ] ; then - FREE_SPACE="$(df -BG "${DIR}" | tail +2 | awk '{print $4}' | tr 'G' ' ')" - else - FREE_SPACE="$(df -g "${DIR}" | tail +2 | awk '{print $4}')" - fi - if [ "${FREE_SPACE}" -le 40 ] ; then - echo "WARNING: The recording directory at ${DIR} only has ${FREE_SPACE} gigabytes available." - fi if [ "${SIGNAL_INT_CHOICE}" != "auto" ] && [ -n "${SIGNAL_INT_CHOICE}" ] ; then echo "WARNING: The configuration ignores the interlacement of the input and forces it to ${SIGNAL_INT_CHOICE}. Set to 'auto' if you prefer to keep the interlacement as the device describes it." fi @@ -206,12 +208,18 @@ _get_audio_device_list(){ fi } +_get_profile_list(){ + ls -1 "${PROFILE_DIR}" | grep ".conf$" | sed "s|.conf$||g" +} + _get_summary(){ + CONFIG_FILE="${PROFILE_DIR}/$(cat "${PROFILE_SELECTED_FILE}").conf" if [[ ! -f "${CONFIG_FILE}" ]] ; then echo "VRecord configuration file is missing, please visit the Settings panel." else . "${CONFIG_FILE}" if [ "${DEVICE_INPUT_CHOICE}" = "0" ] ; then + echo "Selected Profile: $(cat "${PROFILE_SELECTED_FILE}")" echo "Device Input: Decklink" echo "Settings: ${VIDEO_CODEC_CHOICE} ${VIDEO_BIT_DEPTH_CHOICE} ${CONTAINER_CHOICE} File" echo "from ${VIDEO_INPUT_CHOICE} video input and ${AUDIO_INPUT_CHOICE} audio input" @@ -227,11 +235,13 @@ _get_summary(){ echo "QCTools XML: ${QCTOOLSXML_CHOICE}" echo "Playback: ${PLAYBACKVIEW_CHOICE} view (for recording) and ${PLAYBACKVIEW_CHOICE_PASS} view (for passthrough)" elif [ "${DEVICE_INPUT_CHOICE}" = "1" ] ; then + echo "Selected Profile: $(cat "${PROFILE_SELECTED_FILE}")" echo "Device Input: DV" echo "Copying video from ${DVRESCUE_INPUT_CHOICE}." echo "Inputs recorded to ${DIR}" echo "Auxiliary files created in ${LOGDIR}" elif [ "${DEVICE_INPUT_CHOICE}" = "2" ] ; then + echo "Selected Profile: $(cat "${PROFILE_SELECTED_FILE}")" echo "Device Input: Audio" echo "Recording audio from ${AUDIO_DEV_CHOICE}." echo "Audio codec: ${AUDIO_MODE_CODEC_CHOICE}" diff --git a/vrecord b/vrecord index bbf0ad92..2d6024bb 100755 --- a/vrecord +++ b/vrecord @@ -6,11 +6,37 @@ VERSION="2024-10-18" SCRIPTNAME="$(basename "${0}")" SCRIPTDIR="$(dirname "${0}")" -CONFIG_FILE="${HOME}/.${SCRIPTNAME}.conf" +PROFILE_DIR="${HOME}/.vrecord_profiles" +PROFILE_SELECTED_FILE="${PROFILE_DIR}/selected_profile.txt" SAT_OUTLIER_THRSHLD=14 AUD_OUTLIER_THRSHLD=10 BRNG_OUTLIER_THRSHLD=14 +_update_profile(){ + # steps to upgrade profile management + OLD_CONFIG_FILE="${HOME}/.${SCRIPTNAME}.conf" + NEW_CONFIG_NAME="Primary Profile" + NEW_CONFIG_FILE="${PROFILE_DIR}/${NEW_CONFIG_NAME}.conf" + if [[ ! -d "${PROFILE_DIR}" ]] ; then + mkdir "${PROFILE_DIR}" + if [[ -f "${OLD_CONFIG_FILE}" ]] ; then + mv -n "${OLD_CONFIG_FILE}" "${NEW_CONFIG_FILE}" + echo "${NEW_CONFIG_NAME}" > "${PROFILE_SELECTED_FILE}" + fi + fi + if [[ -f "${PROFILE_SELECTED_FILE}" ]] ; then + LOADED_PROFILE="$(cat "${PROFILE_SELECTED_FILE}")" + echo "${PROFILE_DIR}/${LOADED_PROFILE}.conf" + >&2 echo "Loading the profile: ${LOADED_PROFILE}" + else + if [[ -d "${PROFILE_DIR}" ]] ; then + echo "${PROFILE_DIR}/$(ls -1 "${PROFILE_DIR}/*.conf" | head -n 1)" + else + echo "${PROFILE_DIR}/${NEW_CONFIG_FILE}.conf" + fi + fi +} + _usage(){ cat <${i}" + done + } + _get_index_of_value(){ + # run with function, value to look for as first argument, and array to look in as 2nd argument, such function as + # _get_index_of_value "${VIDEO_INPUT_CHOICE}" "${VIDEO_INPUT_OPTIONS[@]}" + VALUE="${1}" + shift + LIST=( "$@" ) + INDEX=0 + MATCH="" + for ITEM in "${LIST[@]}" ; do + if [[ "${VALUE}" = "${ITEM}" ]] ; then + MATCH="$INDEX" + fi + (( ++INDEX )) + done + if [[ -n "${MATCH}" ]] ; then + echo -n "${MATCH}" + fi + } + SELECTION="$(_get_index_of_value "${!VARIABLE_NAME}" "${OPTION_LIST[@]}")" if [[ "${VARIABLE_NAME}" == "DECKLINK_INPUT_CHOICE" ]] ; then LIST="_get_decklink_input_list" @@ -386,6 +445,8 @@ _gtk_vbox_list() { LIST="_get_dvrescue_input_list" elif [[ "${VARIABLE_NAME}" == "AUDIO_DEV_CHOICE" ]] ; then LIST="_get_audio_device_list" + elif [[ "${VARIABLE_NAME}" == "SELECTED_PROFILE" ]] ; then + LIST="_get_profile_list" else LIST="$(_expand_list2items "${OPTION_LIST[@]}")" fi @@ -408,6 +469,9 @@ _gtk_vbox_list() { elif [[ "${VARIABLE_NAME}" == "DV_CONTAINER_CHOICE" ]] && $DVPACKAGER_INSTALLED ; then echo 'disable:DV_RESCUE_OPTION_TC enable:DV_RESCUE_OPTION_TC' + elif [[ "${VARIABLE_NAME}" == "SELECTED_PROFILE" ]] ; then + echo 'echo "$SELECTED_PROFILE" > "'$PROFILE_SELECTED_FILE'" + VRECORD_SETTINGS_SUMMARY' fi } @@ -449,16 +513,26 @@ _gtk_vbox_list() { fi } + if [[ "${OPTION_STYLE}" == "list" ]] ; then + OPTION_ATTRIBUTES=" selection-mode=\"1\" selected-row=\"${SELECTION}\"" + OPTION_ELEMENTS="${WIDTH}" + elif [[ "${OPTION_STYLE}" == "comboboxtext" ]] ; then + unset OPTION_ATTRIBUTES + if [[ -n "${!VARIABLE_NAME}" ]] ; then + OPTION_ELEMENTS="${!VARIABLE_NAME}" + fi + fi + echo " - - ${WIDTH} + <${OPTION_STYLE}${OPTION_ATTRIBUTES}> ${VARIABLE_NAME} + ${OPTION_ELEMENTS} ${LIST} $(_get_list_extras) - + $(_get_vbox_extras) " } @@ -706,31 +780,6 @@ _get_audio_dev_num(){ } _set_up_edit_form() { - _expand_list2items(){ - LIST=( "$@" ) - for i in "${LIST[@]}" ; do - echo "${i}" - done - } - _get_index_of_value(){ - # run with function, value to look for as first argument, and array to look in as 2nd argument, such function as - # _get_index_of_value "${VIDEO_INPUT_CHOICE}" "${VIDEO_INPUT_OPTIONS[@]}" - VALUE="${1}" - shift - LIST=( "$@" ) - INDEX=0 - MATCH="" - for ITEM in "${LIST[@]}" ; do - if [[ "${VALUE}" = "${ITEM}" ]] ; then - MATCH="$INDEX" - fi - (( ++INDEX )) - done - if [[ -n "${MATCH}" ]] ; then - echo -n "${MATCH}" - fi - } - # initialize deckcontrol temp files FFMPEG_STATUS_TMP="$(_maketemp .ffmpeg.status.txt)" DECKCONTROL_STATUS_TMP="$(_maketemp .deckcontrol.status.txt)" @@ -741,9 +790,6 @@ echo "disabled" > "$DECKCONTROL_STATUS_TMP" echo "--:--:--:--" > "$DECKCONTROL_TIMECODE_TMP" echo "disabled" > "$DVRESCUE_STATUS_TMP" -STARTUP_VIEW_TMP=$(_maketemp .startup.txt) -echo "MAIN" > "${STARTUP_VIEW_TMP}" - SIDECAR_FILES_GUI=" @@ -1212,6 +1258,40 @@ AUDIO_INPUT_GUI=$(cat << AUDIO_INPUT_FORM AUDIO_INPUT_FORM ) +export SETTINGS_DIALOG=' + + + + + '"${DECKLINK_INPUT_GUI}"' + '"${DVRESCUE_INPUT_GUI}"' + '"${AUDIO_INPUT_GUI}"' + '"${OPTIONAL_TOOLS_GUI}"' + DEVICE_INPUT_CHOICE + VRECORD_OUTPUT_NAME + enable:record_button + disable:record_button + enable:record_button_main + disable:record_button_main + enable:passthrough_button + disable:passthrough_button + + + + + + INPUTSETTINGS + _update_config_file + +' + export MAIN_DIALOG=' @@ -1237,14 +1317,6 @@ export MAIN_DIALOG=' "'"${RESOURCE_PATH}/vrecord_logo_audio.png"'" audiopassthrough - + + + + + + + NEW_PROFILE + + + + + + @@ -1272,25 +1372,6 @@ export MAIN_DIALOG=' MAIN VRECORD_SETTINGS_SUMMARY - - - - '"${DECKLINK_INPUT_GUI}"' - '"${DVRESCUE_INPUT_GUI}"' - '"${AUDIO_INPUT_GUI}"' - '"${OPTIONAL_TOOLS_GUI}"' - DEVICE_INPUT_CHOICE - VRECORD_OUTPUT_NAME - enable:record_button - disable:record_button - enable:record_button_main - disable:record_button_main - enable:passthrough_button - disable:passthrough_button - - - INPUTSETTINGS - @@ -1320,12 +1401,6 @@ export MAIN_DIALOG=' - - STARTUP_VIEW - '"${STARTUP_VIEW:-MAIN}"' - '"${STARTUP_VIEW_TMP}"' - STARTUP_VIEW - @@ -1423,26 +1498,6 @@ export MAIN_DIALOG=' - -