Open sayamk3004 opened 3 years ago
public function postVideo(Request $request) { $this->validate($request, [ 'topic_img' => 'required', ]); $video_name = ""; if ($request->hasFile('topic_img')) { $destination = 'public/videos/'; $storageUrl = 'public/images/'; $video = $request->file('topic_img'); $video_name = \Carbon\Carbon::now()->timestamp . '.' . $video->extension(); $image_name = \Carbon\Carbon::now()->timestamp; $path = $request->file('topic_img')->storeAs($destination, $video_name); $thumbnail_path = storage_path('app/public/videos'); $file = $request->file('topic_img'); $thumbvideoPath = storage_path('app/public/videos/') . $video_name; $video_path = $destination . '/' . $video_name; $thumbnail_image = $image_name . ".jpg"; $thumbnail_status = VideoThumbnail::createThumbnail($thumbvideoPath, $thumbnail_path, $thumbnail_image, 10); //dd($thumbnail_status); if ($thumbnail_status) { print_r($thumbnail_status); echo "Thumbnail generated "; Auth::user()->videos()->create([ 'description' => $request->input('description'), 'title' => $video_name, 'path' => $path, ]); return response()->json([ 'description' => $request->description ], 200); } else { echo "thumbnail generation has failed"; } } }
Pawlox\VideoThumbnail\VideoThumbnail Object ( [FFMpeg:protected] => [videoObject:protected] => [videoURL:protected] => C:\xampp\htdocs\watchum\storage\app/public/videos/1617575315.mp4 [storageURL:protected] => C:\xampp\htdocs\watchum\storage\app/public/videos [thumbName:protected] => 1617575315.jpg [fullFile:protected] => C:\xampp\htdocs\watchum\storage\app/public/videos/1617575315.jpg [height:protected] => 480 [width:protected] => 640 [screenShotTime:protected] => 10 ) Thumbnail generated
Pawlox\VideoThumbnail\VideoThumbnail Object ( [FFMpeg:protected] => [videoObject:protected] => [videoURL:protected] => C:\xampp\htdocs\watchum\storage\app/public/videos/1617575315.mp4 [storageURL:protected] => C:\xampp\htdocs\watchum\storage\app/public/videos [thumbName:protected] => 1617575315.jpg [fullFile:protected] => C:\xampp\htdocs\watchum\storage\app/public/videos/1617575315.jpg [height:protected] => 480 [width:protected] => 640 [screenShotTime:protected] => 10 ) Thumbnail generated