On 2007-06-12, Jim Kissel wrote:

> In my case firefox has a player installed for wmv files and starts to
> play this stream in the browser.  All I see is the tail end of a bbc
> weather forcast.  Just the bbc weather logo and about 5 seconds of
> sound.  Then nothing.
>
> wget doesn't get much.
>
> Can anyone up the ante with a better URL or an alternate method to
> view/download Click?  (ubuntu 7.04 FF)

Below is my ~/bin/record-real-media script for recording realplayer
audio streams.  I haven't tried video, but this might give you some
helpful ideas.  (It gives mplayer the -noconsolecontrols and
-really-quiet options because I usually use it in an at job.)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/perl -w
##################################################
use strict ;
use Getopt::Std ;
use LWP::UserAgent ;

my ( %option ) ;

getopts("pvhna", \%option) ;

if ($option{h}) {
    exec("perldoc " . $0) ;  # exec terminates this script
}

else {
    while (@ARGV) {
        my $url = shift(@ARGV);

        my $mplayer = mplayer_command($url);
        run_command($mplayer);

        if ($option{a}) {
            my $normalize = normalize_command($mplayer);
            run_command($normalize);
        }

        my $lame = lame_command($mplayer);
        run_command($lame);
    }
}

##################################################
##### END MAIN
##################################################

sub mplayer_command {
    my $url = $_[0];
    my $filename = time() ;
    if ($url =~ /([^\/]+)$/) {
        $filename = $1 ;
    }
    $filename .= ".wav" ;

    my $command = "mplayer -noconsolecontrols -really-quiet -ao pcm:file=" . 
$filename ;

    if ( ($option{p}) || ($url =~ /\.r[ap]m$/) )  {
        $command .= " -playlist ";
    }

    $command .= " \'" . $url . "\'" ;
    return $command ;
}


sub lame_command {
    my $input = $_[0] ;
    print ("lame <- $input\n") if ($option{v}) ;
    my $command = "echo \'no wav found\'" ;
    if ( $input =~ /=(\S+)(\.wav)/ ) {
        my $wav_file = $1 . $2 ;
        my $mp3_file = $1 . ".mp3" ;
        $command = "lame --quiet $wav_file $mp3_file" ;
    }
    return $command ;
}


sub normalize_command {
    my $input = $_[0] ;
    print ("normalize <- $input\n") if ($option{v}) ;
    my $command = "echo \'no wav found\'" ;
    if ( $input =~ /=(\S+)(\.wav)/ ) {
        my $wav_file = $1 . $2 ;
        $command = "normalize-audio -a 20dB $wav_file" ;
    }
    return $command ;
}


sub run_command {
    my $command = $_[0];
    print("CMD: $command\n");
    system($command) unless ($option{n});
}


##################################################
=head1 Options

=over

=item -h

Print this help and quit.

=item -v

Increase verbosity.

=item -a

Normalize to -20dB.

=item -p

Force mplayer '-playlist' option (automatically used for *.ram and *.rpm files).

=item -n

Dry run.

=back

=cut


-- 
ubuntu-uk@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.kubuntu.org/UKTeam/

Reply via email to