Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # idetect.sh
- # attempts to detect if video is interlaced
- # "should be" non-destructive
- AUTHOR="Chris Reid"
- EMAIL="spikeysnack@gmail.com"
- DATE="13 FEB 2017"
- FF=$(which ffmpeg)
- # you can try more or less frames, accuracy improves with more, but takes longer
- frames=256
- # throwing away video so just go raw
- format="rawvideo"
- # example output
- #[Parsed_idet_0 @ 0x38e3000] Single frame detection: TFF:0 BFF:368 Progressive:101 Undetermined:44
- #[Parsed_idet_0 @ 0x38e3000] Multi frame detection: TFF:0 BFF:481 Progressive:10 Undetermined:22
- # filter the relevant part
- OUT=$("${FF}" -filter:v idet -frames:v "${frames}" -an -f "${format}" -y /dev/null \
- -i "${1}" 2>&1 | grep 'Parsed_idet' )
- # parse into array
- testString="${OUT}"
- array=( $testString )
- # iterate the array
- alen=${#array[@]} # num items in array
- for n in $(seq 0 $alen) #
- do
- # Top Field First (TFF) or Bottom Field First (BFF)
- if [ "${array[$n]:0:3}" == "TFF" ] || [ "${array[$n]:0:3}" == "BFF" ]; then
- echo "${array[$n]}"
- S="${array[$n]}"
- N="${S#*:}"
- # echo "N" "${N}"
- fi
- if [ "${array[$n]:0:11}" == "Progressive" ] ; then
- echo "${array[$n]}"
- S="${array[$n]}"
- P="${S#*:}"
- fi
- done
- # colors
- normal="$(tput sgr0)"
- black="$(tput setaf 0)"
- red="$(tput setaf 1)"
- green="$(tput setaf 2)"
- # decisions
- if [ $((N)) -gt 0 ] && [ $((P)) -lt $((N)) ] ; then
- echo -e "${green}YES probably interlaced${normal}"
- else
- echo -e "${red}NO probably not interlaced ${normal}"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement