Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspect ratio handling #331

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions makederiv
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,21 @@ while [[ "${@}" != "" ]] ; do
if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then
INPUTOPTIONS+=(-vcodec libopenjpeg)
fi
CROPADJ=$(_readingestlog "crop_filter")
if [[ -n "${CROPADJ}" ]] ; then
_report -dt "A directive to crop the input object with ${CROPADJ} was found in the capture.log. Will apply."
fi
if [[ "${CROPDETECT}" = "Y" && -z "${CROPADJ}" ]] ; then
_get_cropdetection "${SOURCEFILE}"
fi
if [[ -n "${CROPADJ}" ]] ; then
_add_video_filter "${CROPADJ}"
WIDTH=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f1)
HEIGHT=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f2)
DAR="(${WIDTH}/${HEIGHT})*${SAR}"
fi
if [[ "${OUTPUT_TYPE}" == "broadcast" ]] ; then
_get_broadcastduration "${SOURCEFILE}"
if [ "${CROPDETECT}" = "Y" ] ; then
_get_cropdetection "${SOURCEFILE}"
_add_video_filter "${CROPADJ}"
WIDTH=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f1)
HEIGHT=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f2)
DAR="(${WIDTH}/${HEIGHT})*${SAR}"
fi
# set options for zeroing timecode if input is MXF
if [[ "${FORMAT}" == "mxf" ]] ; then
metadata_option="-metadata"
Expand Down Expand Up @@ -455,13 +461,7 @@ while [[ "${@}" != "" ]] ; do
_add_video_filter "setdar=16/9"
_add_video_filter "fps=fps=ntsc"
MIDDLEOPTIONS+=("${MIDDLEOPTIONSXDCAM[@]}")
elif [ $(echo "scale=3 ; ${DARRATIO} > (16/9)" | bc -l) = 1 ] ; then
_add_video_filter "scale=size=hd1080:interl=1:force_original_aspect_ratio=decrease"
_add_video_filter "pad=1920:1080:(ow-iw)/2:(oh-ih)/2"
_add_video_filter "setdar=16/9"
_add_video_filter "fps=fps=ntsc"
MIDDLEOPTIONS+=("${MIDDLEOPTIONSXDCAM[@]}")
elif [ $(echo "scale=3 ; $DARRATIO > (3/2)" | bc -l) = 1 -o "${ADDSLATE}" = "Y" ] ; then
elif [ $(echo "scale=3 ; $DARRATIO > (3/2)" | bc -l) = 1 -o "${HEIGHT}" -gt "512" -o "${ADDSLATE}" = "Y" ] ; then
_add_video_filter "scale=size=hd1080:interl=1:force_original_aspect_ratio=decrease"
_add_video_filter "pad=1920:1080:(ow-iw)/2:(oh-ih)/2"
_add_video_filter "setdar=16/9"
Expand Down
15 changes: 7 additions & 8 deletions mmfunctions
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,6 @@ _find_input (){
FFMPEGINPUT+=(-i)
FFMPEGINPUT+=("${SOURCEFILE}")
else
VOLADJUST="N"
INPUTOPTIONS+=(-f concat)
INPUTOPTIONS+=(-safe 0)
FFCONCATFILE="$(_maketemp).ffconcat"
Expand Down Expand Up @@ -1116,9 +1115,6 @@ _find_input (){
if [[ -n "${LISTCHAPTERS}" ]]; then
_report -d "Found this chapter list:"
_report -d "${LISTCHAPTERS}"
unset FFMPEGINPUT
INPUTOPTIONS+=(-f concat)
INPUTOPTIONS+=(-safe 0)
FFCONCATFILE=$(_maketemp)
while read chapter ; do
STARTTIME=$(echo "${chapter}" | cut -d- -f1)
Expand Down Expand Up @@ -1149,6 +1145,9 @@ _find_input (){
echo "inpoint ${STARTTIME}" >> "${FFCONCATFILE}"
echo "outpoint ${ENDTIME}" >> "${FFCONCATFILE}"
done < <(echo "${LISTCHAPTERS}")
unset FFMPEGINPUT
FFMPEGINPUT+=(-f concat)
FFMPEGINPUT+=(-safe 0)
FFMPEGINPUT+=(-i)
FFMPEGINPUT+=("${FFCONCATFILE}")
fi
Expand Down Expand Up @@ -1272,7 +1271,7 @@ _get_audio_mapping(){
LOUD_ADJ=$(_readingestlog "loudness_adjustment")
fi
if [ ! "${LOUD_ADJ}" ] ; then
_get_volume_adjustment "${SOURCEFILE}"
_get_volume_adjustment "${FFMPEGINPUT[@]}"
fi
if [[ "${measured_I}" == "inf" ]] || [[ "${measured_I}" == "-inf" ]] ; then
VOLADJUST="N"
Expand Down Expand Up @@ -1435,7 +1434,7 @@ _get_volume_adjustment(){
LOUD_ADJ=""
LOUDNESS_OPT_START=""
LOUDNESS_OPT_END=""
INPUT_MOVIE="${1}"
VOL_FFMPEG_INPUT="${*}"
if [[ -n "${INTIME}" ]] ; then
_report -dt "Loudness reading will start at intime (${INTIME})."
LOUDNESS_OPT_START="-ss ${INTIME}"
Expand All @@ -1444,8 +1443,8 @@ _get_volume_adjustment(){
_report -dt "Loudness reading will end at outtime (${OUTTIME})."
LOUDNESS_OPT_END="-to ${OUTTIME}"
fi
_report -dt "Getting loudness data for $(basename "${INPUT_MOVIE}") ..."
LOUDNESS_DATA=$(ffmpeg -nostdin ${LOUDNESS_OPT_START} -i "${1}" ${LOUDNESS_OPT_END} -vn -filter_complex "${AUDIOFILTERCHAIN},loudnorm=print_format=json" -f null - 2>&1)
_report -dt "Getting loudness data for '${VOL_FFMPEG_INPUT[*]}' ..."
LOUDNESS_DATA=$(ffmpeg -nostdin ${LOUDNESS_OPT_START} ${VOL_FFMPEG_INPUT[*]} ${LOUDNESS_OPT_END} -vn -filter_complex "${AUDIOFILTERCHAIN},loudnorm=print_format=json" -f null - 2>&1)
VOLUME_EXIT_CODE="${?}"
if [ "${VOLUME_EXIT_CODE}" -ne 0 ] ; then
_report -wt "Volume analysis for ${INPUT_MOVIE} exited with ${VOLUME_EXIT_CODE}."
Expand Down