Skip to content

Commit e026d49

Browse files
committed
totally revamped how the cli is dealt with.
handful of minor changes and bug fixes that I've forgotten about.
1 parent 2856fd5 commit e026d49

File tree

27 files changed

+336
-292
lines changed

27 files changed

+336
-292
lines changed

trunk/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ MYTHTV_MODULES = mythtv/nuvinfo.pm \
3434
NUVEXPORT_MODULES = nuv_export/help.pm \
3535
nuv_export/shared_utils.pm \
3636
nuv_export/task.pm \
37+
nuv_export/cli.pm \
3738
nuv_export/ui.pm
3839
MODULES = ${EXPORT_MODULES} ${MYTHTV_MODULES} ${NUVEXPORT_MODULES}
3940

trunk/export/MPEG2_cut.pm

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package export::MPEG2_cut;
1010

1111
# Load the myth and nuv utilities, and make sure we're connected to the database
1212
use nuv_export::shared_utils;
13+
use nuv_export::cli;
1314
use nuv_export::ui;
1415
use mythtv::db;
1516
use mythtv::recordings;
@@ -27,17 +28,17 @@ package export::MPEG2_cut;
2728
};
2829
bless($self, $class);
2930
# Make sure we have tcprobe
30-
$Prog{'tcprobe'} = find_program('tcprobe');
31-
push @{$self->{'errors'}}, 'You need tcprobe to use this.' unless ($Prog{'tcprobe'});
31+
find_program('tcprobe')
32+
or push @{$self->{'errors'}}, 'You need tcprobe to use this.';
3233
# Make sure we have lvemux
33-
$Prog{'mplexer'} = find_program('lvemux');
34-
push @{$self->{'errors'}}, 'You need lvemux to use this.' unless ($Prog{'mplexer'});
34+
find_program('lvemux')
35+
or push @{$self->{'errors'}}, 'You need lvemux to use this.';
3536
# Make sure we have avidemux2
36-
$Prog{'avidemux'} = find_program('avidemux2');
37-
push @{$self->{'errors'}}, 'You need avidemux2 to use this.' unless ($Prog{'avidemux'});
37+
find_program('avidemux2')
38+
or push @{$self->{'errors'}}, 'You need avidemux2 to use this.';
3839
# Make sure we have mpeg2cut
39-
$Prog{'mpeg2cut'} = find_program('mpeg2cut');
40-
push @{$self->{'errors'}}, 'You need mpeg2cut to use this.' unless ($Prog{'mpeg2cut'});
40+
find_program('mpeg2cut')
41+
or push @{$self->{'errors'}}, 'You need mpeg2cut to use this.';
4142

4243
# Any errors? disable this function
4344
$self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
@@ -71,12 +72,12 @@ package export::MPEG2_cut;
7172
my $safe_outfile = shell_escape($self->get_outfile($episode, '.mpg'));
7273
my $standard = ($episode->{'finfo'}{'fps'} =~ /^2(?:5|4\.9)/) ? 'PAL' : 'NTSC';
7374
my $gopsize = ($standard eq 'PAL') ? 12 : 15;
74-
my $lastgop = ($episode->{'goptype'} == 6) ?
75+
my $lastgop = ($episode->{'goptype'} == 6) ?
7576
($gopsize * $episode->{'lastgop'}) :
7677
$episode->{'lastgop'};
7778

