package External::FFmpeg; use parent 'Class::Accessor'; __PACKAGE__->mk_accessors(qw(width height depth pid stream texture_id file)); sub spawn { my ($self,$cmd) = @_; my $pid = open my $stream, $cmd or die "Couldn't spawn '$cmd': $!/$?"; binmode $stream; return ($pid,$stream) }; sub DESTROY { if (my $pid = $_[0]->pid) { kill 9, $pid }; }; package Target::FFmpeg; use strict; use parent -norequire => 'External::FFmpeg'; sub new { my ($class,%args) = @_; my $file = delete $args{filename}; my $width = delete $args{width} || 352; my $height = delete $args{height} || 288; my $in_width = delete $args{in_width} || $width; my $in_height = delete $args{in_height} || $height; my $depth = 3; my ($pid,$stream) = $class->spawn(qq{| bin\\ffmpeg-old.exe -y -f rawvideo -pix_fmt rgb24 -s ${in_width}x${in_height} -i "-" -f mpeg2video -s ${width}x${height} "$file"}); my $self = $class->SUPER::new({ width => $width, height => $height, depth => $depth, stream => $stream, pid => $pid, %args, }); $self };