Debian Codegraph @

etc/FFMS2.avsi

raw
1 # FFmpegSource 2.22 helper functions
2 # Created by TheFluff
3
4 function FFFormatTime(int ms) {
5
6 s = ms / 1000
7 ms = ms % 1000
8 m = s / 60
9 s = s % 60
10 h = m / 60
11 m = m % 60
12
13 return ms < 0 ? "<Unknown>" : string(h) + ":" + string(m,"%02.0f") + ":" + string(s,"%02.0f") + "." + string(ms,"%03.0f")
14 }
15
16 function FFColorSpace(int i) {
17 i=(i<0||i>10) ? 2 : i
18 return Select(i,"RGB","BT709 (ITU-R Rec.709)","Unspecified","Unspecified","FCC","BT470BG (ITU-R Rec.601)","SMPTE 170M (ITU-R Rec.601)","SMPTE 240M","YCoCg","BT2020 NCL","BT2020 NC")
19 }
20
21 function FFColorRange(int i) {
22 i=(i<0||i>2) ? 0 : i
23 return Select(i,"Unknown/Unspecified","Limited range","Full range")
24 }
25
26 function FFCropping(int l, int t, int r, int b) {
27 return "Left="+String(l)+" Top="+String(t)+" Right="+String(r)+" Bottom="+String(b)
28 }
29
30 function FFSampAR(int num, int den) {
31 return num > 0 ? String(num)+":"+String(den)+((num<=0 || den<=0)?"":string(Float(num)/den," (%.3f)")) : "Unknown/Unspecified"
32 }
33
34 function FFPictType(int ch) {
35 s=chr(ch)
36 s = s + (
37 \ ch==73?" (Intra)":ch==80?" (Predicted)":ch==66?" (Bi-dir predicted)":ch==83?" (S(GMC)-VOP MPEG4)"
38 \ : ch==105?" (Switching Intra)":ch==112?" (Switching Predicted)":ch==98?" (FF_BI_TYPE)"
39 \ : " (Unknown)")
40 return s
41 }
42
43 function FFInfo(clip c, bool "framenum", bool "frametype", bool "cfrtime", bool "vfrtime", string "varprefix",
44 \ bool "colorspace",bool "colorrange",bool "cropping",bool "sar",bool "version",bool "showprefix") {
45
46 framenum = default(framenum,true)
47 frametype = default(frametype,true)
48 cfrtime = default(cfrtime,true)
49 vfrtime = default(vfrtime,true)
50 varprefix = default(varprefix, FFVAR_PREFIX)
51 colorSpace = default(colorspace,true)
52 colorrange = default(colorrange,true)
53 cropping = default(cropping,true)
54 sar = default(sar,true)
55 version = default(version,true)
56 showprefix = default(showprefix,false)
57
58 c.frameevaluate("""
59 fftempstring = ""
60 varprefix = """" + varprefix + """"
61 """)
62
63 version ? frameevaluate("""fftempstring = fftempstring + "Version: " + FFGetVersion + "\n" """, after_frame=true) : nop()
64 framenum ? frameevaluate("""fftempstring = fftempstring + "Frame Number: " + string(current_frame) + " of " + string(framecount()) + "\n" """, after_frame=true) : nop()
65 frametype ? frameevaluate("""fftempstring = fftempstring + "Picture Type: " + FFPictType(eval(varprefix + "FFPICT_TYPE")) + "\n" """, after_frame=true) : nop()
66 cfrtime ? frameevaluate("""fftempstring = fftempstring + "CFR Time: " + FFFormatTime(round((current_frame * 1000) / framerate())) + "\n" """, after_frame=true) : nop()
67 vfrtime ? frameevaluate("""fftempstring = fftempstring + "VFR Time: " + FFFormatTime(eval(varprefix + "FFVFR_TIME")) + "\n" """, after_frame=true) : nop()
68 colorspace ? frameevaluate("""fftempstring = fftempstring + "ColorSpace: " + FFColorSpace(eval(varprefix + "FFCOLOR_SPACE")) + "\n" """, after_frame=true) : nop()
69 colorrange ? frameevaluate("""fftempstring = fftempstring + "Color Range: " + FFColorRange(eval(varprefix + "FFCOLOR_RANGE")) + "\n" """, after_frame=true) : nop()
70 cropping ? frameevaluate("""fftempstring = fftempstring + "Cropping: " + FFCropping(eval(varprefix + "FFCROP_LEFT"),eval(varprefix + "FFCROP_TOP"),eval(varprefix + "FFCROP_RIGHT"),eval(varprefix + "FFCROP_BOTTOM")) + "\n" """, after_frame=true) : nop()
71 sar ? frameevaluate("""fftempstring = fftempstring + "SAR: " + FFSampAR(eval(varprefix + "FFSAR_NUM"),eval(varprefix + "FFSAR_DEN")) + "\n" """, after_frame=true) : nop()
72 showprefix ? frameevaluate("""fftempstring = fftempstring + "Prefix: '" + varprefix + "'\n" """, after_frame=true) : nop()
73
74 return scriptclip("subtitle(fftempstring, lsp = 1)", after_frame=true)
75 }