Skip to content

Commit

Permalink
make "crop" an option, instead of forcing it
Browse files Browse the repository at this point in the history
filename illegal-char fixes
perform tmpfile-wipe after each encode, instead of just at END, to keep un-muxed files from piling up.
  • Loading branch information
ex-nerd committed Sep 29, 2004
1 parent 2d004bf commit a8db678
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 24 deletions.
1 change: 1 addition & 0 deletions trunk/export/DVCD.pm
Expand Up @@ -26,6 +26,7 @@ package export::DVCD;
# Transcode-related settings
'denoise' => 1,
'deinterlace' => 1,
'crop' => 1,
};
bless($self, $class);

Expand Down
1 change: 1 addition & 0 deletions trunk/export/DVD.pm
Expand Up @@ -29,6 +29,7 @@ package export::DVD;
# Transcode-related settings
'denoise' => 1,
'deinterlace' => 1,
'crop' => 1,
# DVD-specific settings
'quantisation' => 5, # 4 through 6 is probably right...
'a_bitrate' => 384,
Expand Down
1 change: 1 addition & 0 deletions trunk/export/SVCD.pm
Expand Up @@ -29,6 +29,7 @@ package export::SVCD;
# Transcode-related settings
'denoise' => 1,
'deinterlace' => 1,
'crop' => 1,
# SVCD-specific settings
'quantisation' => 5, # 4 through 6 is probably right...
'a_bitrate' => 192,
Expand Down
1 change: 1 addition & 0 deletions trunk/export/VCD.pm
Expand Up @@ -26,6 +26,7 @@ package export::VCD;
# Transcode-related settings
'denoise' => 1,
'deinterlace' => 1,
'crop' => 1,
};
bless($self, $class);

Expand Down
1 change: 1 addition & 0 deletions trunk/export/XviD.pm
Expand Up @@ -32,6 +32,7 @@ package export::XviD;
# Transcode-related settings
'denoise' => 1,
'deinterlace' => 1,
'crop' => 1,
# VBR-specific settings
'vbr' => 1, # This enables vbr, and the multipass/quantisation options
'multipass' => 0, # You get multipass or quantisation, multipass will override
Expand Down
14 changes: 10 additions & 4 deletions trunk/export/transcode.pm
Expand Up @@ -23,6 +23,7 @@ package export::transcode;
$cli_args{'denoise|noise_reduction:s'} = 1; # Enable noise reduction
$cli_args{'deinterlace:s'} = 1; # Transcode-related settings
$cli_args{'zoom_filter:s'} = 1; # Which zoom filter to use
$cli_args{'crop'} = 1; # Crop out broadcast overscan

# This superclass defines several object variables:
#
Expand Down Expand Up @@ -71,9 +72,14 @@ package export::transcode;
'yesno',
$self->{'deinterlace'} ? 'Yes' : 'No');
# Crop video to get rid of broadcast padding
# $self->{'crop'} = query_text('Crop ',
# 'yesno',
# $self->{'crop'} ? 'Yes' : 'No');
if ($Args{'crop'}) {
$self->{'crop'} = 1;
}
else {
$self->{'crop'} = query_text('Crop broadcast overscan (2% border)?',
'yesno',
$self->{'crop'} ? 'Yes' : 'No');
}
}

sub export {
Expand Down Expand Up @@ -117,7 +123,7 @@ package export::transcode;
;
}
# Crop?
if (1 || $self->{'crop'}) {
if ($self->{'crop'}) {
my $w = sprintf('%.0f', .02 * $episode->{'finfo'}{'width'});
my $h = sprintf('%.0f', .02 * $episode->{'finfo'}{'height'});
$transcode .= " -j $h,$w,$h,$w" if ($h || $w);
Expand Down
21 changes: 11 additions & 10 deletions trunk/mythtv/recordings.pm
Expand Up @@ -91,16 +91,17 @@ package mythtv::recordings;
$description = 'No Description' unless ($description =~ /\S/);
# Build a clean filename
my $outfile = 'Untitled';
if ($show ne 'Untitled' and $episode ne 'Untitled') {
$outfile = "$show - $episode";
}
elsif($show ne 'Untitled') {
$outfile = $show;
}
elsif($episode ne 'Untitled') {
$outfile = $episode;
}
$outfile =~ s/(?:[:\?&\/]+\s*?)+\s?/-/sg;
if ($show ne 'Untitled' and $episode ne 'Untitled') {
$outfile = "$show - $episode";
}
elsif($show ne 'Untitled') {
$outfile = $show;
}
elsif($episode ne 'Untitled') {
$outfile = $episode;
}
$outfile =~ s/(?:[\/\\\:\*\?\<\>\|\-]+\s*?)+\s?/-/sg;
$outfile =~ tr/"/'/s;
#$description =~ s/(?:''|``)/"/sg;
push @{$Shows{$show}}, {'filename' => "$video_dir/$file",
'channel' => $channel,
Expand Down
26 changes: 16 additions & 10 deletions trunk/nuv_export/shared_utils.pm
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2004.09.24 (xris)
#Last Updated: 2004.09.28 (xris)
#
# nuv_export::shared_utils
#
Expand All @@ -14,7 +14,7 @@ package nuv_export::shared_utils;
use Exporter;
our @ISA = qw/ Exporter /;

our @EXPORT = qw/ &clear &find_program &num_cpus &shell_escape &wrap &system
our @EXPORT = qw/ &clear &find_program &num_cpus &shell_escape &wrap &system &wipe_tmpfiles
@Exporters %Prog %Args %cli_args $DEBUG
$is_child
@tmpfiles %children
Expand All @@ -37,14 +37,7 @@ package nuv_export::shared_utils;
END {
if (!$is_child) {
# Clean up temp files/directories
foreach my $file (@tmpfiles) {
if (-d $file) {
rmdir $file;
}
elsif (-e $file) {
unlink $file;
}
}
wipe_tmpfiles();
# Make sure any child processes also go away
if (%children) {
foreach my $child (keys %children) {
Expand Down Expand Up @@ -202,5 +195,18 @@ package nuv_export::shared_utils;
}
}

# Remove tmpfiles
sub wipe_tmpfiles {
foreach my $file (@tmpfiles) {
if (-d $file) {
rmdir $file;
}
elsif (-e $file) {
unlink $file;
}
}
@tmpfiles = ();
}


# vim:ts=4:sw=4:ai:et:si:sts=4
2 changes: 2 additions & 0 deletions trunk/nuvexport
Expand Up @@ -91,6 +91,8 @@
my $start = time();
# Encode
$exporter->export($episode);
# Remove tmpfiles
wipe_tmpfiles();
# Report how long the encode lasted
print "\nEncode finished: ".localtime()."\n";
my $seconds = time() - $start;
Expand Down

0 comments on commit a8db678

Please sign in to comment.