Skip to content

Commit

Permalink
lots of cleanup patches from Dennis Lou
Browse files Browse the repository at this point in the history
  • Loading branch information
ex-nerd committed Feb 15, 2004
1 parent 029c0ef commit 7ab3d45
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 145 deletions.
62 changes: 8 additions & 54 deletions trunk/export_DVD.pm
Expand Up @@ -17,7 +17,6 @@ package export_DVD;
*Args = *main::Args;
*Prog = *main::Prog;
*gui = *main::gui;
*DEBUG = *main::DEBUG;

sub new {
my $class = shift;
Expand Down Expand Up @@ -223,36 +222,16 @@ package export_DVD;
# Here, we have to fork off a copy of mythtranscode
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir} --fifosync";
$command .= ' --honorcutlist' if ($self->{use_cutlist});
if ($DEBUG) {
print "\nmythtranscode command:\n\n$command\n";
}
else {
push @{$self->{children}}, fork_command($command);
}
# Sleep a bit to let mythtranscode start up
if (!$DEBUG) {
my $overload = 0;
while (++$overload < 30 && !(-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout")) {
sleep 1;
print "Waiting for mythtranscode to set up the fifos.\n";
}
unless (-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout") {
die "Waited too long for mythtranscode to create its fifos. Please try again.\n\n";
}
}
push @{$self->{children}}, fork_command($command);
fifos_wait($self->{fifodir});
# Now we fork off a process to encode the audio
if ($Prog{toolame}) {
$command = "nice -n 19 sox -t raw -r $nuv_info{audio_sample_rate} -s -w -c 2 $self->{fifodir}/audout -t raw -r 48000 -s -w -c 2 - | nice -n 19 toolame -s 48.0 -m j -b $self->{a_bitrate} - $self->{tmp_a}";
} else {
$command = "nice -n 19 ffmpeg -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i $self->{fifodir}/audout -ac 2 -ar 48000 -ab $self->{a_bitrate} -vn -f mp2 $self->{tmp_a}";
}

if ($DEBUG) {
print "\naudio command:\n\n$command\n";
}
else {
push @{$self->{children}}, fork_command($command);
}
push @{$self->{children}}, fork_command($command);
# And lastly, we fork off a process to encode the video
# Multiple CPU's? Let's multiprocess
$cpus = num_cpus();
Expand Down Expand Up @@ -283,12 +262,7 @@ package export_DVD;
." --reduction-4x4 2 --reduction-2x2 1 --keep-hf"
.($cpus > 1 ? " --multi-thread $cpus" : '')
." -o $self->{tmp_v}";
if ($DEBUG) {
print "\nmpeg2enc command:\n\n$command\n";
}
else {
push @{$self->{children}}, fork_command($command);
}
push @{$self->{children}}, fork_command($command);
# Wait for child processes to finish
1 while (wait > 0);
$self->{children} = undef;
Expand All @@ -300,39 +274,19 @@ package export_DVD;
else {
$command = "nice -n 19 mplex -f 8 $self->{tmp_v} $self->{tmp_a} -o $safe_outfile";
}
if ($DEBUG) {
print "\nmultiplex command:\n\n$command\n\n";
} else {
system($command);
}

if ($self->{author_now}) {
$command = "nice -n 20 dvdauthor -t -o $self->{dvddir} $safe_outfile";
if ($DEBUG) {
print "\nauthor command 1:\n\n$command\n\n";
} else {
system($command);
}
system($command);
$command = "nice -n 20 dvdauthor -T -o $self->{dvddir}";
if ($DEBUG) {
print "\nauthor command 2:\n\n$command\n\n";
} else {
system($command);
}
system($command);
if ($self->{burn_now}) {
$command = "nice -n 20 growisofs -speed=$self->{dvdr_speed} -Z $self->{dvdr_path} -dvd-video $self->{dvddir}";
if ($DEBUG) {
print "\nburn command:\n\n$command\n\n";
} else {
system($command);
}
system($command);
} else {
$command = "nice -n 20 mkisofs -dvd-video -udf -o $safe_outfile.dvd.iso $self->{dvddir}";
if ($DEBUG) {
print "\nmkisofs command 1:\n\n$command\n\n";
} else {
system($command);
}
system($command);
}
}
}
Expand Down
25 changes: 9 additions & 16 deletions trunk/export_DivX.pm
Expand Up @@ -16,6 +16,7 @@ package export_DivX;
'episode' => undef,
'savepath' => '.',
'outfile' => 'out.avi',
'fifodir' => "fifodir.$$",
'use_cutlist' => 0,
'a_bitrate' => 64,
'v_bitrate' => 256,
Expand Down Expand Up @@ -79,7 +80,7 @@ package export_DivX;
sub execute {
my $self = shift;
# make sure that the fifo dir is clean
if (-e 'fifodir/vidout' || -e 'fifodir/audout') {
if (-e "$self->{fifodir}/vidout" || -e "$self->{fifodir}/audout") {
die "Possibly stale mythtranscode fifo's in fifodir.\nPlease remove them before running nuvexport.\n\n";
}
# Gather any necessary data
Expand All @@ -90,25 +91,17 @@ package export_DivX;
# Set this to true so that the cleanup routine actually runs
$self->{started} = 1;
# Create a directory for mythtranscode's fifo's
unless (-d 'fifodir') {
mkdir('fifodir', 0755) or die "Can't create fifodir: $!\n\n";
unless (-d $self->{fifodir}) {
mkdir($self->{fifodir}, 0755) or die "Can't create $self->{fifodir}: $!\n\n";
}
# Here, we have to fork off a copy of mythtranscode
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f fifodir";
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir}";
$command .= ' --honorcutlist' if ($self->{use_cutlist});
push @{$self->{children}}, fork_command($command);
# Sleep a bit to let mythtranscode start up
my $overload = 0;
while (++$overload < 30 && !(-e 'fifodir/audout' && -e 'fifodir/vidout')) {
sleep 1;
print "Waiting for mythtranscode to set up the fifos.\n";
}
unless (-e 'fifodir/audout' && -e 'fifodir/vidout') {
die "Waited too long for mythtranscode to create its fifos. Please try again.\n\n";
}
fifos_wait($self->{fifodir});
# Now we fork off a process to encode everything
$safe_outfile = shell_escape($self->{outfile});
$command = "nice -n 19 ffmpeg -y -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i fifodir/audout -f rawvideo -s $nuv_info{width}x$nuv_info{height} -r $nuv_info{fps} -i fifodir/vidout -b $self->{v_bitrate} -ab $self->{a_bitrate} -s $self->{h_res}x$self->{v_res} $safe_outfile";
$command = "nice -n 19 ffmpeg -y -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i $self->{fifodir}/audout -f rawvideo -s $nuv_info{width}x$nuv_info{height} -r $nuv_info{fps} -i $self->{fifodir}/vidout -b $self->{v_bitrate} -ab $self->{a_bitrate} -s $self->{h_res}x$self->{v_res} $safe_outfile";
push @{$self->{children}}, fork_command($command);
# Wait for child processes to finish
1 while (wait > 0);
Expand All @@ -126,10 +119,10 @@ package export_DivX;
1 while (wait > 0);
}
# Remove any temporary files
foreach my $file ('fifodir/audout', 'fifodir/vidout') {
foreach my $file ("$self->{fifodir}/audout", "$self->{fifodir}/vidout") {
unlink $file if (-e $file);
}
rmdir 'fifodir' if (-e 'fifodir');
rmdir $self->{fifodir} if (-e $self->{fifodir});
}

1; #return true
15 changes: 1 addition & 14 deletions trunk/export_MP3.pm
Expand Up @@ -91,20 +91,10 @@ package export_MP3;
# my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir} --fifosync";
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir} --fifosync";
# $command .= ' --honorcutlist' if ($self->{use_cutlist});
print "$command \n" ;
push @{$self->{children}}, fork_command($command);
# Sleep a bit to let mythtranscode start up
my $overload = 0;
while (++$overload < 30 && !(-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout")) {
sleep 1;
print "Waiting for mythtranscode to set up the fifos.\n";
}
unless (-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout") {
die "Waited too long for mythtranscode to create its fifos. Please try again.\n\n";
}
fifos_wait($self->{fifodir});
# Now we fork off a process to extract the audio
$command = "nice -19 cat < $self->{fifodir}/audout > $self->{tmp_a}" ;
print "$command \n";
push @{$self->{children}}, fork_command($command);

# Null command for video
Expand All @@ -119,13 +109,10 @@ package export_MP3;
$sample = $nuv_info{audio_sample_rate} / 1000;
my $safe_outfile = shell_escape($self->{outfile});
$command = "nice -n 19 toolame -t1 -s $sample -m j -b $self->{bitrate} $self->{tmp_a} $safe_outfile";
#$command = "nice -n 19 lame -r -v -q 2 -s $sample -m j -V 2 -B $self->{bitrate} $self->{tmp_a} $safe_outfile";
print "$command \n";
system($command);

# Now tag it
$command = "id3tag -A\"$self->{episode}->{title}\" -a\"$self->{episode}->{channel}\" -c\"$self->{episode}->{description}\" -s\"$self->{episode}->{show_name}\" $safe_outfile";
print "$command \n";
system($command);
}