7879
my $command = "mpeg2cut $episode->{'filename'} $safe_outfile $lastgop ";
79-
80+
8081
@cuts = split("\n",$episode->{'cutlist'});
8182
my @skiplist;
8283
foreach my $cut (@cuts) {

trunk/export/NUV_SQL.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package export::NUV_SQL;
1515

1616
# Load the myth and nuv utilities, and make sure we're connected to the database
1717
use nuv_export::shared_utils;
18+
use nuv_export::cli;
1819
use nuv_export::ui;
1920
use mythtv::db;
2021
use mythtv::recordings;

trunk/export/ffmpeg.pm

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/perl -w
2-
#Last Updated: 2005.02.15 (xris)
2+
#Last Updated: 2005.02.17 (xris)
33
#
44
# ffmpeg.pm
55
#
@@ -16,14 +16,15 @@ package export::ffmpeg;
1616
use POSIX;
1717

1818
use nuv_export::shared_utils;
19+
use nuv_export::cli;
1920
use nuv_export::ui;
2021
use mythtv::recordings;
2122

2223
# This superclass defines several object variables:
2324
#
2425
# path (defined by generic)
2526
# use_cutlist (defined by generic)
26-
# denoise
27+
# noise_reduction
2728
# deinterlace
2829
# crop
2930
#
@@ -33,12 +34,12 @@ package export::ffmpeg;
3334
my $self = shift;
3435
my $audioonly = (shift or 0);
3536
# Make sure we have ffmpeg
36-
$Prog{'ffmpeg'} = find_program('ffmpeg');
37-
push @{$self->{'errors'}}, 'You need ffmpeg to use this exporter.' unless ($Prog{'ffmpeg'});
37+
my $ffmpeg = find_program('ffmpeg')
38+
or push @{$self->{'errors'}}, 'You need ffmpeg to use this exporter.';
3839
# Audio only?
3940
$self->{'audioonly'} = $audioonly;
4041
# Gather the supported codecs
41-
my $formats = `$Prog{'ffmpeg'} -formats`;
42+
my $formats = `$ffmpeg -formats 2>/dev/null`;
4243
$formats =~ s/^.+?\n\s*Codecs:\s*\n(.+?\n)\s*\n.*?$/$1/s;
4344
while ($formats =~ /^\s(.{6})\s(\S+)\s*$/mg) {
4445
$self->{'codecs'}{$2} = $1;
@@ -82,7 +83,7 @@ package export::ffmpeg;
8283
}
8384

8485
# 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)
85-
$mythtranscode = "nice -n $Args{'nice'} mythtranscode --showprogress -p autodetect -c $episode->{channel} -s $episode->{start_time_sep} -f \"/tmp/fifodir_$$/\"";
86+
$mythtranscode = "$NICE mythtranscode --showprogress -p autodetect -c $episode->{channel} -s $episode->{start_time_sep} -f \"/tmp/fifodir_$$/\"";
8687
$mythtranscode .= ' --honorcutlist' if ($self->{use_cutlist});
8788

8889
my $videofifo = "/tmp/fifodir_$$/vidout";
@@ -104,12 +105,12 @@ package export::ffmpeg;
104105
else {
105106
# Do noise reduction
106107
if ($self->{'noise_reduction'}) {
107-
$ffmpeg .= "nice -n $Args{'nice'} ffmpeg -f rawvideo";
108+
$ffmpeg .= "$NICE ffmpeg -f rawvideo";
108109
$ffmpeg .= " -s " . $episode->{'finfo'}{'width'} . "x" . $episode->{'finfo'}{'height'};
109110
$ffmpeg .= " -r " . $episode->{'finfo'}{'fps'};
110111
$ffmpeg .= " -i /tmp/fifodir_$$/vidout -f yuv4mpegpipe -";
111112
$ffmpeg .= " 2> /dev/null | ";
112-
$ffmpeg .= "nice -n $Args{'nice'} yuvdenoise -F -r 16";
113+
$ffmpeg .= "$NICE yuvdenoise -F -r 16";
113114
if ($self->{'crop'}) {
114115
$ffmpeg .= " -b $crop_w,$crop_h,-$crop_w,-$crop_h";
115116
}
@@ -120,7 +121,7 @@ package export::ffmpeg;
120121
}
121122

122123
# Start the ffmpeg command
123-
$ffmpeg .= "nice -n $Args{'nice'} ffmpeg";
124+
$ffmpeg .= "$NICE ffmpeg";
124125
if ($num_cpus > 1) {
125126
$transcode .= ' -threads '.($num_cpus);
126127
}

trunk/export/ffmpeg/ASF.pm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Last Updated: 2005.02.15 (xris)
1+
#Last Updated: 2005.02.16 (xris)
22
#
33
# export::ffmpeg::ASF
44
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
@@ -9,6 +9,7 @@ package export::ffmpeg::ASF;
99

1010
# Load the myth and nuv utilities, and make sure we're connected to the database
1111
use nuv_export::shared_utils;
12+
use nuv_export::cli;
1213
use nuv_export::ui;
1314
use mythtv::db;
1415
use mythtv::recordings;
@@ -57,19 +58,19 @@ package export::ffmpeg::ASF;
5758
$self->SUPER::gather_settings();
5859

5960
# Audio Bitrate
60-
if ($Args{'a_bitrate'}) {
61-
$self->{'a_bitrate'} = $Args{'a_bitrate'};
62-
die "Audio bitrate must be > 0\n" unless ($Args{'a_bitrate'} > 0);
61+
if (arg('a_bitrate')) {
62+
$self->{'a_bitrate'} = arg('a_bitrate');
63+
die "Audio bitrate must be > 0\n" unless (arg('a_bitrate') > 0);
6364
}
6465
else {
6566
$self->{'a_bitrate'} = query_text('Audio bitrate?',
6667
'int',
6768
$self->{'a_bitrate'});
6869
}
6970
# Ask the user what video bitrate he/she wants
70-
if ($Args{'v_bitrate'}) {
71-
die "Video bitrate must be > 0\n" unless ($Args{'v_bitrate'} > 0);
72-
$self->{'v_bitrate'} = $Args{'v_bitrate'};
71+
if (arg('v_bitrate')) {
72+
die "Video bitrate must be > 0\n" unless (arg('v_bitrate') > 0);
73+
$self->{'v_bitrate'} = arg('v_bitrate');
7374
}
7475
elsif ($self->{'multipass'} || !$self->{'vbr'}) {
7576
# make sure we have v_bitrate on the commandline

trunk/export/ffmpeg/DVCD.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package export::ffmpeg::DVCD;
1010

1111
# Load the myth and nuv utilities, and make sure we're connected to the database
1212
use nuv_export::shared_utils;
13+
use nuv_export::cli;
1314
use nuv_export::ui;
1415
use mythtv::db;
1516
use mythtv::recordings;

trunk/export/ffmpeg/DVD.pm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/perl -w
2-
#Last Updated: 2005.02.15 (xris)
2+
#Last Updated: 2005.02.16 (xris)
33
#
44
# export::ffmpeg::DVD
55
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
@@ -10,6 +10,7 @@ package export::ffmpeg::DVD;
1010

1111
# Load the myth and nuv utilities, and make sure we're connected to the database
1212
use nuv_export::shared_utils;
13+
use nuv_export::cli;
1314
use nuv_export::ui;
1415
use mythtv::db;
1516
use mythtv::recordings;
@@ -57,8 +58,8 @@ package export::ffmpeg::DVD;
5758
# Load the parent module's settings
5859
$self->SUPER::gather_settings();
5960
# Ask the user what audio bitrate he/she wants
60-
$self->{'a_bitrate'} = $Args{'a_bitrate'} if ($Args{'a_bitrate'});
61-
if (!$Args{'a_bitrate'} || $Args{'confirm'}) {
61+
$self->{'a_bitrate'} = arg('a_bitrate') if (arg('a_bitrate'));
62+
if (!arg('a_bitrate') || arg('confirm')) {
6263
while (1) {
6364
my $a_bitrate = query_text('Audio bitrate?',
6465
'int',
@@ -77,8 +78,8 @@ package export::ffmpeg::DVD;
7778
}
7879
# Ask the user what video bitrate he/she wants, or calculate the max bitrate
7980
my $max_v_bitrate = 9500 - $self->{'a_bitrate'};
80-
$self->{'v_bitrate'} = $Args{'v_bitrate'} if ($Args{'v_bitrate'});
81-
if (!$Args{'v_bitrate'} || $Args{'confirm'}) {
81+
$self->{'v_bitrate'} = arg('v_bitrate') if (arg('v_bitrate'));
82+
if (!arg('v_bitrate') || arg('confirm')) {
8283
while (1) {
8384
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
8485
'int',
@@ -96,8 +97,8 @@ package export::ffmpeg::DVD;
9697
}
9798
}
9899
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
99-
$self->{'quantisation'} = $Args{'quantisation'} if ($Args{'quantisation'});
100-
if (!$Args{'quantisation'} || $Args{'confirm'}) {
100+
$self->{'quantisation'} = arg('quantisation') if (arg('quantisation'));
101+
if (!arg('quantisation') || arg('confirm')) {
101102
while (1) {
102103
my $quantisation = query_text('VBR quality/quantisation (2-31)?', 'float', $self->{'quantisation'});
103104
if ($quantisation < 2) {

trunk/export/ffmpeg/DivX.pm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Last Updated: 2005.02.15 (xris)
1+
#Last Updated: 2005.02.16 (xris)
22
#
33
# export::ffmpeg::DivX
44
# Maintained by Gavin Hurlbut <gjhurlbu@gmail.com>
@@ -9,6 +9,7 @@ package export::ffmpeg::DivX;
99

1010
# Load the myth and nuv utilities, and make sure we're connected to the database
1111
use nuv_export::shared_utils;
12+
use nuv_export::cli;
1213
use nuv_export::ui;
1314
use mythtv::db;
1415
use mythtv::recordings;
@@ -57,19 +58,19 @@ package export::ffmpeg::DivX;
5758
$self->SUPER::gather_settings();
5859

5960
# Audio Bitrate
60-
if ($Args{'a_bitrate'}) {
61-
$self->{'a_bitrate'} = $Args{'a_bitrate'};
62-
die "Audio bitrate must be > 0\n" unless ($Args{'a_bitrate'} > 0);
61+
if (arg('a_bitrate')) {
62+
$self->{'a_bitrate'} = arg('a_bitrate');
63+
die "Audio bitrate must be > 0\n" unless (arg('a_bitrate') > 0);
6364
}
6465
else {
6566
$self->{'a_bitrate'} = query_text('Audio bitrate?',
6667
'int',
6768
$self->{'a_bitrate'});
6869
}
6970
# Ask the user what video bitrate he/she wants
70-
if ($Args{'v_bitrate'}) {
71-
die "Video bitrate must be > 0\n" unless ($Args{'v_bitrate'} > 0);
72-
$self->{'v_bitrate'} = $Args{'v_bitrate'};
71+
if (arg('v_bitrate')) {
72+
die "Video bitrate must be > 0\n" unless (arg('v_bitrate') > 0);
73+
$self->{'v_bitrate'} = arg('v_bitrate');
7374
}
7475
elsif ($self->{'multipass'} || !$self->{'vbr'}) {
7576
# make sure we have v_bitrate on the commandline

trunk/export/ffmpeg/MP3.pm

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/perl -w
2-
#Last Updated: 2005.02.15 (xris)
2+
#Last Updated: 2005.02.16 (xris)
33
#
44
# export::ffmpeg::MP3
55
# Maintained by Chris Petersen <mythtv@forevermore.net>
@@ -10,6 +10,7 @@ package export::ffmpeg::MP3;
1010

1111
# Load the myth and nuv utilities, and make sure we're connected to the database
1212
use nuv_export::shared_utils;
13+
use nuv_export::cli;
1314
use nuv_export::ui;
1415
use mythtv::db;
1516
use mythtv::recordings;
@@ -25,15 +26,15 @@ package export::ffmpeg::MP3;
2526
'enabled' => 1,
2627
'errors' => [],
2728
# Options
28-
'bitrate' => 128,
29+
'bitrate' => 128,
2930
};
3031
bless($self, $class);
3132

3233
# Initialize and check for transcode
3334
$self->init_ffmpeg(1);
3435
# Make sure that we have an mplexer
35-
$Prog{'id3tag'} = find_program('id3tag');
36-
push @{$self->{'errors'}}, 'You need id3tag to export an mp3.' unless ($Prog{'id3tag'});
36+
find_program('id3tag')
37+
or push @{$self->{'errors'}}, 'You need id3tag to export an mp3.';
3738
# Can we even encode vcd?
3839
if (!$self->can_encode('mp3')) {
3940
push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mp3 audio.";
@@ -48,12 +49,10 @@ package export::ffmpeg::MP3;
4849
my $self = shift;
4950
# Load the parent module's settings (skipping one parent, since we don't need the ffmpeg-specific options)
5051
$self->SUPER::gather_settings(1);
51-
# Just in case someone used the wrong commandline parameter
52-
$Args{'bitrate'} ||= $Args{'a_bitrate'};
5352
# Audio Bitrate
54-
if ($Args{'bitrate'}) {
55-
$self->{'bitrate'} = $Args{'bitrate'};
56-
die "Audio bitrate must be > 0\n" unless ($Args{'bitrate'} > 0);
53+
if (arg('bitrate')) {
54+
$self->{'bitrate'} = (arg('bitrate') or arg('a_bitrate'));
55+
die "Audio bitrate must be > 0\n" unless ($self->{'bitrate'} > 0);
5756
}
5857
else {
5958
$self->{'bitrate'} = query_text('Audio bitrate?',

trunk/export/ffmpeg/SVCD.pm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/perl -w
2-
#Last Updated: 2005.02.15 (xris)
2+
#Last Updated: 2005.02.16 (xris)
33
#
44
# export::ffmpeg::SVCD
55
# Maintained by Chris Petersen <mythtv@forevermore.net>
@@ -10,6 +10,7 @@ package export::ffmpeg::SVCD;
1010

1111
# Load the myth and nuv utilities, and make sure we're connected to the database
1212
use nuv_export::shared_utils;
13+
use nuv_export::cli;
1314
use nuv_export::ui;
1415
use mythtv::db;
1516
use mythtv::recordings;
@@ -57,8 +58,8 @@ package export::ffmpeg::SVCD;
5758
# Load the parent module's settings
5859
$self->SUPER::gather_settings();
5960
# Ask the user what audio bitrate he/she wants
60-
$self->{'a_bitrate'} = $Args{'a_bitrate'} if ($Args{'a_bitrate'});
61-
if (!$Args{'a_bitrate'} || $Args{'confirm'}) {
61+
$self->{'a_bitrate'} = arg('a_bitrate') if (arg('a_bitrate'));
62+
if (!arg('a_bitrate') || arg('confirm')) {
6263
while (1) {
6364
my $a_bitrate = query_text('Audio bitrate?',
6465
'int',
@@ -78,8 +79,8 @@ package export::ffmpeg::SVCD;
7879
# 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)
7980
# Then again, mpeg2enc seems to have trouble with bitrates > 2500
8081
my $max_v_bitrate = 2742 - $self->{'a_bitrate'};
81-
$self->{'v_bitrate'} = $Args{'v_bitrate'} if ($Args{'v_bitrate'});
82-
if (!$Args{'v_bitrate'} || $Args{'confirm'}) {
82+
$self->{'v_bitrate'} = arg('v_bitrate') if (arg('v_bitrate'));
83+
if (!arg('v_bitrate') || arg('confirm')) {
8384
$self->{'v_bitrate'} = ($max_v_bitrate < 2500) ? 2742 - $self->{'a_bitrate'} : 2500;
8485
while (1) {
8586
my $v_bitrate = query_text('Maximum video bitrate for VBR?',
@@ -98,8 +99,8 @@ package export::ffmpeg::SVCD;
9899
}
99100
}
100101
# Ask the user what vbr quality (quantisation) he/she wants - 2..31
101-
$self->{'quantisation'} = $Args{'quantisation'} if ($Args{'quantisation'});
102-
if (!$Args{'quantisation'} || $Args{'confirm'}) {
102+
$self->{'quantisation'} = arg('quantisation') if (arg('quantisation'));
103+
if (!arg('quantisation') || arg('confirm')) {
103104
while (1) {
104105
my $quantisation = query_text('VBR quality/quantisation (2-31)?', 'float', $self->{'quantisation'});
105106
if ($quantisation < 2) {

0 commit comments

Comments
 (0)