$mplayer_path = "/path/to/mplayer"; $video_file = "test_file.avi"; #create a temporary directory. my $temppath = "/tmp/screenshots." . int(rand(1e7)); if( ! mkdir($temppath)){ print("Error: $!\n"); exit(1); } if( ! chdir($temppath)){ print("Error: $!\n"); exit(1); } # Pick a mode: # Every single frame # system($mplayer_path, "-vo", "png:z=3", "-ao", "null", $video_file); # Every 20th frame system($mplayer_path, "-vo", "png:z=3", "-vf", "framestep=20", "-ao", "null", $video_file); # Every keyframe # system($mplayer_path, "-vo", "png:z=3", "-vf", "framestep=I", "-ao", "null", $video_file); #mplayer creates many files of the form "^\d{8}\.png$" in the current directory. my $dirh; if( ! opendir($dirh, $temppath)) { print("Error: $!\n"); exit(1); } my @frames = readdir($dirh); closedir($dirh); foreach(@frames){ #do something useful, or delete the file. }