111 changes: 61 additions & 50 deletions trunk/export/ffmpeg/DVD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.16 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::ffmpeg::DVD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -23,23 +23,24 @@ package export::ffmpeg::DVD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/dvd/i,
'name' => 'Export to DVD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# DVD-specific settings
'quantisation' => 5, # 4 through 6 is probably right...
'a_bitrate' => 384,
'v_bitrate' => 6000,
'cli' => qr/dvd/i,
'name' => 'Export to DVD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);

# Initialize and check for ffmpeg
$self->init_ffmpeg();

# Can we even encode dvd?
if (!$self->can_encode('mpeg2video')) {
push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mpeg2video.";
Expand All @@ -53,64 +54,74 @@ package export::ffmpeg::DVD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Add the dvd preferred bitrates
$self->{'defaults'}{'quantisation'} = 5;
$self->{'defaults'}{'a_bitrate'} = 384;
$self->{'defaults'}{'v_bitrate'} = 6000;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Ask the user what audio bitrate he/she wants
$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',
$self->{'a_bitrate'});
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate >= 64.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate <= 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
# Audio Bitrate
while (1) {
my $a_bitrate = query_text('Audio bitrate?',
'int',
$self->val('a_bitrate'));
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate between 64 and 384.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate between 64 and 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
}
# 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'} = arg('v_bitrate') if (arg('v_bitrate'));
if (!arg('v_bitrate') || arg('confirm')) {
if ($self->val('v_bitrate') > $max_v_bitrate || $self->val('confirm')) {
if ($self->val('v_bitrate') > $max_v_bitrate) {
$self->{'v_bitrate'} = $max_v_bitrate;
}
while (1) {
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
'int',
$self->{'v_bitrate'});
$self->val('v_bitrate'));
if ($v_bitrate < 1000) {
print "Too low; please choose a bitrate >= 1000.\n";
print "Too low; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
elsif ($v_bitrate > $max_v_bitrate) {
print "Too high; please choose a bitrate <= $max_v_bitrate.\n";
print "Too high; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
else {
$self->{'v_bitrate'} = $v_bitrate;
last;
}
}
}
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
$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) {
print "Too low; please choose a number between 2 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 2 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
# Ask the user what vbr quality (quantisation) he/she wants - 1..31
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 1 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
}
}
Expand Down
153 changes: 109 additions & 44 deletions trunk/export/ffmpeg/DivX.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Last Updated: 2005.02.16 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::ffmpeg::DivX
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -15,30 +15,34 @@ package export::ffmpeg::DivX;
use mythtv::recordings;

# Load the following extra parameters from the commandline
add_arg('quantisation|q=i', 'Quantisation');
add_arg('a_bitrate|a=i', 'Audio bitrate');
add_arg('v_bitrate|v=i', 'Video bitrate');
add_arg('multipass!', 'Enably two-pass encoding.');

