Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function AddVideos(){
- $input = Input::all();
- $video= 'novideo.mp4';
- $file = Input::file('video');
- $x = filesize($file);
- //upto 500 mb
- if($x<=524288000){
- //upto 2 mb
- // if($x<=2097152){
- if(isset($file)){
- if(Input::file('video')->isValid())
- {
- //store file input in a varaible
- $file = Input::file('video');
- $d = 'uploads/images/';
- $thumb = rand(1,9999).'.png';
- $a = exec("ffmpeg -ss 00:00:05 -i ".$file." -vf 'select=not(mod(n\,1000)),scale=320:240' ".$d.$thumb."");
- //get extension of file
- $extension =$file->getClientOriginalExtension();
- //define directory to store images
- $directory = 'uploads/videos/';
- //change filename to a random sha1 plus current time
- $filename = "user_" . substr(sha1(time().time()), 0, 15) .rand(0,1000). ".{$extension}";
- // $upload_success = Input::file('video')->move($directory, $filename);
- $s3 = AWS::get('s3');
- $upload_success = $s3->putObject([
- 'ACL' => 'public-read',
- 'Bucket' => 'estreamz',
- 'Key' => $directory.$filename,
- 'Body' => fopen($file->getPathname(), 'r'),
- 'ContentType' => 'video/mp4',
- ]);
- $video = $upload_success ? $filename : $video;
- }
- }
- $v_time = date('H:i:s', strtotime($input['video_time']));
- DB::table('videos')->insertGetId(array(
- 'episode_id' => $input['episode_id'],
- 'title' => $input['title'] ,
- 'video_thumb' => $thumb ,
- 'video' => $video ,
- 'description' => $input['description'] ,
- 'length' => $input['length'] ,
- 'video_date' => $input['video_date'] ,
- 'video_time' => $v_time ,
- 'created_at' => new DateTime,
- 'updated_at' => new DateTime
- ));
- return Redirect::route('admin.videos');
- }
- else{
- $eps = DB::table('episodes')->where('deleted_at','=',NULL)->orderby('created_at', 'DESC')->get();
- return View::make('admin.videos.enterVideo')->withErrors(['Video size should be less then 500 mb'])->with('input_values', $eps);
- }
- }
Add Comment
Please, Sign In to add comment