21 changes: 11 additions & 10 deletions trunk/export/ffmpeg/XviD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.15 (xris)
#Last Updated: 2005.02.16 (xris)
#
# export::ffmpeg::XviD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -10,6 +10,7 @@ package export::ffmpeg::XviD;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
Expand Down Expand Up @@ -60,19 +61,19 @@ package export::ffmpeg::XviD;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Audio Bitrate
if ($Args{'a_bitrate'}) {
$self->{'a_bitrate'} = $Args{'a_bitrate'};
die "Audio bitrate must be > 0\n" unless ($Args{'a_bitrate'} > 0);
if (arg('a_bitrate')) {
$self->{'a_bitrate'} = arg('a_bitrate');
die "Audio bitrate must be > 0\n" unless (arg('a_bitrate') > 0);
}
else {
$self->{'a_bitrate'} = query_text('Audio bitrate?',
'int',
$self->{'a_bitrate'});
}
# VBR options
if ($Args{'quantisation'}) {
die "Quantisation must be a number between 1 and 31 (lower means better quality).\n" if ($Args{'quantisation'} < 1 || $Args{'quantisation'} > 31);
$self->{'quantisation'} = $Args{'quantisation'};
if (arg('quantisation')) {
die "Quantisation must be a number between 1 and 31 (lower means better quality).\n" if (arg('quantisation') < 1 || arg('quantisation') > 31);
$self->{'quantisation'} = arg('quantisation');
$self->{'vbr'} = 1;
}
elsif (!$is_cli) {
Expand All @@ -96,9 +97,9 @@ package export::ffmpeg::XviD;
}
}
# Ask the user what audio and video bitrates he/she wants
if ($Args{'v_bitrate'}) {
die "Video bitrate must be > 0\n" unless ($Args{'v_bitrate'} > 0);
$self->{'v_bitrate'} = $Args{'v_bitrate'};
if (arg('v_bitrate')) {
die "Video bitrate must be > 0\n" unless (arg('v_bitrate') > 0);
$self->{'v_bitrate'} = arg('v_bitrate');
}
elsif (!$self->{'vbr'}) {
# make sure we have v_bitrate on the commandline
Expand Down
32 changes: 15 additions & 17 deletions trunk/export/generic.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.13 (xris)
#Last Updated: 2005.02.17 (xris)
#
# generic.pm
#
Expand All @@ -12,6 +12,7 @@ package export::generic;
use POSIX;

use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;

BEGIN {
Expand All @@ -29,8 +30,8 @@ package export::generic;
# These aren't used by all modules, but the routine to define them is here, so here they live
add_arg('height|v_res|h=i', 'Output height.');
add_arg('width|h_res|w=i', 'Output width.');
add_arg('deinterlace:s!', 'Deinterlace video.');
add_arg('noise_reduction|denoise|nr:s!', 'Enable noise reduction.');
add_arg('deinterlace!', 'Deinterlace video.');
add_arg('noise_reduction|denoise|nr!', 'Enable noise reduction.');
add_arg('crop!', 'Crop out broadcast overscan.');

# Gather generic export settings
Expand All @@ -41,22 +42,19 @@ package export::generic;
# Ask the user if he/she wants to use the cutlist
$self->{'use_cutlist'} = query_text('Enable Myth cutlist?',
'yesno',
(defined($Args{'cutlist'}) && $Args{'cutlist'} == 0) ? 'No' : 'Yes');
arg('cutlist', 1) ? 'No' : 'Yes');
# Video settings
if (!$self->{'audioonly'}) {
# Defaults?
$Args{'denoise'} = '' if (defined $Args{'denoise'} && $Args{'denoise'} eq '');
$Args{'deinterlace'} = 1 if (defined $Args{'deinterlace'} && $Args{'deinterlace'} eq '');
# Noise reduction?
$self->{'denoise'} = query_text('Enable noise reduction (slower, but better results)?',
$self->{'noise_reduction'} = query_text('Enable noise reduction (slower, but better results)?',
'yesno',
$self->{'denoise'} ? 'Yes' : 'No');
arg('noise_reduction', $self->{'noise_reduction'}) ? 'Yes' : 'No');
# Deinterlace video?
$self->{'deinterlace'} = query_text('Enable deinterlacing?',
'yesno',
$self->{'deinterlace'} ? 'Yes' : 'No');
arg('deinterlace', $self->{'deinterlace'}) ? 'Yes' : 'No');
# Crop video to get rid of broadcast padding
if ($Args{'crop'}) {
if (arg('crop')) {
$self->{'crop'} = 1;
}
else {
Expand Down Expand Up @@ -113,9 +111,9 @@ package export::generic;
sub query_resolution {
my $self = shift;
# Ask the user what resolution he/she wants
if ($Args{'width'}) {
die "Width must be > 0\n" unless ($Args{'width'} > 0);
$self->{'width'} = $Args{'width'};
if (arg('width')) {
die "Width must be > 0\n" unless (arg('width') > 0);
$self->{'width'} = arg('width');
}
else {
while (1) {
Expand Down Expand Up @@ -145,9 +143,9 @@ package export::generic;
}
}
# Ask about the height
if ($Args{'height'}) {
die "Height must be > 0\n" unless ($Args{'height'} > 0);
$self->{'height'} = $Args{'height'};
if (arg('height')) {
die "Height must be > 0\n" unless (arg('height') > 0);
$self->{'height'} = arg('height');
}
else {
while (1) {
Expand Down
29 changes: 15 additions & 14 deletions trunk/export/transcode.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.14 (xris)
#Last Updated: 2005.02.17 (xris)
#
# transcode.pm
#
Expand All @@ -15,6 +15,7 @@ package export::transcode;
use POSIX;

use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::recordings;

Expand All @@ -25,7 +26,7 @@ package export::transcode;
#
# path (defined by generic)
# use_cutlist (defined by generic)
# denoise
# noise_reduction
# deinterlace
# crop
# zoom_filter
Expand All @@ -35,8 +36,8 @@ package export::transcode;
sub init_transcode {
my $self = shift;
# Make sure we have transcode
$Prog{'transcode'} = find_program('transcode');
push @{$self->{'errors'}}, 'You need transcode to use this exporter.' unless ($Prog{'transcode'});
find_program('transcode')
or push @{$self->{'errors'}}, 'You need transcode to use this exporter.';
}

# Gather data for transcode
Expand All @@ -47,15 +48,15 @@ package export::transcode;
$self->SUPER::gather_settings($skip ? $skip - 1 : 0);
return if ($skip);
# Zoom Filter
if (defined $Args{'zoom_filter'}) {
if (!$Args{'zoom_filter'}) {
if (defined arg('zoom_filter')) {
if (!arg('zoom_filter')) {
$self->{'zoom_filter'} = 'B_spline';
}
elsif ($Args{'zoom_filter'} =~ /^(?:Lanczos3|Bell|Box|Mitchell|Hermite|B_spline|Triangle)$/) {
$self->{'zoom_filter'} = $Args{'zoom_filter'};
elsif (arg('zoom_filter') =~ /^(?:Lanczos3|Bell|Box|Mitchell|Hermite|B_spline|Triangle)$/) {
$self->{'zoom_filter'} = arg('zoom_filter');
}
else {
die "Unknown zoom_filter: $Args{'zoom_filter'}\n";
die "Unknown zoom_filter: ".arg('zoom_filter')."\n";
}
}
}
Expand All @@ -71,7 +72,7 @@ package export::transcode;
# Load nuv info
load_finfo($episode);
# Start the transcode command
$transcode = "nice -n $Args{'nice'} transcode"
$transcode = "$NICE transcode"
# -V is now the default, but need to keep using it because people are still using an older version of transcode
.' -V' # use YV12/I420 instead of RGB, for faster processing
.' --print_status 16' # Only print status every 16 frames -- prevents buffer-related slowdowns
Expand Down Expand Up @@ -105,16 +106,16 @@ package export::transcode;
die "Possibly stale mythtranscode fifo's in /tmp/fifodir_$$/.\nPlease remove them before running nuvexport.\n\n";
}
# Here, we have to fork off a copy of mythtranscode (no need to use --fifosync with transcode -- it seems to do this on its own)
$mythtranscode = "nice -n $Args{'nice'} mythtranscode --showprogress -p autodetect -c $episode->{'channel'} -s $episode->{'start_time_sep'} -f \"/tmp/fifodir_$$/\"";
$mythtranscode = "$NICE mythtranscode --showprogress -p autodetect -c $episode->{'channel'} -s $episode->{'start_time_sep'} -f \"/tmp/fifodir_$$/\"";
# On no-audio encodes, we need to do something to keep mythtranscode's audio buffers from filling up available RAM
# $mythtranscode .= ' --fifosync' if ($skip_audio);
# let transcode handle the cutlist -- got too annoyed with the first/last frame(s) showing up no matter what I told mythtranscode
#$mythtranscode .= ' --honorcutlist' if ($self->{'use_cutlist'});
}
# Figure out the input files
if ($episode->{'finfo'}{'is_mpeg'}) {
$transcode .= " -i $episode->{'filename'} -x ";
if ($episode->{'finfo'}{'mpeg_stream_type'} == 'pes') {
$transcode .= " -i $episode->{'filename'} -x ";
if ($episode->{'finfo'}{'mpeg_stream_type'} eq 'pes') {
$transcode .= 'vob';
}
else {
Expand Down Expand Up @@ -155,7 +156,7 @@ package export::transcode;
$transcode .= " -J smartyuv";
#smartyuv|smartdeinter|dilyuvmmx
}
if ($self->{'denoise'}) {
if ($self->{'noise_reduction'}) {
$transcode .= " -J yuvdenoise=mode=2";
}
# Add any additional settings from the child module
Expand Down
11 changes: 6 additions & 5 deletions trunk/export/transcode/DVCD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.01.26 (xris)
#Last Updated: 2005.02.17 (xris)
#
# export::transcode::DVCD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -10,6 +10,7 @@ package export::transcode::DVCD;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
Expand All @@ -24,7 +25,7 @@ package export::transcode::DVCD;
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'denoise' => 1,
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
};
Expand All @@ -33,8 +34,8 @@ package export::transcode::DVCD;
# Initialize and check for transcode
$self->init_transcode();
# Make sure that we have an mplexer
$Prog{'mplexer'} = find_program('tcmplex', 'mplex');
push @{$self->{'errors'}}, 'You need tcmplex or mplex to export a dvcd.' unless ($Prog{'mplexer'});
find_program('tcmplex')
or push @{$self->{'errors'}}, 'You need tcmplex to export a dvcd.';

# Any errors? disable this function
$self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
Expand Down Expand Up @@ -65,7 +66,7 @@ package export::transcode::DVCD;
# Execute the parent method
$self->SUPER::export($episode, ".$$");
# Multiplex the streams
my $command = "nice -n $Args{'nice'} tcmplex -m v $ntsc"
my $command = "$NICE tcmplex -m v $ntsc"
.' -i '.shell_escape($self->get_outfile($episode, ".$$.m1v"))
.' -p '.shell_escape($self->get_outfile($episode, ".$$.mpa"))
.' -o '.shell_escape($self->get_outfile($episode, '.mpg'));
Expand Down
23 changes: 12 additions & 11 deletions trunk/export/transcode/DVD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.14 (xris)
#Last Updated: 2005.02.17 (xris)
#
# export::transcode::DVD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -10,6 +10,7 @@ package export::transcode::DVD;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
Expand All @@ -27,7 +28,7 @@ package export::transcode::DVD;
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'denoise' => 1,
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# DVD-specific settings
Expand All @@ -40,8 +41,8 @@ package export::transcode::DVD;
# Initialize and check for transcode
$self->init_transcode();
# Make sure that we have an mplexer
$Prog{'mplexer'} = find_program('tcmplex', 'mplex');
push @{$self->{'errors'}}, 'You need tcmplex or mplex to export a dvd.' unless ($Prog{'mplexer'});
find_program('tcmplex')
or push @{$self->{'errors'}}, 'You need tcmplex to export a dvd.';

# Any errors? disable this function
$self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
Expand All @@ -54,8 +55,8 @@ package export::transcode::DVD;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Ask the user what audio bitrate he/she wants
$self->{'a_bitrate'} = $Args{'a_bitrate'} if ($Args{'a_bitrate'});
if (!$Args{'a_bitrate'} || $Args{'confirm'}) {
$self->{'a_bitrate'} = arg('a_bitrate') if (arg('a_bitrate'));
if (!arg('a_bitrate') || arg('confirm')) {
while (1) {
my $a_bitrate = query_text('Audio bitrate?',
'int',
Expand All @@ -74,8 +75,8 @@ package export::transcode::DVD;
}
# Ask the user what video bitrate he/she wants, or calculate the max bitrate
my $max_v_bitrate = 9500 - $self->{'a_bitrate'};
$self->{'v_bitrate'} = $Args{'v_bitrate'} if ($Args{'v_bitrate'});
if (!$Args{'v_bitrate'} || $Args{'confirm'}) {
$self->{'v_bitrate'} = arg('v_bitrate') if (arg('v_bitrate'));
if (!arg('v_bitrate') || arg('confirm')) {
while (1) {
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
'int',
Expand All @@ -93,8 +94,8 @@ package export::transcode::DVD;
}
}
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
$self->{'quantisation'} = $Args{'quantisation'} if ($Args{'quantisation'});
if (!$Args{'quantisation'} || $Args{'confirm'}) {
$self->{'quantisation'} = arg('quantisation') if (arg('quantisation'));
if (!arg('quantisation') || arg('confirm')) {
while (1) {
my $quantisation = query_text('VBR quality/quantisation (2-31)?', 'float', $self->{'quantisation'});
if ($quantisation < 2) {
Expand Down Expand Up @@ -131,7 +132,7 @@ package export::transcode::DVD;
# Execute the parent method
$self->SUPER::export($episode, ".$$");
# Multiplex the streams
my $command = "nice -n $Args{'nice'} tcmplex -m d $ntsc"
my $command = "$NICE tcmplex -m d $ntsc"
.' -i '.shell_escape($self->get_outfile($episode, ".$$.m2v"))
.' -p '.shell_escape($self->get_outfile($episode, ".$$.mpa"))
.' -o '.shell_escape($self->get_outfile($episode, '.mpg'));
Expand Down
19 changes: 10 additions & 9 deletions trunk/export/transcode/SVCD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.14 (xris)
#Last Updated: 2005.02.17 (xris)
#
# export::transcode::SVCD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -10,6 +10,7 @@ package export::transcode::SVCD;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
Expand All @@ -27,7 +28,7 @@ package export::transcode::SVCD;
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'denoise' => 1,
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# SVCD-specific settings
Expand All @@ -52,8 +53,8 @@ package export::transcode::SVCD;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Ask the user what audio bitrate he/she wants
$self->{'a_bitrate'} = $Args{'a_bitrate'} if ($Args{'a_bitrate'});
if (!$Args{'a_bitrate'} || $Args{'confirm'}) {
$self->{'a_bitrate'} = arg('a_bitrate') if (arg('a_bitrate'));
if (!arg('a_bitrate') || arg('confirm')) {
while (1) {
my $a_bitrate = query_text('Audio bitrate?',
'int',
Expand All @@ -73,8 +74,8 @@ package export::transcode::SVCD;
# Ask the user what video bitrate he/she wants, or calculate the max bitrate (2756 max, though we round down a bit since some dvd players can't handle the max)
# Then again, mpeg2enc seems to have trouble with bitrates > 2500
my $max_v_bitrate = 2742 - $self->{'a_bitrate'};
$self->{'v_bitrate'} = $Args{'v_bitrate'} if ($Args{'v_bitrate'});
if (!$Args{'v_bitrate'} || $Args{'confirm'}) {
$self->{'v_bitrate'} = arg('v_bitrate') if (arg('v_bitrate'));
if (!arg('v_bitrate') || arg('confirm')) {
$self->{'v_bitrate'} = ($max_v_bitrate < 2500) ? 2742 - $self->{'a_bitrate'} : 2500;
while (1) {
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
Expand All @@ -93,8 +94,8 @@ package export::transcode::SVCD;
}
}
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
$self->{'quantisation'} = $Args{'quantisation'} if ($Args{'quantisation'});
if (!$Args{'quantisation'} || $Args{'confirm'}) {
$self->{'quantisation'} = arg('quantisation') if (arg('quantisation'));
if (!arg('quantisation') || arg('confirm')) {
while (1) {
my $quantisation = query_text('VBR quality/quantisation (2-31)?', 'float', $self->{'quantisation'});
if ($quantisation < 2) {
Expand Down Expand Up @@ -150,7 +151,7 @@ package export::transcode::SVCD;
print "Not splitting because combined file size of chunks is < ".(0.97 * $self->{'split_every'} * 1024 * 1024).", which is the requested split size.\n";
}
# Multiplex the streams
my $command = "nice -n $Args{'nice'} tcmplex -m s $ntsc"
my $command = "$NICE tcmplex -m s $ntsc"
.($split_file ? ' -F '.shell_escape($split_file) : '')
.' -i '.shell_escape($self->get_outfile($episode, ".$$.m2v"))
.' -p '.shell_escape($self->get_outfile($episode, ".$$.mpa"))
Expand Down
11 changes: 6 additions & 5 deletions trunk/export/transcode/VCD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.01.26 (xris)
#Last Updated: 2005.02.17 (xris)
#
# export::transcode::VCD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -10,6 +10,7 @@ package export::transcode::VCD;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
Expand All @@ -24,7 +25,7 @@ package export::transcode::VCD;
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'denoise' => 1,
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# VCD-specific settings
Expand All @@ -35,8 +36,8 @@ package export::transcode::VCD;
# Initialize and check for transcode
$self->init_transcode();
# Make sure that we have an mplexer
$Prog{'mplexer'} = find_program('tcmplex', 'mplex');
push @{$self->{'errors'}}, 'You need tcmplex or mplex to export a vcd.' unless ($Prog{'mplexer'});
find_program('tcmplex', 'mplex')
or push @{$self->{'errors'}}, 'You need tcmplex or mplex to export a vcd.';

# Any errors? disable this function
$self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
Expand Down Expand Up @@ -87,7 +88,7 @@ package export::transcode::VCD;
print "Not splitting because combined file size of chunks is < ".(0.97 * $self->{'split_every'} * 1024 * 1024).", which is the requested split size.\n";
}
# Multiplex the streams
my $command = "nice -n $Args{'nice'} tcmplex -m v $ntsc"
my $command = "$NICE tcmplex -m v $ntsc"
.($split_file ? ' -F '.shell_escape($split_file) : '')
.' -i '.shell_escape($self->get_outfile($episode, ".$$.m1v"))
.' -p '.shell_escape($self->get_outfile($episode, ".$$.mpa"))
Expand Down
25 changes: 13 additions & 12 deletions trunk/export/transcode/XviD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.14 (xris)
#Last Updated: 2005.02.17 (xris)
#
# export::transcode::XviD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -10,6 +10,7 @@ package export::transcode::XviD;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
Expand All @@ -28,7 +29,7 @@ package export::transcode::XviD;
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'denoise' => 1,
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# VBR-specific settings
Expand Down Expand Up @@ -56,23 +57,23 @@ package export::transcode::XviD;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Audio Bitrate
if ($Args{'a_bitrate'}) {
$self->{'a_bitrate'} = $Args{'a_bitrate'};
die "Audio bitrate must be > 0\n" unless ($Args{'a_bitrate'} > 0);
if (arg('a_bitrate')) {
$self->{'a_bitrate'} = arg('a_bitrate');
die "Audio bitrate must be > 0\n" unless (arg('a_bitrate') > 0);
}
else {
$self->{'a_bitrate'} = query_text('Audio bitrate?',
'int',
$self->{'a_bitrate'});
}
# VBR options
if ($Args{'multipass'}) {
if (arg('multipass')) {
$self->{'multipass'} = 1;
$self->{'vbr'} = 1;
}
elsif ($Args{'quantisation'}) {
die "Quantisation must be a number between 1 and 31 (lower means better quality).\n" if ($Args{'quantisation'} < 1 || $Args{'quantisation'} > 31);
$self->{'quantisation'} = $Args{'quantisation'};
elsif (arg('quantisation')) {
die "Quantisation must be a number between 1 and 31 (lower means better quality).\n" if (arg('quantisation') < 1 || arg('quantisation') > 31);
$self->{'quantisation'} = arg('quantisation');
$self->{'vbr'} = 1;
}
elsif (!$is_cli) {
Expand Down Expand Up @@ -101,9 +102,9 @@ package export::transcode::XviD;
}
}
# Ask the user what audio and video bitrates he/she wants
if ($Args{'v_bitrate'}) {
die "Video bitrate must be > 0\n" unless ($Args{'v_bitrate'} > 0);
$self->{'v_bitrate'} = $Args{'v_bitrate'};
if (arg('v_bitrate')) {
die "Video bitrate must be > 0\n" unless (arg('v_bitrate') > 0);
$self->{'v_bitrate'} = arg('v_bitrate');
}
elsif ($self->{'multipass'} || !$self->{'vbr'}) {
# make sure we have v_bitrate on the commandline
Expand Down
22 changes: 11 additions & 11 deletions trunk/man/nuvexport.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Comments
.\" $Id$
.Dd Sept 26, 2004
.Dd Sept 26, 2004
.ds volume-operating-system NuvExport
.Os NUVEXPORT
.Dt NUVEXPORT 1 1
Expand All @@ -27,12 +27,12 @@

.Op Fl Fl ffmpeg
.Op Fl Fl deinterlace
.Op Fl Fl denoise
.Op Fl Fl noise_reduction
.Op Fl Fl crop

.Op Fl Fl transcode
.Op Fl Fl deinterlace
.Op Fl Fl denoise
.Op Fl Fl noise_reduction
.Op Fl Fl crop
.Op Fl Fl zoom_filter=\fRfiltername\fR

Expand Down Expand Up @@ -79,7 +79,7 @@ Uses ffmpeg as the re-encoder process
.Bl -tag -width indent
.It Fl Fl deinterlace
deinterlaces the output file
.It Fl Fl denoise
.It Fl Fl noise_reduction
uses noise reduction filters to clean up the output
.It Fl Fl crop
crops the broadcast overscan
Expand All @@ -89,7 +89,7 @@ Uses transcode as the re-encoder process
.Bl -tag -width indent
.It Fl Fl deinterlace
deinterlaces the output file
.It Fl Fl denoise
.It Fl Fl noise_reduction
uses noise reduction filters to clean up the output
.It Fl Fl crop
crops the broadcast overscan
Expand All @@ -101,15 +101,15 @@ uses a zoom filter as specified
.Sh USAGE
As mentioned, the program is interactive, and is fairly self explanitory. The following are the basic steps to export a file from mythtv.
.Bd -literal
1) Choose export type from the prompts, details of the choices are below
1) Choose export type from the prompts, details of the choices are below
in EXPORT TYPES section
2) Choose from the show titles.
3) Choose a specific show from the titles, you may select a number of
3) Choose a specific show from the titles, you may select a number of
different shows, and batch them for re-encode
4) hit "c" to continue and begin the reencode process
5) the following questions are usually ok to leave with defaults,
5) the following questions are usually ok to leave with defaults,
especially if you are unsure as to their function
.Ed
.Ed
.Sh DIAGNOSTICS
.Ex -std
.Sh DEPENDANCIES
Expand All @@ -136,10 +136,10 @@ DVCD - export to VCD format, but using 48kHz audio, useful for DVDs
DVD - export to DVD
WMV - Windows Media Player files, exports ASF files with the mpeg4 codec
MP3 - Export audio track to a Mp3
MPEG2->MPEG2 cut - cuts commercials tagged by mythtv and gives
MPEG2->MPEG2 cut - cuts commercials tagged by mythtv and gives
you a mpeg file. This only works for Mpeg-2 recorded media,
like that recorded with a PVR-x25 card
nuv and sql - dumps mysql database so it can be moved to another
nuv and sql - dumps mysql database so it can be moved to another
mythtv backend
.Ed
.Sh SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions trunk/mythtv/recordings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package mythtv::recordings;

use DBI;
use nuv_export::shared_utils;
use nuv_export::cli;
use mythtv::db;
use mythtv::nuvinfo;

Expand All @@ -22,7 +23,6 @@ package mythtv::recordings;
# These are available for export, but for the most part should only be needed here
our @EXPORT_OK = qw/ &generate_showtime $num_shows /;
}
our @EXPORT_OK;

# Variables we intend to export
our ($video_dir, @Files, %Shows, $num_shows);
Expand Down Expand Up @@ -90,7 +90,7 @@ package mythtv::recordings;
or die "Could not execute ($q): $!\n\n";
my ($show, $episode, $description, $show_hostname, $cutlist) = $sh->fetchrow_array;
# Skip shows without cutlists?
next if ($Args{'require_cutlist'} && !$cutlist);
next if (arg('require_cutlist') && !$cutlist);
# Unknown file - someday we should report this
next unless ($show);
$sh2->execute($channel, "$syear$smonth$sday$shour$sminute$ssecond")
Expand Down
111 changes: 111 additions & 0 deletions trunk/nuv_export/cli.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.16 (xris)
#
# cli.pm
#
# routines for dealing with the commandline arguments
#

package nuv_export::cli;

use English;
use Getopt::Long qw(:config pass_through);

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;

BEGIN {
use Exporter;
our @ISA = qw/ Exporter /;

our @EXPORT = qw/ &add_arg &arg &load_cli_args
$export_prog $is_cli
$DEBUG
/;
}

# Load some options early, before anything else:
# --ffmpeg, --transcode. Default is --ffmpeg
our $export_prog = find_program('ffmpeg') ? 'ffmpeg' : 'transcode';
GetOptions('ffmpeg' => sub { $export_prog = 'ffmpeg'; },
'transcode' => sub { $export_prog = 'transcode'; },
);

# Debug mode?
our $DEBUG;

# Look for certain commandline options to determine if this is cli-mode
our $is_cli = 0;

# Only need to keep track of cli args here
my %cli_args;
my %args;

# Load the following extra parameters from the commandline
add_arg('search-only', 'Search only, do not do anything with the found recordings');
add_arg('confirm', 'Confirm commandline-entered choices');

add_arg('title=s', 'Find programs to convert based on their title.');
add_arg('subtitle|episode=s', 'Find programs to convert based on their subtitle (episode name).');
add_arg('description=s', 'Find programs to convert based on their description.');
add_arg('infile|input|i=s', 'Input filename');
add_arg('chanid|channel=i', 'Find programs to convert based on their chanid');
add_arg('starttime|start_time=i', 'Find programs to convert based on their starttime.');

add_arg('require_cutlist', 'Only show programs that have a cutlist?');

add_arg('mode|export=s', 'Specify which export mode to use');

add_arg('noserver|no-server', "Don't talk to the server -- do all encodes here in this execution");

add_arg('nice=i', 'Set the value of "nice" for subprocesses');
add_arg('version', 'Show the version and exit');

# Load the commandline options
add_arg('help', 'Show nuvexport help');
add_arg('debug', 'Enable debug mode');

# Load the commandline arguments
sub load_cli_args {
# Build an array of the requested commandline arguments
my @args;
foreach my $key (keys %cli_args) {
push @args, $cli_args{$key}[0];
}
# Connect $DEBUG
$args{'debug'} = \$DEBUG;
# Get the options
GetOptions(\%args, @args)
or die "Invalid commandline parameter(s).\n";
# Make sure nice is defined
if (defined($args{'nice'})) {
die "--nice must be between -20 (highest priority) and 19 (lowest)\n" if (int($args{'nice'}) != $args{'nice'} || $args{'nice'} > 19 || $args{'nice'} < -20);
$NICE .= ' -n'.int($args{'nice'});
}
else {
$NICE .= ' -n19';
}
# Is this a commandline-only request?
if (!$args{'confirm'} && ($args{'title'} || $args{'subtitle'} || $args{'description'} || $args{'infile'} || $args{'starttime'} || $args{'chanid'})) {
$is_cli = 1;
}
# No server stuff enabled yet, default to off
$args{'noserver'} = 1;
}

# Add an argument to check for on the commandline
sub add_arg {
my ($arg, $description) = @_;
my ($name) = $arg =~ /^([^!=:\|]+)/;
$cli_args{$name} = [$arg, $description];
}

# Retrieve the value of a commandline argument
sub arg {
my ($arg, $default) = @_;
return defined($args{$arg}) ? $args{$arg} : $default;
}

1; #return true

# vim:ts=4:sw=4:ai:et:si:sts=4
6 changes: 3 additions & 3 deletions trunk/nuv_export/help.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.10 (xris)
#Last Updated: 2005.02.16 (xris)
#
# help.pm
#

if ($Args{'mode'}) {
if (arg('mode')) {
my $exporter = query_exporters($export_prog);
print "No help for $export_prog/", $Args{'mode'}, "\n\n";
print "No help for $export_prog/", arg('mode'), "\n\n";
}

print "Help section still needs to be updated.\n"
Expand Down
23 changes: 15 additions & 8 deletions trunk/nuv_export/shared_utils.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.13 (xris)
#Last Updated: 2005.02.16 (xris)
#
# nuv_export::shared_utils
#
Expand All @@ -14,24 +14,27 @@ package nuv_export::shared_utils;
use Exporter;
our @ISA = qw/ Exporter /;

our @EXPORT = qw/ &clear &find_program &shell_escape &wrap &system &mkdir &wipe_tmpfiles
@Exporters %Prog %Args $DEBUG
$num_cpus $is_child
@tmpfiles %children
our @EXPORT = qw/ &clear &find_program &shell_escape
&wrap &wipe_tmpfiles
&system &mkdir
@Exporters
$DEBUG $NICE
$num_cpus $is_child
@tmpfiles %children
/;
}

# Variables that we export so all other modules can share them
our @Exporters; # A list of the various exporters
our %Prog; # Locations of preferred programs for various tasks (mplex, etc) -- DEPRECATED
our %Args; # Edit this to store command line arguments in individual variables
our $is_child = 0; # This is set to 1 after forking to a new process
our @tmpfiles; # Keep track of temporary files, so we can clean them up upon quit
our %children; # Keep track of child pid's so we can kill them off if we quit unexpectedly
our $num_cpus = 0; # How many cpu's on this machine?


# These are defined here to avoid some nasty use-loops with nuv_export::ui
our $DEBUG;
$Args{'debug'} = \$DEBUG;
our $NICE;

# Remove any temporary files, and make sure child processes are cleaned up.
END {
Expand Down Expand Up @@ -70,6 +73,10 @@ package nuv_export::shared_utils;
$num_cpus = 1;
}

# Make sure that we have nice installed
$NICE = find_program('nice');
die "You need nice in order to use nuvexport.\n\n" unless ($NICE);

# Clear the screen
sub clear {
print $DEBUG ? "\n" : $terminal->Tputs('cl');
Expand Down
118 changes: 27 additions & 91 deletions trunk/nuv_export/ui.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2004.12.26 (xris)
#Last Updated: 2005.02.16 (xris)
#
# nuvexport::ui
#
Expand All @@ -9,103 +9,36 @@
package nuv_export::ui;

use File::Path;
use Getopt::Long;

# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use mythtv::db;
use nuv_export::cli;
use mythtv::recordings;

BEGIN {
use Exporter;
our @ISA = qw/ Exporter /;

our @EXPORT = qw/ &add_arg &load_cli_args &arg
&load_episodes &load_cli_episodes
our @EXPORT = qw/ &load_episodes &load_cli_episodes
&query_savepath &query_exporters &query_text
$is_cli
/;
}

# Only need to keep track of cli args here
my %cli_args;

# Load the following extra parameters from the commandline
add_arg('search-only', 'Search only, do not do anything with the found recordings');
add_arg('confirm', 'Confirm commandline-entered choices');

add_arg('title=s', 'Find programs to convert based on their title.');
add_arg('subtitle|episode=s', 'Find programs to convert based on their subtitle (episode name).');
add_arg('description=s', 'Find programs to convert based on their description.');
add_arg('infile|input|i=s', 'Input filename');
add_arg('chanid|channel=i', 'Find programs to convert based on their chanid');
add_arg('starttime|start_time=i', 'Find programs to convert based on their starttime.');

add_arg('require_cutlist', 'Only show programs that have a cutlist?');

add_arg('mode|export=s', 'Specify which export mode to use');

add_arg('noserver|no-server', "Don't talk to the server -- do all encodes here in this execution");

add_arg('nice=i', 'Set the value of "nice" for subprocesses');
add_arg('version', 'Show the version and exit');

# Load the commandline options
add_arg('help', 'Show nuvexport help');
add_arg('debug', 'Enable debug mode');

# Look for certain commandline options to determine if this is cli-mode
our $is_cli = 0;

# Load the commandline arguments
sub load_cli_args {
# Build an array of the requested commandline arguments
my @args;
foreach my $key (keys %cli_args) {
push @args, $cli_args{$key}[0];
}
# Get the options
GetOptions(\%Args, keys %cli_args)
or die "Invalid commandline parameter(s).\n";
# Make sure nice is defined
if (defined($Args{'nice'})) {
die "--nice must be between -20 (highest priority) and 19 (lowest)\n" if (int($Args{'nice'}) != $Args{'nice'} || $Args{'nice'} > 19 || $Args{'nice'} < -20);
$Args{'nice'} = int($Args{'nice'});
}
else {
$Args{'nice'} = 19;
}
# Is this a commandline-only request?
if (!$Args{'confirm'} && ($Args{'title'} || $Args{'subtitle'} || $Args{'description'} || $Args{'infile'} || $Args{'starttime'} || $Args{'chanid'})) {
$is_cli = 1;
}
}

# Add an argument to check for on the commandline
sub add_arg {
my ($arg, $description) = @_;
my ($name) = $arg =~ /^([^!=:\|]+)/;
$cli_args{$name} = [$arg, $description];
}

# Retrieve the value of a commandline argument
sub arg {
my ($arg, $default) = @_;
return defined($Args{$arg}) ? $Args{$arg} : $default;
}

# Load episodes from the commandline
sub load_cli_episodes {
my @matches;
# Performing a search
if ($Args{'title'} || $Args{'subtitle'} || $Args{'description'}) {
if (arg('title') || arg('subtitle') || arg('description')) {
foreach my $show (sort keys %Shows) {
# Title search?
next unless (!$Args{'title'} || $show =~ /$Args{'title'}/si);
my $title = arg('title');
next unless (!$title || $show =~ /$title/si);
# Search episodes
foreach my $episode (@{$Shows{$show}}) {
next unless (!$Args{'subtitle'} || $episode->{'title'} =~ /$Args{'subtitle'}/si);
next unless (!$Args{'description'} || $episode->{'description'} =~ /$Args{'description'}/si);
my $subtitle = arg('subtitle');
my $description = arg('description');
next unless (!$subtitle || $episode->{'title'} =~ /$subtitle/si);
next unless (!$description || $episode->{'description'} =~ /$description/si);
push @matches, $episode;
}
}
Expand All @@ -114,36 +47,38 @@ package nuv_export::ui;
}
# Look for a filename or channel/starttime
else {
my $chanid = arg('chanid');
my $starttimg = arg('starttime');
# Filename specified on the command line -- extract the chanid and starttime
if ($Args{'infile'}) {
if ($Args{'infile'} =~ /\b(\d+)_(\d+)_\d+\.nuv$/) {
$Args{'chanid'} = $1;
$Args{'starttime'} = $2;
if (arg('infile')) {
if (arg('infile') =~ /\b(\d+)_(\d+)_\d+\.nuv$/) {
$chanid = $1;
$starttime = $2;
}
else {
die "Input filename does not match the MythTV recording name format.\n"
."Please reference only files in your active MythTV video directory.\n";
}
}
# Find the show
if ($Args{'starttime'} || $Args{'chanid'}) {
if ($starttime || $chanid) {
# We need both arguments
die "Please specify both a starttime and chanid.\n" unless ($Args{'starttime'} && $Args{'chanid'});
die "Please specify both a starttime and chanid.\n" unless ($starttime && $chanid);
# Make sure the requested show exists
foreach my $show (sort keys %Shows) {
foreach my $episode (@{$Shows{$show}}) {
next unless ($Args{'chanid'} == $episode->{'channel'} && $Args{'starttime'} == $episode->{'start_time'});
next unless ($chanid == $episode->{'channel'} && $starttime == $episode->{'start_time'});
push @matches, $episode;
last;
}
last if (@matches);
}
# Not found?
die "Couldn't find a show on chanid $Args{'chanid'} at the specified time.\n" unless (@matches);
die "Couldn't find a show on chanid $chanid at the specified time.\n" unless (@matches);
}
}
# Only searching, not processing
if ($Args{'search-only'}) {
if (arg('search-only')) {
if (@matches) {
print "\nMatching Shows:\n\n";
foreach my $episode (@matches) {
Expand Down Expand Up @@ -376,12 +311,13 @@ package nuv_export::ui;

die "No export modules were found!\n" unless (@Exporters);
# Load the mode from the commandline?
if ($Args{'mode'}) {
if (my $mode = arg('mode', ($PROGRAM_NAME =~ /^.*?nuvexport-([\w\-]+)$/) ? $1 : undef)) {
foreach my $exporter (@Exporters) {
next unless ($Args{'mode'} =~ /$exporter->{'cli'}/);
next unless ($mode =~ /$exporter->{'cli'}/);
return $exporter;
}
die "Unknown exporter mode: $Args{'mode'}\n";
print "Unknown exporter mode: $mode\n";
exit -1;
}
# Build the query
my $query = "Using $export_prog for exporting.\n"
Expand Down Expand Up @@ -428,9 +364,9 @@ package nuv_export::ui;
# die "here, we should be loading the savepath from the mythvideo info in the database\n";
# }
# No need?
return undef unless ($Args{'noserver'} || $Args{'path'});
return undef unless (arg('noserver') || arg('path'));
# Grab a path from the commandline?
my $path = ($Args{'path'} or '');
my $path = (arg('path') or '');
$path =~ s/\/+$//s;
if ($is_cli) {
# Need a pathname
Expand Down
46 changes: 10 additions & 36 deletions trunk/nuvexport
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/perl -w
# Last Updated: 2005.02.12 (xris)
# Last Updated: 2005.02.16 (xris)

# Version
$VERSION = '0.2 cvs20050215';
$VERSION = '0.2 cvs20050221';

# Autoflush buffers
$|++;
Expand All @@ -22,31 +22,15 @@
use File::Basename;
use lib dirname($ENV{'_'}), '/usr/share/nuvexport', '/usr/local/share/nuvexport';

# How was nuvexport called?
my $callname = $0;

# Load the myth and nuv utilities, and connect to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::recordings;

# Make sure that we have mythtranscode installed
$Prog{'mythtranscode'} = find_program('mythtranscode');
die "You need mythtranscode in order to use nuvexport.\n\n" unless ($Prog{'mythtranscode'});

# Make sure that we have nice installed
$Prog{'nice'} = find_program('nice');
die "You need nice in order to use nuvexport.\n\n" unless ($Prog{'nice'});

# Load some options early, before anything else:
# --help, --ffmpeg, --transcode. Default is --ffmpeg
BEGIN {

our $export_prog = 'ffmpeg';

use Getopt::Long qw(:config pass_through);
GetOptions('ffmpeg' => sub { $export_prog = 'ffmpeg'; },
'transcode' => sub { $export_prog = 'transcode'; },
);
}
find_program('mythtranscode')
or die "You need mythtranscode in order to use nuvexport.\n\n";

# Load the exporters based on which suite was selected above
if ($export_prog eq 'transcode') {
Expand Down Expand Up @@ -89,30 +73,20 @@
push @Exporters, export::NUV_SQL->new;

# Load the ui
use nuv_export::ui;
load_cli_args();

# Import a callname?
if (!$Args{'mode'} && $callname =~ /^.*?nuvexport-(\S+)$/) {
$Args{'mode'} = $1;
}

# No server stuff enabled yet
$Args{'noserver'} = 1;

# Show the version?
if ($Args{'version'}) {
if (arg('version')) {
print "nuvexport version: $VERSION\n";
exit;
}

# Print the help - for now, this is just perldoc
if ($Args{'help'}) {
if (arg('help')) {
require nuv_export::help;
}

# Load the recordings, and the $video_dir variable
use mythtv::recordings;
load_recordings();

# Load episodes from the commandline (and display/quit if this is search-only)
Expand All @@ -128,7 +102,7 @@
$exporter->gather_settings();

# Encode right here?
if ($Args{'noserver'}) {
if (arg('noserver')) {
foreach my $episode (@episodes) {
# Keep track of when we started
if ($DEBUG) {
Expand Down
6 changes: 4 additions & 2 deletions trunk/nuvexport.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name: nuvexport
Version: 0.2
Release: cvs20050215
Release: cvs20050221
License: GPL
Summary: mythtv nuv video file conversion script
URL: http://forevermore.net/nuvexport/
Expand All @@ -17,12 +17,14 @@ BuildArch: noarch

# Standard nuvexport modules:
Requires: perl >= 5.6
Requires: perl-DBD-MySQL
Requires: perl-DBI
Requires: perl-Time-HiRes
Requires: transcode >= 0.6.12
Requires: ffmpeg >= 0.4.9
Requires: mjpegtools >= 1.6.2
Requires: mplayer
Requires: divx4linux
Requires: perl-Time-HiRes
# mpeg2cut needs some others:
Requires: avidemux >= 2
Requires: lve
Expand Down