Skip to content

Instantly share code, notes, and snippets.

@dericed
Created December 11, 2019 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dericed/46ad833ef726600dca4104352d7ecab3 to your computer and use it in GitHub Desktop.
Save dericed/46ad833ef726600dca4104352d7ecab3 to your computer and use it in GitHub Desktop.
#!/bin/bash
_fix(){
FILE="${1}"
NAME="$(basename "${FILE}")"
PASP_OFFSET="$(mediaconch -mt "${FILE}" | xmlstarlet sel -N mt="https://mediaarea.net/mediatrace" -t -m "mt:MediaTrace/mt:media/mt:block[@name='File header']/mt:block[@name='Track']/mt:block[@name='Media']/mt:block[@name='Media Information']/mt:block[@name='Sample Table']/mt:block[@name='Sample Description']/mt:block[@name='Video']/mt:block[@name='Pixel Aspect Ratio']/mt:data[@name='hSpacing']" -v @offset)"
if [[ "${PASP_OFFSET}" = "" ]] ; then
echo "${NAME} has no pixel aspect ratio atom anyway, skipping"
else
echo "${NAME} has a pixel aspect ratio atom at ${PASP_OFFSET}"
sfk setbytes "${FILE}" "${PASP_OFFSET}" 0x000000200000001B -yes
fi
}
while [[ "${@}" != "" ]] ; do
INPUT="${1}"
shift
if [[ -f "${INPUT}" ]] ; then
_fix "${INPUT}"
else
"${1} was not a file, please run '${0} file.mov' "
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment