sheenam12

Untitled

May 11th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. public function AddVideos(){
  2.  
  3. $input = Input::all();
  4.  
  5. $video= 'novideo.mp4';
  6.  
  7. $file = Input::file('video');
  8.  
  9. $x = filesize($file);
  10.  
  11. //upto 500 mb
  12. if($x<=524288000){
  13.  
  14. //upto 2 mb
  15. // if($x<=2097152){
  16.  
  17. if(isset($file)){
  18. if(Input::file('video')->isValid())
  19. {
  20. //store file input in a varaible
  21. $file = Input::file('video');
  22. $d = 'uploads/images/';
  23. $thumb = rand(1,9999).'.png';
  24. $a = exec("ffmpeg -ss 00:00:05 -i ".$file." -vf 'select=not(mod(n\,1000)),scale=320:240' ".$d.$thumb."");
  25. //get extension of file
  26. $extension =$file->getClientOriginalExtension();
  27. //define directory to store images
  28. $directory = 'uploads/videos/';
  29. //change filename to a random sha1 plus current time
  30. $filename = "user_" . substr(sha1(time().time()), 0, 15) .rand(0,1000). ".{$extension}";
  31.  
  32. // $upload_success = Input::file('video')->move($directory, $filename);
  33.  
  34. $s3 = AWS::get('s3');
  35.  
  36. $upload_success = $s3->putObject([
  37. 'ACL' => 'public-read',
  38. 'Bucket' => 'estreamz',
  39. 'Key' => $directory.$filename,
  40. 'Body' => fopen($file->getPathname(), 'r'),
  41. 'ContentType' => 'video/mp4',
  42. ]);
  43.  
  44. $video = $upload_success ? $filename : $video;
  45. }
  46. }
  47.  
  48.  
  49. $v_time = date('H:i:s', strtotime($input['video_time']));
  50.  
  51. DB::table('videos')->insertGetId(array(
  52. 'episode_id' => $input['episode_id'],
  53. 'title' => $input['title'] ,
  54. 'video_thumb' => $thumb ,
  55. 'video' => $video ,
  56. 'description' => $input['description'] ,
  57. 'length' => $input['length'] ,
  58. 'video_date' => $input['video_date'] ,
  59. 'video_time' => $v_time ,
  60. 'created_at' => new DateTime,
  61. 'updated_at' => new DateTime
  62. ));
  63.  
  64.  
  65. return Redirect::route('admin.videos');
  66.  
  67. }
  68.  
  69.  
  70. else{
  71.  
  72. $eps = DB::table('episodes')->where('deleted_at','=',NULL)->orderby('created_at', 'DESC')->get();
  73.  
  74. return View::make('admin.videos.enterVideo')->withErrors(['Video size should be less then 500 mb'])->with('input_values', $eps);
  75.  
  76. }
  77.  
  78.  
  79. }
Add Comment
Please, Sign In to add comment