1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* new binding {dim} to easily get video dimensions as int[]

This commit is contained in:
Reinhard Pointner 2012-07-10 06:20:01 +00:00
parent 24ea7ab334
commit 1dd86ad2b0
3 changed files with 19 additions and 11 deletions

View File

@ -14,6 +14,7 @@ import static net.sourceforge.tuned.StringUtilities.*;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
@ -232,33 +233,40 @@ public class MediaBindingBean {
@Define("resolution")
public String getVideoResolution() {
String width = getMediaInfo(StreamKind.Video, 0, "Width");
String height = getMediaInfo(StreamKind.Video, 0, "Height");
List<Integer> dim = getDimension();
if (width == null || height == null)
if (dim.contains(null))
return null;
// e.g. 1280x720
return width + 'x' + height;
return join(dim, "x");
}
@Define("ws")
public String getWidescreen() {
float width = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Width"));
float height = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Height"));
List<Integer> dim = getDimension();
// width-to-height aspect ratio greater than 1.37:1
return width / height > 1.37 ? "ws" : null;
return (float) dim.get(0) / dim.get(1) > 1.37f ? "ws" : null;
}
@Define("sdhd")
public String getVideoDefinitionCategory() {
String height = getMediaInfo(StreamKind.Video, 0, "Height");
List<Integer> dim = getDimension();
// SD (less than 720 lines) or HD (more than 720 lines)
return Integer.parseInt(height) < 720 ? "SD" : "HD";
return dim.get(0) >= 1280 || dim.get(1) >= 720 ? "HD" : "SD";
}
@Define("dim")
public List<Integer> getDimension() {
String width = getMediaInfo(StreamKind.Video, 0, "Width");
String height = getMediaInfo(StreamKind.Video, 0, "Height");
return Arrays.asList(width != null ? Integer.parseInt(width) : null, height != null ? Integer.parseInt(height) : null);
}

View File

@ -2,4 +2,4 @@
parameter.exclude: ^StreamKind|Count$
# preview expressions (keys are tagged so they can be sorted alphabetically)
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,sxe,s00e00,movie,vc,ac,cf,vf,af,resolution,hpi,ws,sdhd,source,group,crc32,fn,ext,file,pi,pn,lang,actors,director,genres,certification,rating,info.runtime,info.status,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,sxe,s00e00,movie,vc,ac,cf,vf,af,resolution,hpi,ws,sdhd,source,group,crc32,fn,ext,file,pi,pn,lang,actors,director,genres,certification,rating,dim,info.runtime,info.status,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language

View File

@ -207,7 +207,7 @@ class FormatDialog extends JDialog {
// initialize window properties
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setSize(520, 400);
setSize(540, 380);
}