Updated nuvexport patch

Share

To get nuvexport working with MythTV User Jobs as a transcoder, I needed to further modify my nuvexport patch to handle the fact that there is no controlling terminal for user jobs. Here is the new patch:

    Index: export/ffmpeg.pm
    ===================================================================
    --- export/ffmpeg.pm    (revision 242)
    +++ export/ffmpeg.pm    (working copy)
    @@ -70,11 +70,11 @@
         # Audio only?
             $self->{'audioonly'} = $audioonly;
         # Gather the supported codecs
    -        my $data      = `$ffmpeg -formats 2>/dev/null`;
    +        my $data      = `$ffmpeg -formats 2>&1`;
             my ($formats) = $data =~ /(?:^|\n\s*)File\sformats:\s*\n(.+?\n)\s*\n/s;
             my ($codecs)  = $data =~ /(?:^|\n\s*)Codecs:\s*\n(.+?\n)\s*\n/s;
             if ($formats) {
    -            while ($formats =~ /^\s(..)\s(\S+)\s*$/mg) {
    +            while ($formats =~ /^\s(.{2})\s(\S+).*$/mg) {
                     $self->formats'}{$2} = $1;
                 }
             }
    @@ -286,7 +286,7 @@
             push @tmpfiles, "/tmp/fifodir_$$", "/tmp/fifodir_$$/audout", "/tmp/fifodir_$$/vidout";
    
         # Execute ffmpeg
    -        print "Starting ffmpeg.\n" unless ($DEBUG);
    +        print "Starting ffmpeg: $ffmpeg\n" unless ($DEBUG);
             ($ffmpeg_pid, $ffmpeg_h) = fork_command("$ffmpeg 2>&1");
             $children{$ffmpeg_pid} = 'ffmpeg' if ($ffmpeg_pid);
    
    Index: export/ffmpeg/PSP.pm
    ===================================================================
    --- export/ffmpeg/PSP.pm        (revision 242)
    +++ export/ffmpeg/PSP.pm        (working copy)
    @@ -170,7 +170,8 @@
             $self->{'ffmpeg_xtra'}  = ' -b ' . $self->{'v_bitrate'}
                                      .' -bufsize 65535'
                                      .' -ab 32 -acodec aac'
    -                                 ." -f psp -title $safe_title";
    +                                 ." -f psp -title $safe_title"
    +                                 .' -ar 24000';
         # Execute the parent method
             $self->SUPER::export($episode, '.MP4');
    
    Index: nuv_export/shared_utils.pm
    ===================================================================
    --- nuv_export/shared_utils.pm  (revision 242)
    +++ nuv_export/shared_utils.pm  (working copy)
    @@ -66,7 +66,11 @@
             $termios->getattr;
             $OSPEED = $termios->getospeed;
         };
    -    our $terminal = Term::Cap->Tgetent({OSPEED=>OSPEED});
    +
    +    my $terminal = Null; # This is the controlling terminal
    +    eval {
    +        $terminal = Term::Cap->Tgetent({OSPEED=>$OSPEED});
    +    };
    
     # Gather info about how many cpu's this machine has
         if (-e '/proc/cpuinfo') {
    @@ -85,7 +89,16 @@
    
     # Clear the screen
         sub clear {
    -        print $DEBUG ? "\n" : $terminal->Tputs('cl');
    +        print $terminal;
    +        if ($DEBUG) {
    +            print "\n";
    +        }
    +        elsif ($terminal ne Null ) {
    +            $terminal->Tputs('cl');
    +        }
    +        else {
    +            print "\n";
    +        }
         }
    
     # Byte swap a 32-bit number from little-endian to big-endian
    Index: nuv_export/ui.pm
    ===================================================================
    --- nuv_export/ui.pm    (revision 242)
    +++ nuv_export/ui.pm    (working copy)
    @@ -380,6 +380,7 @@
                 $count++;
                 $query .= (' ' x (3 - length($count)))."$count. ".$exporter->{'name'};
                 $query .= ' (disabled)' unless ($exporter->{'enabled'});
    +            $query .= "\n\t\tErrors: @{$exporter->{'errors'}}\n" unless ($exporter->{'enabled'});
                 $query .= "\n";
             }
             $query .= "\n  q. Quit\n\nChoose a function: ";
    

You can download the patch from here.

Update: Isn’t it always the way? Once I had the patch posted I bothered to get a new SVN version, and noticed that some of my patches had been included there. Here’s a new version of the nuvexport patch which will cleanly apply:

    Index: export/ffmpeg.pm
    ===================================================================
    --- export/ffmpeg.pm	(revision 271)
    +++ export/ffmpeg.pm	(working copy)
    @@ -300,7 +300,7 @@
                 $children{$cat_pid} = 'audio dump' if ($cat_pid);
             }
         # Execute ffmpeg
    -        print "Starting ffmpeg.\n" unless ($DEBUG);
    +        print "Starting ffmpeg: $ffmpeg\n" unless ($DEBUG);
             ($ffmpeg_pid, $ffmpeg_h) = fork_command("$ffmpeg 2>&1");
             $children{$ffmpeg_pid} = 'ffmpeg' if ($ffmpeg_pid);
    
    Index: export/ffmpeg/PSP.pm
    ===================================================================
    --- export/ffmpeg/PSP.pm	(revision 271)
    +++ export/ffmpeg/PSP.pm	(working copy)
    @@ -170,7 +170,8 @@
             $self->ffmpeg_xtra'}  = ' -b ' . $self->{'v_bitrate'}
                                      .' -bufsize 65535'
                                      .' -ab 32 -acodec aac'
    -                                 ." -f psp -title $safe_title";
    +                                 ." -f psp -title $safe_title"
    +                                 .' -ar 24000';
         # Execute the parent method
             $self->SUPER::export($episode, '.MP4');
    
    Index: nuv_export/shared_utils.pm
    ===================================================================
    --- nuv_export/shared_utils.pm	(revision 271)
    +++ nuv_export/shared_utils.pm	(working copy)
    @@ -66,7 +66,11 @@
             $termios->getattr;
             $OSPEED = $termios->getospeed;
         };
    -    our $terminal = Term::Cap->Tgetent({OSPEED=li>$OSPEED});
    +
    +    my $terminal = Null; # This is the controlling terminal
    +    eval {
    +        $terminal = Term::Cap->Tgetent({OSPEED=>$OSPEED});
    +    };
    
     # Gather info about how many cpu's this machine has
         if (-e '/proc/cpuinfo') {
    @@ -85,7 +89,15 @@
    
     # Clear the screen
         sub clear {
    -        print $DEBUG ? "\n" : $terminal->Tputs('cl');
    +        if ($DEBUG) {
    +            print "\n";
    +        }
    +        elsif ($terminal ne Null ) {
    +            $terminal->Tputs('cl');
    +        }
    +        else {
    +            print "\n";
    +        }
         }
    
     # Byte swap a 32-bit number from little-endian to big-endian
    Index: nuv_export/ui.pm
    ===================================================================
    --- nuv_export/ui.pm	(revision 271)
    +++ nuv_export/ui.pm	(working copy)
    @@ -380,6 +380,7 @@
                 $count++;
                 $query .= (' ' x (3 - length($count)))."$count. ".$exporter->{'name'};
                 $query .= ' (disabled)' unless ($exporter->{'enabled'});
    +            $query .= "\n\t\tErrors: @{$exporter->{'errors'}}\n" unless ($exporter->{'enabled'});
                 $query .= "\n";
             }
             $query .= "\n  q. Quit\n\nChoose a function: ";
    

You can download the patch as well.

Share