Expand Down
38 changes: 4 additions & 34 deletions trunk/export_SVCD.pm
Expand Up @@ -16,7 +16,6 @@ package export_SVCD;
*Args = *main::Args;
*Prog = *main::Prog;
*gui = *main::gui;
*DEBUG = *main::DEBUG;

sub new {
my $class = shift;
Expand Down Expand Up @@ -198,31 +197,11 @@ package export_SVCD;
# Here, we have to fork off a copy of mythtranscode
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir} --fifosync";
$command .= ' --honorcutlist' if ($self->{use_cutlist});
if ($DEBUG) {
print "\nmythtranscode command:\n\n$command\n";
}
else {
push @{$self->{children}}, fork_command($command);
}
# Sleep a bit to let mythtranscode start up
if (!$DEBUG) {
my $overload = 0;
while (++$overload < 30 && !(-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout")) {
sleep 1;
print "Waiting for mythtranscode to set up the fifos.\n";
}
unless (-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout") {
die "Waited too long for mythtranscode to create its fifos. Please try again.\n\n";
}
}
push @{$self->{children}}, fork_command($command);
fifos_wait($self->{fifodir});
# Now we fork off a process to encode the audio
$command = "nice -n 19 ffmpeg -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i $self->{fifodir}/audout -ar 44100 -ab $self->{a_bitrate} -vn -f mp2 $self->{tmp_a}";
if ($DEBUG) {
print "\naudio command:\n\n$command\n";
}
else {
push @{$self->{children}}, fork_command($command);
}
push @{$self->{children}}, fork_command($command);
# And lastly, we fork off a process to encode the video
# Multiple CPU's? Let's multiprocess
$cpus = num_cpus();
Expand Down Expand Up @@ -256,12 +235,7 @@ package export_SVCD;
." --reduction-4x4 2 --reduction-2x2 1"
.($cpus > 1 ? " --multi-thread $cpus" : '')
." -o $self->{tmp_v}";
if ($DEBUG) {
print "\nmpeg2enc command:\n\n$command\n";
}
else {
push @{$self->{children}}, fork_command($command);
}
push @{$self->{children}}, fork_command($command);
# Wait for child processes to finish
1 while (wait > 0);
$self->{children} = undef;
Expand All @@ -273,10 +247,6 @@ package export_SVCD;
else {
$command = "nice -n 19 mplex -f 5 $self->{tmp_v} $self->{tmp_a} -o $safe_outfile";
}
if ($DEBUG) {
print "\nmultiplex command:\n\n$command\n\n";
exit;
}
system($command);
}