sub new {
my $class = shift;
my $self = {
'cli' => qr/\bdivx\b/i,
'name' => 'Export to DivX',
'enabled' => 1,
'errors' => [],
# ffmpeg-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# DivX-specific settings
'a_bitrate' => 128,
'v_bitrate' => 960,
'width' => 624,
'height' => 464,
'cli' => qr/\bdivx\b/i,
'name' => 'Export to DivX',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);
die "Width must be > 0\n" unless (!defined $self->val('width') || $self->{'width'} =~ /^\s*\D/ || $self->{'width'} > 0);
die "Height must be > 0\n" unless (!defined $self->val('height') || $self->{'height'} =~ /^\s*\D/ || $self->{'height'} > 0);

# Initialize and check for ffmpeg
$self->init_ffmpeg();

# Can we even encode divx?
if (!$self->can_encode('mpeg4')) {
push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mpeg4.";
Expand All @@ -52,31 +56,59 @@ package export::ffmpeg::DivX;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Default bitrates and resolution
$self->{'defaults'}{'a_bitrate'} = 128;
$self->{'defaults'}{'v_bitrate'} = 960;
$self->{'defaults'}{'width'} = 624;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();

# Audio Bitrate
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'});
}
# Ask the user what video bitrate he/she wants
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
$self->{'v_bitrate'} = query_text('Video bitrate?',
'int',
$self->{'v_bitrate'});
$self->{'a_bitrate'} = query_text('Audio bitrate?',
'int',
$self->val('a_bitrate'));
# VBR options
if (!$is_cli) {
$self->{'vbr'} = query_text('Variable bitrate video?',
'yesno',
$self->val('vbr'));
if ($self->{'vbr'}) {
$self->{'multipass'} = query_text('Multi-pass (slower, but better quality)?',
'yesno',
$self->val('multipass'));
if (!$self->{'multipass'}) {
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 1 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
}
}
}
# Ask the user what video bitrate he/she wants
if ($self->{'multipass'} || !$self->{'vbr'}) {
$self->{'v_bitrate'} = query_text('Video bitrate?',
'int',
$self->val('v_bitrate'));
}
}
# Query the resolution
$self->query_resolution();
Expand All @@ -85,17 +117,50 @@ package export::ffmpeg::DivX;
sub export {
my $self = shift;
my $episode = shift;
# Load nuv info
# Make sure we have finfo
load_finfo($episode);
# Build the ffmpeg string
$self->{'ffmpeg_xtra'} = " -b " . $self->{'v_bitrate'}
. " -vcodec mpeg4"
. " -ab " . $self->{'a_bitrate'}
. " -acodec mp3"
. " -s " . $self->{'width'} . "x" . $self->{'height'}
;
# Execute the parent method
$self->SUPER::export($episode, ".avi");
# Dual pass?
if ($self->{'multipass'}) {
# Add the temporary file to the list
push @tmpfiles, "/tmp/divx.$$.log";
# Back up the path and use /dev/null for the first pass
my $path_bak = $self->{'path'};
$self->{'path'} = '/dev/null';
# First pass
print "First pass...\n";
$self->{'ffmpeg_xtra'} = ' -b ' . $self->{'v_bitrate'}
. ' -vcodec mpeg4'
#. ' -ab ' . $self->{'a_bitrate'}
#. ' -acodec mp3'
. " -s $self->{'width'}x$self->{'height'}"
. " -pass 1 -passlogfile '/tmp/divx.$$.log'"
. ' -f avi';
$self->SUPER::export($episode, '');
# Restore the path
$self->{'path'} = $path_bak;
# Second pass
print "Final pass...\n";
$self->{'ffmpeg_xtra'} = ' -b ' . $self->{'v_bitrate'}
. ' -vcodec mpeg4'
. ' -ab ' . $self->{'a_bitrate'}
. ' -acodec mp3'
. " -s $self->{'width'}x$self->{'height'}"
. " -pass 2 -passlogfile '/tmp/divx.$$.log'"
. ' -f avi';
}
# Single Pass
else {
$self->{'ffmpeg_xtra'} = ' -b ' . $self->{'v_bitrate'}
. (($self->{'vbr'}) ?
" -qmin $self->{'quantisation'} -qmax 31" : '')
. ' -vcodec mpeg4'
. ' -ab ' . $self->{'a_bitrate'}
. ' -acodec mp3'
. " -s $self->{'width'}x$self->{'height'}"
. ' -f avi';
}
# Execute the (final pass) encode
$self->SUPER::export($episode, '.avi');
}

1; #return true
Expand Down
44 changes: 28 additions & 16 deletions trunk/export/ffmpeg/MP3.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.16 (xris)
#Last Updated: 2005.03.02 (xris)
#
# export::ffmpeg::MP3
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -21,20 +21,28 @@ package export::ffmpeg::MP3;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bmp3\b/i,
'name' => 'Export to MP3',
'enabled' => 1,
'errors' => [],
# Options
'bitrate' => 128,
'cli' => qr/\bmp3\b/i,
'name' => 'Export to MP3',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
$self->{'bitrate'} = $self->val('a_bitrate') unless (defined $self->val('bitrate'));
die "Bitrate must be > 0\n" unless (!defined $self->val('bitrate') || $self->{'bitrate'} > 0);

# Initialize and check for transcode
$self->init_ffmpeg(1);

# Make sure that we have an mplexer
find_program('id3tag')
or push @{$self->{'errors'}}, 'You need id3tag to export an mp3.';

