Changeset 417

Show
Ignore:
Timestamp:
10/10/07 00:25:08 (11 months ago)
Author:
miya
Message:

FFmpeg::Command: Support timeout(), stdout() and stderr() methods.Thanks to Yasuhiro Horiuchi.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • library/perl/trunk/FFmpeg-Command/Changes

    r272 r417  
    11Revision history for FFmpeg-Command 
     2 
     30.07    Wed Oct 10 
     4        Support timeout(), stdout() and stderr() methods. 
     5        Thanks to Yasuhiro Horiuchi. 
    26 
    370.06    Sun Sep 24 
  • library/perl/trunk/FFmpeg-Command/lib/FFmpeg/Command.pm

    r416 r417  
    33use warnings; 
    44use strict; 
    5 our $VERSION = '0.06'; 
     5our $VERSION = '0.07'; 
    66 
    77use base qw( Class::Accessor::Fast Class::ErrorHandler ); 
    8 __PACKAGE__->mk_accessors( qw( input_file output_file ffmpeg options ) ); 
     8__PACKAGE__->mk_accessors( qw( input_file output_file ffmpeg options timeout stdout stderr ) ); 
    99 
    1010use IPC::Run qw( start ); 
     
    3333        input_file  => '', 
    3434        output_file => '', 
     35        timeout     => 0, 
    3536    }; 
    3637    bless $self, $class; 
     
    8990    my $self = shift; 
    9091 
    91     my ( $in, $out, $err ); 
     92    my @opts = ( \$self->{stdin}, \$self->{stdout}, \$self->{stderr} ); 
     93    push @opts, IPC::Run::timeout($self->timeout) if $self->timeout; 
     94 
    9295    my $h = eval { 
    93         start [ $self->ffmpeg, '-y', '-i', $self->input_file, @{ $self->options }, $self->output_file ], 
    94             \$in, \$out, \$err; 
     96        start( 
     97            [ 
     98                $self->ffmpeg, 
     99                '-y', 
     100                '-i', $self->input_file, 
     101                @{ $self->options }, 
     102                $self->output_file 
     103            ], 
     104            @opts, 
     105        ); 
    95106    }; 
    96107 
     
    101112    else { 
    102113        finish $h or do { 
    103             $self->error($err); 
     114            $self->error($self->stderr); 
    104115            return; 
    105116        }; 
     
    132143    }); 
    133144 
     145    # Set timeout 
     146    $ffmpeg->timeout(300); 
     147 
    134148    # Convert a video file into iPod playable format. 
    135149    $ffmpeg->output_options({ 
    136         file  => $output_file, 
     150        file  => $output_file, 
    137151        device => 'ipod', 
    138152    }); 
     
    204218You can omit this argument and this module searches ffmpeg command within PATH environment variable. 
    205219 
     220=head2 timeout() 
     221 
     222Set command timeout.Default is 0. 
    206223 
    207224=head2 input_options({ %options }) 
     
    291308An alias of execute() 
    292309 
     310=head2 stdout() 
     311 
     312Get ffmpeg command output to stdout. 
     313 
     314=head2 stderr() 
     315 
     316Get ffmpeg command output to stderr. 
    293317 
    294318=head1 AUTHOR