xrcwrn
xrcwrn

Reputation: 5327

Image Video Thumbnail creating using PHP-FFmpeg

I am using PHP-FFmpeg for video 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

Upvotes: 1

Views: 2621

Answers (2)

ChAnDu353
ChAnDu353

Reputation: 651

If it is to display on browser, You can use HTML5 Video, this will generate a thumbnail from video at 4 seconds.

  <video  width="400" height="300" controls id="videopreview" preload="metadata"  >
    <source src="uploads/video_name.mp4#t=4" type="video/mp4">
</video>

Upvotes: 0

slhck
slhck

Reputation: 38652

$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.

Upvotes: 3

Related Questions