# Can we even encode vcd?
if (!$self->can_encode('mp3')) {
push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mp3 audio.";
Expand All @@ -45,20 +53,24 @@ package export::ffmpeg::MP3;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# MP3 bitrate
$self->{'defaults'}{'bitrate'} = 128;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings (skipping one parent, since we don't need the ffmpeg-specific options)
$self->SUPER::gather_settings(1);
# Audio Bitrate
if (arg('bitrate')) {
$self->{'bitrate'} = (arg('bitrate') or arg('a_bitrate'));
die "Audio bitrate must be > 0\n" unless ($self->{'bitrate'} > 0);
}
else {
$self->{'bitrate'} = query_text('Audio bitrate?',
'int',
$self->{'bitrate'});
}
$self->{'bitrate'} = query_text('Audio bitrate?',
'int',
$self->val('bitrate'));
}

sub export {
Expand Down
118 changes: 64 additions & 54 deletions trunk/export/ffmpeg/SVCD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.16 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::ffmpeg::SVCD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -23,21 +23,21 @@ package export::ffmpeg::SVCD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bsvcd\b/i,
'name' => 'Export to SVCD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# SVCD-specific settings
'quantisation' => 5, # 4 through 6 is probably right...
'a_bitrate' => 192,
'v_bitrate' => 2500,
'cli' => qr/\bsvcd\b/i,
'name' => 'Export to SVCD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);

# Initialize and check for ffmpeg
$self->init_ffmpeg();
# Can we even encode svcd?
Expand All @@ -53,66 +53,76 @@ package export::ffmpeg::SVCD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Add the svcd preferred bitrates
$self->{'defaults'}{'quantisation'} = 5;
$self->{'defaults'}{'a_bitrate'} = 192;
$self->{'defaults'}{'v_bitrate'} = 2500;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Ask the user what audio bitrate he/she wants
$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',
$self->{'a_bitrate'});
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate >= 64.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate <= 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
# Audio Bitrate
while (1) {
my $a_bitrate = query_text('Audio bitrate?',
'int',
$self->val('a_bitrate'));
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate between 64 and 384.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate between 64 and 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
}
# 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'} = 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;
# 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 = min(2500, 2742 - $self->{'a_bitrate'});
if ($self->val('v_bitrate') > $max_v_bitrate || $self->val('confirm')) {
if ($self->val('v_bitrate') > $max_v_bitrate) {
$self->{'v_bitrate'} = $max_v_bitrate;
}
while (1) {
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
'int',
$self->{'v_bitrate'});
$self->val('v_bitrate'));
if ($v_bitrate < 1000) {
print "Too low; please choose a bitrate >= 1000.\n";
print "Too low; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
elsif ($v_bitrate > $max_v_bitrate) {
print "Too high; please choose a bitrate <= $self->{'v_bitrate'}.\n";
print "Too high; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
else {
$self->{'v_bitrate'} = $v_bitrate;
last;
}
}
}
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
$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) {
print "Too low; please choose a number between 2 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 2 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
# Ask the user what vbr quality (quantisation) he/she wants - 1..31
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 1 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
}
}
Expand Down
28 changes: 19 additions & 9 deletions trunk/export/ffmpeg/VCD.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.03.02 (xris)
#
# export::ffmpeg::VCD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -20,19 +20,20 @@ package export::ffmpeg::VCD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bdvcd\b/i,
'name' => 'Export to VCD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
'cli' => qr/\bdvcd\b/i,
'name' => 'Export to VCD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Initialize and check for ffmpeg
$self->init_ffmpeg();

