I'm wondering what is the logic for determining the standard format with {vf} binding?
I'm working on an unrelated python script that I need to be able to parse the video resolution but I need the standard resolutions, not the actual resolutions in the case that the video has black bars cropped out, etc.
I know filebot handles this perfectly!
If you don't mind, could you share the logic and conditions so that I can recreate this feature for my script?
My script is only for personal use, but I understand if you don't want to share.
Thanks for maintaining filebot! No other renamer compares to it!
What is the logic for determining the standard format with {vf} ?
Re: What is the logic for determining the standard format with {vf} ?
e.g.
Code: Select all
resolution.steps.w: 15360 7680 3840 2040 1920 1280 1024 854 720 640 640 512 320 160
resolution.steps.h: 8640 4320 2160 1080 1080 720 576 576 480 480 360 240 240 120
Code: Select all
private final int[] ws;
private final int[] hs;
public VideoFormat() {
this.ws = getIntArrayProperty("resolution.steps.w");
this.hs = getIntArrayProperty("resolution.steps.h");
}
public int guessFormat(int width, int height) {
int ns = 0;
for (int i = 0; i < ws.length - 1; i++) {
if ((width >= ws[i] || height >= hs[i]) || (width > ws[i + 1] && height > hs[i + 1])) {
ns = hs[i];
break;
}
}
if (ns > 0) {
return ns;
}
throw new IllegalArgumentException(String.format("Illegal resolution: [%d, %d]", width, height));
}
Re: What is the logic for determining the standard format with {vf} ?
Code: Select all
365 @Define("vf")
366 public String getVideoFormat() {
367 int w = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Width"));
368 int h = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Height"));
369
370 // e.g. 720p, nobody actually wants files to be tagged as interlaced, e.g. 720i
371 return String.format("%dp", VideoFormat.DEFAULT_GROUPS.guessFormat(w, h));
372 }
[DOCS] FileBot Groovy Expression References