0

so i am working on a project where a video uploading feature should be there,

this is how i uploading a video

//view for video

video uploader

<form action="{{route('videoUploader')}}" role="form" id="postForm" name="postForm" method="POST" 
 enctype="multipart/form-data">
    @csrf
    <input type="file" name="files[]" multiple ><br/>
    <input type="submit"  value="upload">
</form>

and on controller side the code is //controller for video

public function videoUpload(Request $request){
        $files=$request->file('files');
        $videoArray=[];
        if($files){
            foreach($files as $video){
                $filename= $video->getClientOriginalName();
                $extension = $video->getClientOriginalExtension();
                $fileNameToStore = $filename. '_'.time().'.'.$extension;
                $path = $video->move('storage/videos',$fileNameToStore);
                $videoArray[]=$fileNameToStore;
            }
            }
        return view('admin.Post.video',compact('videoArray'));
    }

and this is how i am getting and see output on blade

@if (!empty($videoArray))
@foreach ($videoArray as $video)
<iframe src="{{ asset('storage/videos/'.$video) }}"frameborder="0" width="250" height="200"  
allowfullscreen></iframe>
@endforeach
@endif

but the issue is, i want these videos to trim first, if video is more than 1 minute longer, it should be trimmed, and get trimmed video to show on the blade, and i don't have any idea how can i achieve this. i could not find any helpful tutorial on web for this, so i came here. please help me and thanks in advance

2 Answers2

0

First you have to upload the video and then you can get time and trim the video as per your need.

Use FFMpeg Pbmedia Laravel package for this. Open below link and add package into your laravel project

https://packagist.org/packages/pbmedia/laravel-ffmpeg

  • i added and how can i use this, i asked recently please help there – user14698698 Nov 30 '20 at 13:32
  • Steps: 1. Install FFMPEG on your server. 2. Install FFMPEG laravel package from https://packagist.org/packages/pbmedia/laravel-ffmpeg Above link includes all your problem solution. – Rajender Kumar Dec 03 '20 at 05:42
  • thank you sir for reply again, i already did it but still facing some problem, explained in this post https://stackoverflow.com/questions/65087821/how-to-use-or-import-ffmpeg-in-a-laravel-controller – user14698698 Dec 04 '20 at 06:40
0

with FFmpeg

 ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4
dılo sürücü
  • 3,821
  • 1
  • 26
  • 28