Skip to content

Commit bf26a95

Browse files
committed
mencoder and mencoder+xvid updates/optimizations. Selectively apply parts of patches to close #3064. I don't know what the maker of the patch was reading, but the man page clearly states that the -vf (formerly -vop) filters are applied in reverse, and the correct order should be scale,denoise,deint,crop (which would then be reversed by mencoder to run them as crop->deint->denoise->scale)
1 parent 6dcda03 commit bf26a95

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

nuvexport/export/mencoder.pm

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ package export::mencoder;
5050
sub build_vop_line{
5151
my $cmdline = shift;
5252
my $vop = '';
53-
while($cmdline =~ m/.*?-vop\s+([^\s]+)\s/gs){
53+
while ($cmdline =~ m/.*?-vf\s+([^\s]+)\s/gs){
5454
$vop .= ",$1";
5555
}
5656
$vop =~ s/^,+//;
5757
$vop =~ s/,+$//;
58-
$cmdline =~ s/-vop\s+[^\s]+\s/ /g;
59-
$cmdline .= " -vop $vop ";
58+
$cmdline =~ s/-vf\s+[^\s]+\s/ /g;
59+
$cmdline .= " -vf $vop ";
6060
return $cmdline;
6161
}
6262

@@ -79,7 +79,7 @@ package export::mencoder;
7979
# Not an mpeg mencoder can not do cutlists (from what I can tell..)
8080
unless ($episode->{'finfo'}{'is_mpeg'} && !$self->{'use_cutlist'}) {
8181
# swap red/blue -- used with svcd, need to see if it's needed everywhere
82-
# $mencoder .= ' -vop rgb2bgr '; #this is broken in mencoder 1.0preX
82+
# $mencoder .= ' -vf rgb2bgr '; #this is broken in mencoder 1.0preX
8383
# Set up the fifo dirs?
8484
if (-e "/tmp/fifodir_$$/vidout" || -e "/tmp/fifodir_$$/audout") {
8585
die "Possibly stale mythtranscode fifo's in /tmp/fifodir_$$/.\nPlease remove them before running nuvexport.\n\n";
@@ -109,10 +109,19 @@ package export::mencoder;
109109
.':fps='.$episode->{'finfo'}{'fps'}
110110
;
111111
}
112+
# Add any additional settings from the child module.
112113
# NOTE: this comes before the standard filters below, because
113-
# mencoder applies filters in reverse
114-
# Add any additional settings from the child module
114+
# mencoder applies filters in reverse, and we want things like "scale" to
115+
# run last.
115116
$mencoder .= ' '.$self->{'mencoder_xtra'};
117+
# Filters (remember, mencoder reads these in reverse order (so deint should be last if used)
118+
# Normally you would do -vf filter1=<val>,filter2=<val>,lavcdeint...
119+
if ($self->{'noise_reduction'}) {
120+
$mencoder .= " -vf denoise3d";
121+
}
122+
if ($self->{'deinterlace'}) {
123+
$mencoder .= " -vf lavcdeint";
124+
}
116125
# Crop?
117126
if ($self->{'crop'}) {
118127
my $t = sprintf('%.0f', ($self->val('crop_top') / 100) * $episode->{'finfo'}{'height'});
@@ -127,18 +136,7 @@ package export::mencoder;
127136
# Figure out the new width/height
128137
my $w = $episode->{'finfo'}{'width'} - $r - $l;
129138
my $h = $episode->{'finfo'}{'height'} - $t - $b;
130-
$mencoder .= " -vop crop=$w:$h:$l:$t " if ($t || $r || $b || $l);
131-
}
132-
# Use the cutlist? (only for mpeg files -- nuv files are handled by mythtranscode)
133-
# Can we cut with mencoder?
134-
# Filters (remember, mencoder reads these in reverse order (so deint should be last if used)
135-
# Normally you would do -vop filter1=<val>,filter2=<val>,lavcdeint...
136-
if ($self->{'noise_reduction'}) {
137-
$mencoder .= " -vf denoise3d";
138-
}
139-
if ($self->{'deinterlace'}) {
140-
$mencoder .= " -vf lavcdeint";
141-
#smartyuv|smartdeinter|dilyuvmmx
139+
$mencoder .= " -vf crop=$w:$h:$l:$t " if ($t || $r || $b || $l);
142140
}
143141
# Output directory set to null means the first pass of a multipass
144142
if (!$self->{'path'} || $self->{'path'} =~ /^\/dev\/null\b/) {
@@ -159,7 +157,7 @@ package export::mencoder;
159157
fifos_wait("/tmp/fifodir_$$/");
160158
push @tmpfiles, "/tmp/fifodir_$$", "/tmp/fifodir_$$/audout", "/tmp/fifodir_$$/vidout";
161159
}
162-
#Fix -vop options before we execute mencoder
160+
#Fix -vf options before we execute mencoder
163161
$mencoder = build_vop_line($mencoder);
164162
# Execute mencoder
165163
print "Starting mencoder.\n" unless ($DEBUG);

nuvexport/export/mencoder/XviD.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ package export::mencoder::XviD;
118118
my $self = shift;
119119
my $episode = shift;
120120
# Build the mencoder string
121-
my $params = " -ovc xvid -vop scale=$self->{'width'}:$self->{'height'}"
121+
my $params = " -ovc xvid -vf scale=$self->{'width'}:$self->{'height'}"
122122
#." -N 0x55" # make *sure* we're exporting mp3 audio
123123

124124
#." -oac mp3lame -lameopts vbr=3:br=$self->{'a_bitrate'}"
@@ -137,8 +137,8 @@ package export::mencoder::XviD;
137137
print "First pass...\n";
138138
$self->{'mencoder_xtra'} = " $params"
139139
." -passlogfile /tmp/xvid.$$.log"
140-
." -nosound"
141-
." -xvidencopts bitrate=$self->{'v_bitrate'}:pass=1 ";
140+
." -oac copy"
141+
." -xvidencopts bitrate=$self->{'v_bitrate'}:pass=1:quant_type=mpeg:threads=2:keyframe_boost=10:kfthreshold=1:kfreduction=20 ";
142142
$self->SUPER::export($episode, '', 1);
143143
# Restore the path
144144
$self->{'path'} = $path_bak;
@@ -147,7 +147,7 @@ package export::mencoder::XviD;
147147
$self->{'mencoder_xtra'} = " $params"
148148
." -oac mp3lame -lameopts vbr=3:br=$self->{'a_bitrate'}"
149149
." -passlogfile /tmp/xvid.$$.log"
150-
." -xvidencopts bitrate=$self->{'v_bitrate'}:pass=2 ";
150+
." -xvidencopts bitrate=$self->{'v_bitrate'}:pass=2:quant_type=mpeg:threads=2:keyframe_boost=10:kfthreshold=1:kfreduction=20 ";
151151
}
152152
# Single pass
153153
else {

0 commit comments

Comments
 (0)