# Can we even encode vcd?
if (!$self->can_encode('mpeg1video')) {
push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mpeg1video.";
Expand All @@ -46,6 +47,15 @@ package export::ffmpeg::VCD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Not really anything to add
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
Expand Down
36 changes: 25 additions & 11 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.03.01 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::ffmpeg::XviD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -24,17 +24,17 @@ package export::ffmpeg::XviD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bxvid\b/i,
'name' => 'Export to XviD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
'cli' => qr/\bxvid\b/i,
'name' => 'Export to XviD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);
Expand Down Expand Up @@ -65,6 +65,18 @@ package export::ffmpeg::XviD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Default bitrates and resolution
$self->{'defaults'}{'a_bitrate'} = 128;
$self->{'defaults'}{'v_bitrate'} = 960;
$self->{'defaults'}{'width'} = 624;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
Expand All @@ -84,7 +96,9 @@ package export::ffmpeg::XviD;
$self->val('multipass'));
if (!$self->{'multipass'}) {
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?', 'float', $self->val('quantisation'));
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
Expand All @@ -98,7 +112,7 @@ package export::ffmpeg::XviD;
}
}
}
# Ask the user what audio and video bitrates he/she wants
# Ask the user what video bitrate he/she wants
if ($self->{'multipass'} || !$self->{'vbr'}) {
$self->{'v_bitrate'} = query_text('Video bitrate?',
'int',
Expand Down
33 changes: 21 additions & 12 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.28 (xris)
#Last Updated: 2005.03.07 (xris)
#
# generic.pm
#
Expand Down Expand Up @@ -35,7 +35,17 @@ package export::generic;
add_arg('noise_reduction|denoise|nr!', 'Enable noise reduction.');
add_arg('crop!', 'Crop out broadcast overscan.');

# Gather generic export settings
# Load defaults
sub load_defaults {
my $self = shift;
# These defaults apply to all modules
$self->{'defaults'}{'use_cutlist'} = 1;
$self->{'defaults'}{'noise_reduction'} = 1;
$self->{'defaults'}{'deinterlace'} = 1;
$self->{'defaults'}{'crop'} = 1;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the save path, if requested
Expand All @@ -55,14 +65,9 @@ package export::generic;
'yesno',
$self->val('deinterlace'));
# Crop video to get rid of broadcast padding
if (arg('crop')) {
$self->{'crop'} = 1;
}
else {
$self->{'crop'} = query_text('Crop broadcast overscan (2% border)?',
'yesno',
$self->val('crop'));
}
$self->{'crop'} = query_text('Crop broadcast overscan (2% border)?',
'yesno',
$self->val('crop'));
}
}

Expand Down Expand Up @@ -92,7 +97,7 @@ package export::generic;
$outfile =~ s/(?:[\/\\\:\*\?\<\>\|\-]+\s*)+(?=[^\s\/\\\:\*\?\<\>\|\-])/- /sg;
$outfile =~ tr/"/'/s;
# add underscores?
if (arg('underscores')) {
if ($self->val('underscores')) {
$outfile =~ tr/ /_/s;
}
# Make sure we don't have a duplicate filename
Expand Down Expand Up @@ -260,8 +265,12 @@ package export::generic;
my $self = shift;
my $arg = shift;
if (!defined $self->{$arg}) {
# Config option?
my $val = rc_arg($arg, $self);
# Use the default for this object
$val = $self->{'defaults'}{$arg} unless (defined $val);
# Look for a config option, or a commandline option
$self->{$arg} = arg($arg, rc_arg($arg, $self));
$self->{$arg} = arg($arg, $val);
}
return $self->{$arg};
}
Expand Down
51 changes: 16 additions & 35 deletions trunk/export/mencoder.pm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/perl -w
#Last Updated: 2005.02.27 (icemaann)
#Last Updated: 2005.03.02 (xris)
#
# mencoder.pm
#
# routines for setting up mencoder
# routines for setting up mencoder
#

package export::mencoder;
Expand All @@ -19,48 +19,30 @@ package export::mencoder;
use nuv_export::ui;
use mythtv::recordings;

# Load the following extra parameters from the commandline
add_arg('zoom_filter:s', 'Which zoom filter to use.');

# This superclass defines several object variables:
#
# path (defined by generic)
# use_cutlist (defined by generic)
# noise_reduction
# deinterlace
# crop
# zoom_filter
#

# Check for mencoder
sub init_mencoder {
my $self = shift;
# Make sure we have mencoder
# Make sure we have mencoder
find_program('mencoder')
or push @{$self->{'errors'}}, 'You need mencoder to use this exporter.';
}

