printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
    if ($mov->hasAudio()) {
        printf("get audio codec = %s\n", $mov->getAudioCodec());
        printf("get audio bit rate = %d\n", $mov->getAudioBitRate());
        printf("get audio sample rate = %d \n", $mov->getAudioSampleRate());
        printf("get audio channels = %s\n", $mov->getAudioChannels());
    }
    printf("has video = %s\n", $mov->hasVideo() == 0 ? 'No' : 'Yes');
    if ($mov->hasVideo()) {
        printf("frame height = %d pixels\n", $mov->getFrameHeight());
        printf("frame width = %d pixels\n", $mov->getFrameWidth());
        printf("get video codec = %s\n", $mov->getVideoCodec());
        printf("get video bit rate = %d\n", $mov->getVideoBitRate());
        printf("get pixel format = %s\n", $mov->getPixelFormat());
        printf("get pixel aspect ratio = %s\n", $mov->getPixelAspectRatio());
        printf("get frame = %s\n", is_object($mov->getFrame(10)) ? 'true' : 'false');
        printf("get frame number = %d\n", $mov->getFrameNumber());
    }
    echo "\n\n--------------------\n";
}
if (php_sapi_name() != 'cgi') {
    echo '</pre>';
}
/* FUNCTIONS */
function print_class_methods($class)
{
    echo "\nMethods available in class '{$class}':\n";
    $methods = get_class_methods($class);
    if (is_array($methods)) {
        foreach ($methods as $method) {
            echo $method . "\n";
<?php 
function_exists("imagecreatetruecolor") or die("skip function imagecreatetruecolor unavailable");
require_once '../../ffmpeg_movie.php';
require_once '../../ffmpeg_frame.php';
require_once '../../ffmpeg_animated_gif.php';
$ignore_demo_files = true;
$dir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
require_once $dir . '/examples/example-config.php';
$tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'tmp/';
?>
--FILE--
<?php 
$mov = new PHPVideoToolkit_movie($dir . '/examples/to-be-processed/cat.mpeg', false, $tmp_dir);
$img = $tmp_dir . '/test-';
$i = 0;
while (($frame = $mov->getFrame()) != false) {
    $i++;
    $filename = $img . $i . '.png';
    $gd_image = $frame->toGDImage();
    imagepng($gd_image, $filename);
    printf("ffmpeg getFrame({$i}): md5 = %s\n", md5(file_get_contents($filename)));
    imagedestroy($gd_image);
    unlink($filename);
}
?>
--EXPECT--
ffmpeg getFrame(1): md5 = 3bdd86fce4a2556bd53b58c1bbebc7da
ffmpeg getFrame(2): md5 = 551362661dca92950a67e2462e246acb
ffmpeg getFrame(3): md5 = 143a0dad4fe8c1fdd3ea446193849e27
ffmpeg getFrame(4): md5 = 9a3b99e039a2d9a39ac5f386da37a35a
ffmpeg getFrame(5): md5 = ad6f536e556da31d751f53566d2da2bf
<?php 
function_exists("imagecreatetruecolor") or die("skip function imagecreatetruecolor unavailable");
require_once '../../ffmpeg_movie.php';
require_once '../../ffmpeg_frame.php';
require_once '../../ffmpeg_animated_gif.php';
$ignore_demo_files = true;
$dir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
require_once $dir . '/examples/example-config.php';
$tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'tmp/';
?>
--FILE--
<?php 
$mov = new PHPVideoToolkit_movie($dir . '/examples/to-be-processed/Video000.3gp', false, $tmp_dir);
$agif = sprintf("%s/test.gif", $tmp_dir);
$ff_gif = new PHPVideoToolkit_animated_gif($agif, 120, 96, 5, 5);
for ($i = 1; $i < 70; $i += 10) {
    $ff_frame = $mov->getFrame($i);
    $ff_gif->addFrame($ff_frame);
}
$img = imagecreatetruecolor(128, 96);
$red = imagecolorallocate($img, 255, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
imagerectangle($img, 5, 5, 90, 90, $white);
$ff_frame_img = new PHPVideoToolkit_frame($img);
$ff_gif->addFrame($ff_frame_img);
printf("ffmpeg animated gif: md5 = %s\n", md5(file_get_contents($agif)));
// unlink($agif);
?>
--EXPECT--
ffmpeg animated gif: md5 = 81441e56d9cb5c781e5f7499217614a3
예제 #4
0
<?php 
function_exists("imagecreatetruecolor") or die("skip function imagecreatetruecolor unavailable");
require_once '../../ffmpeg_movie.php';
require_once '../../ffmpeg_frame.php';
require_once '../../ffmpeg_animated_gif.php';
$ignore_demo_files = true;
$dir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
require_once $dir . '/examples/example-config.php';
$tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'tmp/';
?>
--FILE--
<?php 
$frame = 73;
$mov = new PHPVideoToolkit_movie($dir . '/examples/to-be-processed/cat.mpeg', false, $tmp_dir);
$img = sprintf("%s/test-%04d.png", $tmp_dir, $frame);
$ff_frame = $mov->getFrame($frame);
if ($ff_frame) {
    $gd_image = $ff_frame->toGDImage();
    if ($gd_image) {
        imagepng($gd_image, $img);
        imagedestroy($gd_image);
        // generate md5 of file (NOTE: different versions of ffmpeg may produce different
        // md5 hashes since resampling has been changed slightly due to a fix. Need to
        // use EXPECTREX to test for both md5 possibilities.
        printf("ffmpeg getFrame(): md5 = %s\n", md5(file_get_contents($img)));
        unlink($img);
    }
}
?>
--EXPECT--
ffmpeg getFrame(): md5 = eb9160f6590cb0f4f63303b0bdb91c85
--TEST--
ffmpeg getFrameNumber test
--SKIPIF--
<?php 
require_once '../../ffmpeg_movie.php';
require_once '../../ffmpeg_frame.php';
require_once '../../ffmpeg_animated_gif.php';
$ignore_demo_files = true;
$dir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
require_once $dir . '/examples/example-config.php';
$tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'tmp/';
?>
--FILE--
<?php 
$mov = new PHPVideoToolkit_movie($dir . '/examples/to-be-processed/cat.mpeg', false, $tmp_dir);
/* move frame point to frame 5 */
$mov->getFrame(5);
printf("ffmpeg getFrameNumber(): %d\n", $mov->getFrameNumber());
?>
--EXPECT--
ffmpeg getFrameNumber(): 5
{
    if ($gd_image) {
        $img = sprintf("tmp.png", $tmp_dir);
        imagepng($gd_image, $img);
        // generate md5 of file
        printf("%s\n", md5(file_get_contents($img)));
        unlink($img);
    } else {
        printf("failed\n");
    }
}
$framenumber = 73;
$mov = new PHPVideoToolkit_movie($dir . '/examples/to-be-processed/cat.mpeg', false, $tmp_dir);
$img = sprintf("%s/test-%04d.png", $tmp_dir, $framenumber);
/* cropping as part of resize */
$frame = $mov->getFrame($framenumber);
$frame->resize(50, 50, 10, 10, 10, 10);
$gd_image = $frame->toGDImage();
print 'ffmpeg resize and crop: md5 = ';
print_image_md5($gd_image);
imagedestroy($gd_image);
$framenumber++;
/* cropping without resize */
$frame = $mov->getFrame($framenumber);
$frame->crop(10, 10, 10, 10);
$gd_image = $frame->toGDImage();
print 'ffmpeg crop: md5 = ';
print_image_md5($gd_image);
imagedestroy($gd_image);
?>
--EXPECT--