FFmpeg
view release on metacpan or search on metacpan
#instantiate a new FFmpeg object.
my $ff = FFmpeg->new();
foreach my $media (@media){
#load each media file
$ff->input_file($media);
#or from a URL. note that input_url
#enables use of other input_url_* args
$ff->input_url('http://wherever.org/whatever.mpg');
$ff->input_url_referrer('http://somewhere.org/overtherainbow');
$ff->input_url_max_size('5000'); #in bytes
#and create the stream info, accessible in a
#FFmpeg::StreamGroup object.
my $sg = $ff->create_streamgroup();
#we're only interested in StreamGroups with
#a visual component
next unless $sg->has_video;
#capture a frame at offset 30s into the video
#stream in jpeg format, and get a filehandle on
#the jpeg data stream.
my $fh = $sg->capture_frame(
image_format => $ff->image_format('jpeg'),
start_time => '00:00:30'
);
#write the jpeg to a file.
open(JPEG, ">$media.jpg");
print JPEG $_ while <$fh>;
close(JPEG);
}
=head1 DESCRIPTION
FFmpeg (in this module, referred to here as B<FFmpeg-Perl>) is a
Perl interface to the base project FFmpeg (referred to here as
B<FFmpeg-C>). From the B<FFmpeg-C> homepage:
B<FFmpeg-C> is a complete solution to record, convert and stream
audio and video. It includes libavcodec, the leading
audio/video codec library. B<FFmpeg-C> is developed under Linux,
but it can compiled under most OSes, including Windows.
The project is made of several components:
=over 4
=item I<ffmpeg>
a command line tool to convert one video file format to another.
It also supports grabbing and encoding in real time from a TV
card.
=item I<ffserver>
an HTTP (RTSP is being developped) multimedia
streaming server for live broadcasts. Time shifting of
live broadcast is also supported.
=item I<ffplay>
a simple media player based on SDL and on the ffmpeg libraries.
=item I<libavcodec>
a library containing all the ffmpeg audio/video encoders and
decoders. Most codecs were developed from scratch to ensure
best performances and high code reusability.
=item I<libavformat>
a library containing parsers and generators for all common
audio/video formats.
=back
B<FFmpeg-Perl> currently only supports the functionality of the
I<ffmpeg> and I<libavformat> components of the B<FFmpeg-C>
suite. That is, functions exist for extracting metadata from
media streams and transforming one media stream format to
another, but no effort is (yet) made to port HTTP
broadcasting or playback functionality (provided by the
I<ffserver> and I<ffplay> components, respectively).
=head1 FEEDBACK
=head2 Mailing Lists
Questions, feedback, and bug reports related to the B<FFmpeg-Perl>
interface to B<FFmpeg-C> should be sent to the Perl Video mailing
list. Subscribe here:
L<http://sumo.genetics.ucla.edu/mailman/listinfo/perl-video/>
Questions, feedback, and bug reports related to the underlying
B<FFmpeg-C> code should be sent to the general ffmpeg user and
developer. More information is available here:
L<http://ffmpeg.sourceforge.net/>
=head2 Reporting Bugs
See "Mailing Lists" above.
=head2 Patches
I'm very open to bug reports in the form of patches, as well as
patches that extend or add to the functionality of the library.
Please send a diff using "diff -up", along with a summary of the
purpose of the patch to the Perl Video mailing list (address
above, see "Mailing Lists").
=head1 AUTHOR
Allen Day E<lt>allenday@ucla.eduE<gt>
( run in 0.352 second using v1.01-cache-2.11-cpan-140bd7fdf52 )