# Gather data for mencoder
# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Not really anything to add
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
my $skip = shift;
# Gather generic settings
$self->SUPER::gather_settings($skip ? $skip - 1 : 0);
return if ($skip);
# Zoom Filter
if (defined arg('zoom_filter')) {
if (!arg('zoom_filter')) {
$self->{'zoom_filter'} = 'B_spline';
}
elsif (arg('zoom_filter') =~ /^(?:Lanczos3|Bell|Box|Mitchell|Hermite|B_spline|Triangle)$/) {
$self->{'zoom_filter'} = arg('zoom_filter');
}
else {
die "Unknown zoom_filter: ".arg('zoom_filter')."\n";
}
}
}

#Fix/build mencoder filter chain
sub build_vop_line{
my $cmdline = shift;
Expand All @@ -74,7 +56,6 @@ package export::mencoder;
$cmdline .= " -vop $vop ";
return $cmdline;
}


sub export {
my $self = shift;
Expand Down Expand Up @@ -112,14 +93,14 @@ package export::mencoder;
if (-e "/tmp/fifodir_$$/vidout" || -e "/tmp/fifodir_$$/audout") {
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 (need to use --fifosync with mencoder? needs testing)
# Here, we have to fork off a copy of mythtranscode (need to use --fifosync with mencoder? needs testing)
$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 mythtranscode handle the cutlist
$mythtranscode .= ' --honorcutlist' if ($self->{'use_cutlist'});
}
# Figure out the input files
# Figure out the input files
if ($episode->{'finfo'}{'is_mpeg'} && !$self->{'use_cutlist'}) {
$mencoder .= " -idx $episode->{'filename'} ";
}
Expand All @@ -146,7 +127,7 @@ package export::mencoder;
# Use the cutlist? (only for mpeg files -- nuv files are handled by mythtranscode)
# Can we cut with mencoder?
# Filters (remember, mencoder reads these in reverse order (so deint should be last if used)
# Normally you would do -vop filter1=<val>,filter2=<val>,lavcdeint...
# Normally you would do -vop filter1=<val>,filter2=<val>,lavcdeint...
if ($self->{'noise_reduction'}) {
$mencoder .= " -vop denoise3d";
}
Expand Down
27 changes: 18 additions & 9 deletions trunk/export/mencoder/XviD.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
#Last Updated: 2005.03.01 (xris)
#Last Updated: 2005.03.02 (xris)
#
# export::mencoder::XviD
# Copied from transcode.pm
Expand All @@ -25,17 +25,17 @@ package export::mencoder::XviD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bxvidmen\b/i,
'name' => 'Export to XviD (using mencoder)',
'enabled' => 1,
'errors' => [],
#Mencoder-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
'cli' => qr/\bxvidmen\b/i,
'name' => 'Export to XviD (using mencoder)',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);
Expand All @@ -60,6 +60,15 @@ package export::mencoder::XviD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Not really anything to add
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
Expand Down
33 changes: 14 additions & 19 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.17 (xris)
#Last Updated: 2005.03.02 (xris)
#
# transcode.pm
#
Expand All @@ -22,16 +22,6 @@ package export::transcode;
# Load the following extra parameters from the commandline
add_arg('zoom_filter:s', 'Which zoom filter to use.');

# This superclass defines several object variables:
#
# path (defined by generic)
# use_cutlist (defined by generic)
# noise_reduction
# deinterlace
# crop
# zoom_filter
#

# Check for transcode
sub init_transcode {
my $self = shift;
Expand All @@ -40,23 +30,28 @@ package export::transcode;
or push @{$self->{'errors'}}, 'You need transcode to use this exporter.';
}

