Changeset 416

Show
Ignore:
Timestamp:
10/09/07 22:07:17 (1 year ago)
Author:
miya
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • library/perl/trunk/FFmpeg-Command/lib/FFmpeg/Command.pm

    r395 r416  
    33use warnings; 
    44use strict; 
    5 our $VERSION = '0.07'; 
     5our $VERSION = '0.06'; 
    66 
    77use base qw( Class::Accessor::Fast Class::ErrorHandler ); 
     
    4545sub output_options { 
    4646    my ( $self, $args ) = @_; 
    47  
    4847    $self->output_file(delete $args->{file}); 
    4948    my $device = delete $args->{device} || 'ipod'; 
    50     my $media  = delete $args->{media}  || 'video'; 
    51  
    52     if ( delete $args->{auto_set_media} ) { 
    53         unless ( $self->input_file ) { 
    54             $self->error('You must call input_file() or input_options() for setting input file name before calling output_options() when you set auto_set_media to 1.'); 
    55             return; 
    56         } 
    57         require MIME::Types; 
    58         my $myme = MIME::Types->new; 
    59         $media = $mime->mimeTypeOf( $self->input_file ); 
    60         $media =~ s!(.[^/]+)/!$1!; 
    61     } 
    62  
    63     if ( $media ne 'video' and $media 'audio' ) { 
    64         $self->error("media '$media' is not valid.'video' or 'audio' is valid."); 
    65         return; 
    66     } 
    6749 
    6850    my %device_option = ( 
     
    8769    ); 
    8870 
    89     my %audio_option = ( 
    90         audio_codec         => 'mp3', 
    91         audio_sampling_rate => 48000, 
    92         audio_bit_rate      => 128, 
     71    my %output_option = ( 
     72        %{ $device_option{$device} }, 
     73        %$args, 
    9374    ); 
    94  
    95     my %output_option; 
    96     if ( $media eq 'video' ) { 
    97         %output_option = ( 
    98             %{ $device_option{$device} }, 
    99             %$args, 
    100         ); 
    101     } 
    102     else { 
    103         %output_option = ( 
    104             %audio_option, 
    105             %$args, 
    106         ); 
    107     } 
    10875 
    10976    for ( keys %output_option ){ 
     
    212179    $ffmpeg->exec(); 
    213180 
    214     # Convert a audio file into a mp3 formatted auto file. 
    215     $ffmed->output_options({ 
    216         media => 'audio', 
    217     }); 
    218  
    219     $ffmpeg->exec(); 
    220  
    221     # Convert a audio file into a aac formatted auto file. 
    222     $ffmed->output_options({ 
    223         media               => 'audio', 
    224         audio_codec         => 'aac', 
    225         audio_sampling_rate => 48000, 
    226         audio_bit_rate      => 128, 
    227     }); 
    228  
    229     $ffmpeg->exec(); 
    230  
    231     # Detect media type of an input file automatically and set output options automatically for the media type. 
    232     $ffmed->output_options({ 
    233         auto_set_media => 1, 
    234     }); 
    235  
    236     $ffmpeg->exec(); 
    237  
    238181    # Execute ffmpeg with any options you like. 
    239182    # This sample code takes a screnn shot. 
     
    326269Set the comment. 
    327270 
    328 =item media 
    329  
    330 Set the media type (video or audio) of an output file.Default is 'video'. 
    331  
    332 =item auto_set_media 
    333  
    334 Set the media type of an output file automatically from an input file. 
    335  
    336271=back 
    337272