Expand Down
10 changes: 1 addition & 9 deletions trunk/export_VCD.pm
Expand Up @@ -99,15 +99,7 @@ package export_VCD;
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir} --fifosync";
$command .= ' --honorcutlist' if ($self->{use_cutlist});
push @{$self->{children}}, fork_command($command);
# Sleep a bit to let mythtranscode start up
my $overload = 0;
while (++$overload < 30 && !(-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout")) {
sleep 1;
print "Waiting for mythtranscode to set up the fifos.\n";
}
unless (-e "$self->{fifodir}/audout" && -e "$self->{fifodir}/vidout") {
die "Waited too long for mythtranscode to create its fifos. Please try again.\n\n";
}
fifos_wait($self->{fifodir});
# Now we fork off a process to encode the audio
if ($Prog{mp2_encoder} =~ /\btoolame$/) {
$sample = $nuv_info{audio_sample_rate} / 1000;
Expand Down
25 changes: 9 additions & 16 deletions trunk/export_WMV.pm
Expand Up @@ -16,6 +16,7 @@ package export_WMV;
'episode' => undef,
'savepath' => '.',
'outfile' => 'out.wmv',
'fifodir' => "fifodir.$$",
'use_cutlist' => 0,
'a_bitrate' => 64,
'v_bitrate' => 256,
Expand Down Expand Up @@ -81,7 +82,7 @@ package export_WMV;
sub execute {
my $self = shift;
# make sure that the fifo dir is clean
if (-e 'fifodir/vidout' || -e 'fifodir/audout') {
if (-e "$self->{fifodir}/vidout" || -e "$self->{fifodir}/audout") {
die "Possibly stale mythtranscode fifo's in fifodir.\nPlease remove them before running nuvexport.\n\n";
}
# Gather any necessary data
Expand All @@ -92,25 +93,17 @@ package export_WMV;
# Set this to true so that the cleanup routine actually runs
$self->{started} = 1;
# Create a directory for mythtranscode's fifo's
unless (-d 'fifodir') {
mkdir('fifodir', 0755) or die "Can't create fifodir: $!\n\n";
unless (-d $self->{fifodir}) {
mkdir($self->{fifodir}, 0755) or die "Can't create $self->{fifodir}: $!\n\n";
}
# Here, we have to fork off a copy of mythtranscode
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f fifodir";
my $command = "nice -n 19 mythtranscode -p autodetect -c $self->{episode}->{channel} -s $self->{episode}->{start_time_sep} -f $self->{fifodir}";
$command .= ' --honorcutlist' if ($self->{use_cutlist});
push @{$self->{children}}, fork_command($command);
# Sleep a bit to let mythtranscode start up
my $overload = 0;
while (++$overload < 30 && !(-e 'fifodir/audout' && -e 'fifodir/vidout')) {
sleep 1;
print "Waiting for mythtranscode to set up the fifos.\n";
}
unless (-e 'fifodir/audout' && -e 'fifodir/vidout') {
die "Waited too long for mythtranscode to create its fifos. Please try again.\n\n";
}
fifos_wait($self->{fifodir});
# Now we fork off a process to encode everything
$safe_outfile = shell_escape($self->{outfile});
$command = "nice -n 19 ffmpeg -y -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i fifodir/audout -f rawvideo -s $nuv_info{width}x$nuv_info{height} -r $nuv_info{fps} -i fifodir/vidout -b $self->{v_bitrate} -ab $self->{a_bitrate} -s $self->{h_res}x$self->{v_res} $safe_outfile";
$command = "nice -n 19 ffmpeg -y -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i $self->{fifodir}/audout -f rawvideo -s $nuv_info{width}x$nuv_info{height} -r $nuv_info{fps} -i $self->{fifodir}/vidout -b $self->{v_bitrate} -ab $self->{a_bitrate} -s $self->{h_res}x$self->{v_res} $safe_outfile";
push @{$self->{children}}, fork_command($command);
# Wait for child processes to finish
1 while (wait > 0);
Expand All @@ -128,10 +121,10 @@ package export_WMV;
1 while (wait > 0);
}
# Remove any temporary files
foreach my $file ('fifodir/audout', 'fifodir/vidout') {
foreach my $file ("$self->{fifodir}/audout", "$self->{fifodir}/vidout") {
unlink $file if (-e $file);
}
rmdir 'fifodir' if (-e 'fifodir');
rmdir $self->{fifodir} if (-e $self->{fifodir});
}

1; #return true
3 changes: 2 additions & 1 deletion trunk/gui_text.pm
Expand Up @@ -6,6 +6,7 @@ package gui_text;
*Shows = *main::Shows;
*Functions = *main::Functions;
*num_shows = *main::num_shows;
*DEBUG = *main::DEBUG;

sub new {
my $class = shift;
Expand All @@ -25,7 +26,7 @@ package gui_text;
# Display the show list
while (1) {
# Clear the screen
system('clear');
system('clear') unless ($DEBUG);
# Stage "quit" means, well, quit...
if ($self->stage eq 'quit') {
# Report the duration
Expand Down

0 comments on commit 7ab3d45

Please sign in to comment.