# Gather data for transcode
# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Not really anything to add
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
my $skip = shift;
# Gather generic settings
$self->SUPER::gather_settings($skip ? $skip - 1 : 0);
return if ($skip);
# Zoom Filter
if (defined arg('zoom_filter')) {
if (!arg('zoom_filter')) {
if (defined $self->val('zoom_filter')) {
if (!$self->val('zoom_filter')) {
$self->{'zoom_filter'} = 'B_spline';
}
elsif (arg('zoom_filter') =~ /^(?:Lanczos3|Bell|Box|Mitchell|Hermite|B_spline|Triangle)$/) {
$self->{'zoom_filter'} = arg('zoom_filter');
}
else {
die "Unknown zoom_filter: ".arg('zoom_filter')."\n";
elsif ($self->val('zoom_filter') !~ /^(?:Lanczos3|Bell|Box|Mitchell|Hermite|B_spline|Triangle)$/) {
die "Unknown zoom_filter: ".$self->val('zoom_filter')."\n";
}
}
}
Expand Down
28 changes: 19 additions & 9 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.02.17 (xris)
#Last Updated: 2005.03.02 (xris)
#
# export::transcode::DVCD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -20,19 +20,20 @@ package export::transcode::DVCD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bdvcd\b/i,
'name' => 'Export to DVCD (VCD with 48kHz audio for making DVDs)',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
'cli' => qr/\bdvcd\b/i,
'name' => 'Export to DVCD (VCD with 48kHz audio for making DVDs)',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Initialize and check for transcode
$self->init_transcode();

# Make sure that we have an mplexer
find_program('tcmplex')
or push @{$self->{'errors'}}, 'You need tcmplex to export a dvcd.';
Expand All @@ -43,6 +44,15 @@ package export::transcode::DVCD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Not really anything to add
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
Expand Down
111 changes: 61 additions & 50 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.17 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::transcode::DVD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -23,23 +23,24 @@ package export::transcode::DVD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/dvd/i,
'name' => 'Export to DVD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# DVD-specific settings
'quantisation' => 5, # 4 through 6 is probably right...
'a_bitrate' => 384,
'v_bitrate' => 6000,
'cli' => qr/dvd/i,
'name' => 'Export to DVD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);

# Initialize and check for transcode
$self->init_transcode();

# Make sure that we have an mplexer
find_program('tcmplex')
or push @{$self->{'errors'}}, 'You need tcmplex to export a dvd.';
Expand All @@ -50,64 +51,74 @@ package export::transcode::DVD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Add the dvd preferred bitrates
$self->{'defaults'}{'quantisation'} = 5;
$self->{'defaults'}{'a_bitrate'} = 384;
$self->{'defaults'}{'v_bitrate'} = 6000;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Ask the user what audio bitrate he/she wants
$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',
$self->{'a_bitrate'});
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate >= 64.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate <= 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
# Audio Bitrate
while (1) {
my $a_bitrate = query_text('Audio bitrate?',
'int',
$self->val('a_bitrate'));
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate between 64 and 384.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate between 64 and 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
}
# 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'} = arg('v_bitrate') if (arg('v_bitrate'));
if (!arg('v_bitrate') || arg('confirm')) {
if ($self->val('v_bitrate') > $max_v_bitrate || $self->val('confirm')) {
if ($self->val('v_bitrate') > $max_v_bitrate) {
$self->{'v_bitrate'} = $max_v_bitrate;
}
while (1) {
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
'int',
$self->{'v_bitrate'});
$self->val('v_bitrate'));
if ($v_bitrate < 1000) {
print "Too low; please choose a bitrate >= 1000.\n";
print "Too low; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
elsif ($v_bitrate > $max_v_bitrate) {
print "Too high; please choose a bitrate <= $max_v_bitrate.\n";
print "Too high; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
else {
$self->{'v_bitrate'} = $v_bitrate;
last;
}
}
}
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
$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) {
print "Too low; please choose a number between 2 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 2 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
# Ask the user what vbr quality (quantisation) he/she wants - 1..31
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 1 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
}
}
Expand Down
125 changes: 68 additions & 57 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.17 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::transcode::SVCD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -23,22 +23,21 @@ package export::transcode::SVCD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bsvcd\b/i,
'name' => 'Export to SVCD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# SVCD-specific settings
'quantisation' => 5, # 4 through 6 is probably right...
'split_every' => 795, # Split every 795 megs
'a_bitrate' => 192,
'v_bitrate' => 2500,
'cli' => qr/\bsvcd\b/i,
'name' => 'Export to SVCD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);

# Initialize and check for transcode
$self->init_transcode();

