Php 在laravel 5.5中创建视频缩略图
我在拉维尔的一个项目中工作 我想在上传视频时创建缩略图 我正在关注这篇文章 pawlox/视频缩略图 当我称之为Php 在laravel 5.5中创建视频缩略图,php,laravel,laravel-5,Php,Laravel,Laravel 5,我在拉维尔的一个项目中工作 我想在上传视频时创建缩略图 我正在关注这篇文章 pawlox/视频缩略图 当我称之为 $thumb = VideoThumbnail::createThumbnail(asset('public/stories/videos/21530251287.mp4'), asset("public/images/"), 'thumb.jpg', 2, 600, 600); 它的回归 Pawlox\VideoThumbnail\VideoThumbna
$thumb = VideoThumbnail::createThumbnail(asset('public/stories/videos/21530251287.mp4'), asset("public/images/"), 'thumb.jpg', 2, 600, 600);
它的回归
Pawlox\VideoThumbnail\VideoThumbnail Object(
[FFMpeg:protected] =>
[videoObject:protected] =>
[videoURL:protected] => http://localhost/sunbay/yms/public/stories/2/videos/21530251287.mp4
[storageURL:protected] => http://localhost/sunbay/yms/public/images
[thumbName:protected] => thumb.jpg
[fullFile:protected] => http://localhost/sunbay/yms/public/images/thumb.jpg
[height:protected] => 600
[width:protected] => 600
[screenShotTime:protected] => 2 )
但拇指没有生成
请让我知道我做错了什么。以及如何解决这个问题
提前感谢。
资产
生成URL,您需要文件路径,请尝试:
$thumb = VideoThumbnail::createThumbnail(public_path('stories/videos/21530251287.mp4'), public_path("images/"), 'thumb.jpg', 2, 600, 600);
我认为问题在于缩略图没有保存。它实际上是创建的,但不是存储的。如果您选中
/var/www/html/theevent/vendor/pawlox/video thumbnail/src/VideoThumbnail.php
,您将看到此方法
public function createThumbnail($videoUrl, $storageUrl, $fileName, $second, $width = 640, $height = 480) {
$this->videoURL = $videoUrl;
$this->storageURL = $storageUrl;
$this->thumbName = $fileName;
$this->fullFile = "{$this->storageURL}/{$this->thumbName}";
$this->screenShotTime = $second;
$this->width = $width;
$this->height = $height;
try {
$this->create();
$this->thumbnail();
$this->resizeCropImage($this->width, $this->height, $this->fullFile, $this->fullFile);
} catch (Exception $e) {
Log::error($e->getMessage());
}
return $this;
}
so u need to fix the file path by creating d folder for the file to be saved
here my working code
$thumbnail_path=storage_path().'/app/public/thumbs';
$file = $request->file('video');
$thumbvideoPath = storage_path('/app/public/videos/').$videoName;
$video_path = $destination_path.'/'.$file_name;
$thumbnail_image = $videoName.".jpg";
$thumbnail_status = VideoThumbnail::createThumbnail($thumbvideoPath,$thumbnail_path,$thumbnail_image, 10);
//dd($thumbnail_status);
if($thumbnail_status)
{
echo "Thumbnail generated ";
}
else
{
echo "thumbnail generation has failed";
}
重新启动xampp服务器 您正在添加:
FFMPEG="/usr/bin/ffmpeg"
FFPROBE="/usr/bin/ffprobe"
在
.env
文件中进行更改后,您需要重新启动服务器。您需要安装FFMpeg对于ubuntu 16.04:
sudo apt-get update
sudo apt-get install ffmpeg
sudo service apache2 restart
我还使用这个软件包不断地生成缩略图和面部错误,然后我使用这个软件包来消除这些错误
https://packagist.org/packages/lakshmajim/thumbnail
或
https://github.com/lakshmaji/Thumbnail