Jelajahi Sumber

Support for maximum width and height

Zachary Kotlarek 13 tahun lalu
induk
melakukan
6d470ad09f
1 mengubah file dengan 18 tambahan dan 0 penghapusan
  1. 18 0
      encode.pl

+ 18 - 0
encode.pl

@@ -24,6 +24,8 @@ my $DEBUG               = 0;
 my $FORCE_MKV           = 0;
 my $AUDIO_COPY          = 0;
 my $STEREO_ONLY         = 0;
+my $HEIGHT              = undef();
+my $WIDTH               = undef();
 
 # Runtime debug mode
 if (defined($ENV{'DEBUG'}) && $ENV{'DEBUG'}) {
@@ -63,6 +65,14 @@ if ($ENV{'QUALITY'}) {
 	$HD_QUALITY = $ENV{'QUALITY'};
 }
 
+# Allow overrides for video height and width. The default is "same as source".
+if ($ENV{'HEIGHT'}) {
+	$HEIGHT = $ENV{'HEIGHT'};
+}
+if ($ENV{'WIDTH'}) {
+	$WIDTH = $ENV{'WIDTH'};
+}
+
 # Command-line parameters
 my ($in_file, $out_file, $title) = @ARGV;
 if (!defined($in_file) || length($in_file) < 1 || !-r $in_file) {
@@ -211,6 +221,14 @@ foreach my $title (keys(%titles)) {
 		$title_out_file =~ s/(\.\w{2,4})$/\-${title_text}${1}/;
 	}
 
+	# Limit the maximum height and width, if any is specified
+	if ($HEIGHT) {
+		push(@video_params, '--maxHeight', $HEIGHT);
+	}
+	if ($WIDTH) {
+		push(@video_params, '--maxWidth', $WIDTH);
+	}
+
 	# Output file
 	if (uc($title_out_file) eq uc($in_file)) {
 		$title_out_file =~ s/(\.\w{2,4})$/-recode${1}/;