Expand All @@ -48,73 +47,85 @@ package export::transcode::SVCD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Split every 795 megs
$self->{'defaults'}{'split_every'} = 795;
# Add the svcd preferred bitrates
$self->{'defaults'}{'quantisation'} = 5;
$self->{'defaults'}{'a_bitrate'} = 192;
$self->{'defaults'}{'v_bitrate'} = 2500;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Ask the user what audio bitrate he/she wants
$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',
$self->{'a_bitrate'});
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate >= 64.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate <= 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
# Audio Bitrate
while (1) {
my $a_bitrate = query_text('Audio bitrate?',
'int',
$self->val('a_bitrate'));
if ($a_bitrate < 64) {
print "Too low; please choose a bitrate between 64 and 384.\n";
}
elsif ($a_bitrate > 384) {
print "Too high; please choose a bitrate between 64 and 384.\n";
}
else {
$self->{'a_bitrate'} = $a_bitrate;
last;
}
}
# 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'} = 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;
# 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 = min(2500, 2742 - $self->{'a_bitrate'});
if ($self->val('v_bitrate') > $max_v_bitrate || $self->val('confirm')) {
if ($self->val('v_bitrate') > $max_v_bitrate) {
$self->{'v_bitrate'} = $max_v_bitrate;
}
while (1) {
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
'int',
$self->{'v_bitrate'});
$self->val('v_bitrate'));
if ($v_bitrate < 1000) {
print "Too low; please choose a bitrate >= 1000.\n";
print "Too low; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
elsif ($v_bitrate > $max_v_bitrate) {
print "Too high; please choose a bitrate <= $self->{'v_bitrate'}.\n";
print "Too high; please choose a bitrate between 1000 and $max_v_bitrate.\n";
}
else {
$self->{'v_bitrate'} = $v_bitrate;
last;
}
}
}
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
$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) {
print "Too low; please choose a number between 2 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 2 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
# Ask the user what vbr quality (quantisation) he/she wants - 1..31
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
elsif ($quantisation > 31) {
print "Too high; please choose a number between 1 and 31\n";
}
else {
$self->{'quantisation'} = $quantisation;
last;
}
}
# Split every # megs?
$self->{'split_every'} = query_text('Split after how many MB?',
'int',
$self->{'split_every'});
$self->{'split_every'} = 795 if ($self->{'split_every'} < 1);
$self->val('split_every'));
$self->{'split_every'} = $self->{'defaults'}{'split_every'} if ($self->val('split_every') < 1);
}

sub export {
Expand Down
39 changes: 24 additions & 15 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.02.17 (xris)
#Last Updated: 2005.03.02 (xris)
#
# export::transcode::VCD
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
Expand All @@ -20,40 +20,49 @@ package export::transcode::VCD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bvcd\b/i,
'name' => 'Export to VCD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
# VCD-specific settings
'split_every' => 795, # Split every 795 megs
'cli' => qr/\bvcd\b/i,
'name' => 'Export to VCD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Initialize and check for transcode
$self->init_transcode();

# Make sure that we have an mplexer
find_program('tcmplex', 'mplex')
or push @{$self->{'errors'}}, 'You need tcmplex or mplex to export a vcd.';
find_program('tcmplex')
or push @{$self->{'errors'}}, 'You need tcmplex to export a vcd.';

# Any errors? disable this function
$self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
# Return
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Split every 795 megs
$self->{'defaults'}{'split_every'} = 795;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Split every # megs?
$self->{'split_every'} = query_text('Split after how many MB?',
'int',
$self->{'split_every'});
$self->{'split_every'} = 795 if ($self->{'split_every'} < 1);
$self->val('split_every'));
$self->{'split_every'} = $self->{'defaults'}{'split_every'} if ($self->val('split_every') < 1);
}

sub export {
Expand Down
36 changes: 25 additions & 11 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.03.01 (xris)
#Last Updated: 2005.03.07 (xris)
#
# export::transcode::XviD
# Maintained by Chris Petersen <mythtv@forevermore.net>
Expand All @@ -24,17 +24,17 @@ package export::transcode::XviD;
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bxvid\b/i,
'name' => 'Export to XviD',
'enabled' => 1,
'errors' => [],
# Transcode-related settings
'noise_reduction' => 1,
'deinterlace' => 1,
'crop' => 1,
'cli' => qr/\bxvid\b/i,
'name' => 'Export to XviD',
'enabled' => 1,
'errors' => [],
'defaults' => {},
};
bless($self, $class);

