sweep: portable VFR detection (mawk has no asort; the check silently passed every file on Debian)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -52,10 +52,12 @@ probe() {
|
|||||||
local head; head=$(head -c 2097152 "$f" | grep -aob -m3 -E 'moov|mdat|moof' | tr '\n' ' ')
|
local head; head=$(head -c 2097152 "$f" | grep -aob -m3 -E 'moov|mdat|moof' | tr '\n' ' ')
|
||||||
if grep -q moof <<<"$head"; then echo "remux fragmented"; return; fi
|
if grep -q moof <<<"$head"; then echo "remux fragmented"; return; fi
|
||||||
# real VFR test: do the gaps between the first ~400 frames vary? (dts is monotonic even with B-frames)
|
# real VFR test: do the gaps between the first ~400 frames vary? (dts is monotonic even with B-frames)
|
||||||
|
# portable awk (Debian's mawk has no asort): deltas -> sort -n -> median + spread
|
||||||
local vfr; vfr=$(ffprobe -v error -select_streams v:0 -show_entries packet=dts_time -of csv=p=0 -read_intervals '%+#400' "$f" 2>/dev/null |
|
local vfr; vfr=$(ffprobe -v error -select_streams v:0 -show_entries packet=dts_time -of csv=p=0 -read_intervals '%+#400' "$f" 2>/dev/null |
|
||||||
awk 'NF && $1!="N/A" { if (p!="") d[n++]=$1-p; p=$1 }
|
awk 'NF && $1!="N/A" { if (p!="") print $1-p; p=$1 }' | sort -n |
|
||||||
|
awk '{ d[n++]=$1 }
|
||||||
END { if (n<20) { print "cfr"; exit }
|
END { if (n<20) { print "cfr"; exit }
|
||||||
for(i=0;i<n;i++) a[i]=d[i]; asort(a); med=a[int(n/2)]; if (med<=0) { print "cfr"; exit }
|
med=d[int(n/2)]; if (med<=0) { print "cfr"; exit }
|
||||||
bad=0; for(i=0;i<n;i++){ x=d[i]-med; if(x<0)x=-x; if (x > med*0.25) bad++ }
|
bad=0; for(i=0;i<n;i++){ x=d[i]-med; if(x<0)x=-x; if (x > med*0.25) bad++ }
|
||||||
print (bad > n*0.02) ? "vfr" : "cfr" }')
|
print (bad > n*0.02) ? "vfr" : "cfr" }')
|
||||||
[[ $vfr == vfr ]] && { echo "encode vfr"; return; }
|
[[ $vfr == vfr ]] && { echo "encode vfr"; return; }
|
||||||
|
|||||||
Reference in New Issue
Block a user