Changeset 416
- Timestamp:
- 10/09/07 22:07:17 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
library/perl/trunk/FFmpeg-Command/lib/FFmpeg/Command.pm
r395 r416 3 3 use warnings; 4 4 use strict; 5 our $VERSION = '0.0 7';5 our $VERSION = '0.06'; 6 6 7 7 use base qw( Class::Accessor::Fast Class::ErrorHandler ); … … 45 45 sub output_options { 46 46 my ( $self, $args ) = @_; 47 48 47 $self->output_file(delete $args->{file}); 49 48 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 }67 49 68 50 my %device_option = ( … … 87 69 ); 88 70 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, 93 74 ); 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 }108 75 109 76 for ( keys %output_option ){ … … 212 179 $ffmpeg->exec(); 213 180 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 238 181 # Execute ffmpeg with any options you like. 239 182 # This sample code takes a screnn shot. … … 326 269 Set the comment. 327 270 328 =item media329 330 Set the media type (video or audio) of an output file.Default is 'video'.331 332 =item auto_set_media333 334 Set the media type of an output file automatically from an input file.335 336 271 =back 337 272