# Initialize the default parameters
$self->load_defaults();

# Verify any commandline or config file options
die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);
Expand All @@ -59,6 +59,18 @@ package export::transcode::XviD;
return $self;
}

# Load default settings
sub load_defaults {
my $self = shift;
# Load the parent module's settings
$self->SUPER::load_defaults();
# Default bitrates and resolution
$self->{'defaults'}{'a_bitrate'} = 128;
$self->{'defaults'}{'v_bitrate'} = 960;
$self->{'defaults'}{'width'} = 624;
}

# Gather settings from the user
sub gather_settings {
my $self = shift;
# Load the parent module's settings
Expand All @@ -78,7 +90,9 @@ package export::transcode::XviD;
$self->val('multipass'));
if (!$self->{'multipass'}) {
while (1) {
my $quantisation = query_text('VBR quality/quantisation (1-31)?', 'float', $self->val('quantisation'));
my $quantisation = query_text('VBR quality/quantisation (1-31)?',
'float',
$self->val('quantisation'));
if ($quantisation < 1) {
print "Too low; please choose a number between 1 and 31.\n";
}
Expand All @@ -92,7 +106,7 @@ package export::transcode::XviD;
}
}
}
# Ask the user what audio and video bitrates he/she wants
# Ask the user what video bitrate he/she wants
if ($self->{'multipass'} || !$self->{'vbr'}) {
$self->{'v_bitrate'} = query_text('Video bitrate?',
'int',
Expand Down
12 changes: 10 additions & 2 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.28 (xris)
#Last Updated: 2005.03.07 (xris)
#
# nuv_export::shared_utils
#
Expand All @@ -14,7 +14,8 @@ package nuv_export::shared_utils;
use Exporter;
our @ISA = qw/ Exporter /;

our @EXPORT = qw/ &clear &find_program &shell_escape
our @EXPORT = qw/ &min
&clear &find_program &shell_escape
&wrap &wipe_tmpfiles
&system &mkdir
@Exporters @episodes
Expand Down Expand Up @@ -121,6 +122,13 @@ BEGIN {
}
}

# Returns the smaller of two numbers
sub min {
my $a = shift;
my $b = shift;
return ($a < $b) ? $a : $b;
}

# Escape a parameter for safe use in a commandline call
sub shell_escape {
$file = shift;
Expand Down
3 changes: 2 additions & 1 deletion trunk/nuvexport
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
}

# Add a couple of include paths so we can load the various export and gui modules
use English;
use File::Basename;
use lib dirname($ENV{'_'}), '/usr/share/nuvexport', '/usr/local/share/nuvexport';
use lib dirname($ENV{'_'} or $PROGRAM_NAME), '/usr/share/nuvexport', '/usr/local/share/nuvexport';

# Load the myth and nuv utilities, and connect to the database
use nuv_export::shared_utils;
Expand Down
1 change: 1 addition & 0 deletions trunk/nuvexport.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Requires: perl-Time-HiRes
Requires: transcode >= 0.6.12
Requires: ffmpeg >= 0.4.9
Requires: mjpegtools >= 1.6.2
Requires: id3tag
Requires: mplayer
Requires: divx4linux
# mpeg2cut needs some others:
Expand Down
10 changes: 6 additions & 4 deletions trunk/nuvexportrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#

#
# Anything placed within the <nuvexport> section
# Anything placed within the <nuvexport> section will be interpreted
# as a global option. Use this section for options that don't relate
# specifically to any particular exporter.
#
<nuvexport>

Expand All @@ -19,7 +21,7 @@
# preference of program for exports. This is equivalent to --ffmpeg,
# --transcode or --mencoder
#
export_prog=transcode
export_prog=transcode

#
# Any other parameters set in this file are equivalent to using the equivalent
Expand All @@ -33,12 +35,12 @@ export_prog=transcode
# would like to do. Use --mode or any of the mode symlinks (like
# nuvexport-xvid) to override.
#
# mode=xvid
# mode=xvid

#
# Setting underscores to yes will convert whitespace in filenames to an
# underscore character (which some people seem to prefer)
underscores=no
underscores=no

</nuvexport>

Expand Down