#
# Converts an input video stream to blank and white using PDL.
#

use YUV4MPEG;
use PDL;
use PDL::ImageRGB;

my $streaminfo = new YUV4MPEG::StreamInfo;
my $frameinfo = new YUV4MPEG::FrameInfo;

$streaminfo->read();
$streaminfo->write();

my $frame = new YUV4MPEG::Frame($streaminfo);
my $frame_cnt = 0;
my $pdl;

while ($frame->read($frameinfo) == Y4M_OK)
{
  $frame->to_rgb();
  $pdl = $frame->get_pdl_data();

  $pdl .= $pdl->rgbtogr()->dummy(0,3);  

  $frame->set_pdl_data($pdl);
  $frame->to_yuv();

  $frame->write($frameinfo);
  $frameinfo = new YUV4MPEG::FrameInfo;

  $frame_cnt++;
  print STDERR "Done frame $frame_cnt...\n";
}
