Image Video Thumbnail creating using PHP-FFmpeg

I am using PHP-FFmpeg for viode thumbnail genaration. My code is below

<?php

$video = "a.mp4";
$image = "thumb.jpg";
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42));
$frame->save($image);
?>

I am trying above code to generate video thumbnail it is showing

Fatal error: Call to a member function frame() on string in C:\xampp\htdocs\video-uploader\ImageGenerator.php on line 5

1 answer

  • answered 2019-04-15 09:41 slhck

    $video is a string, so you cannot access the method frame().

    You want:

    $ffmpeg = FFMpeg\FFMpeg::create();
    $video = $ffmpeg->open("a.mp4");
    

    See the basic usage example.