Posted By

erraja_07 on 07/06/11


Tagged

image video ffmpeg capture - poster


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

fabienthomas
bcmoney


PHP - Capture Video/Movie Poster Image using FFMPEG (WAMP5)


 / Published in: PHP
 

URL: http://itwigle.com/twig/Capturing_video_thumbnails_with_PHP

  1. function captureVideoPosterImg($movie_file = '')
  2. {
  3. extension_loaded('ffmpeg');
  4. $movie_file = 'E:\wamp new\www\projects\indiemade_live\developer\uploads\comments\11\14\video\04072011094613_24062011234404_s Sporting Goods- Teams Come Alive.flv';
  5. // Instantiates the class ffmpeg_movie so we can get the information you want the video
  6. $movie = new ffmpeg_movie($movie_file);
  7. // Get The duration of the video in seconds
  8. echo $Duration = round($movie->getDuration(), 0);
  9. // Get the number of frames of the video
  10. $TotalFrames = $movie->getFrameCount();
  11. // Get the height in pixels Video
  12. $height = $movie->getFrameHeight();
  13. // Get the width of the video in pixels
  14. $width = $movie->getFrameWidth();
  15. //Receiving the frame from the video and saving
  16. // Need to create a GD image ffmpeg-php to work on it
  17. $image = imagecreatetruecolor($width, $height);
  18. // Create an instance of the frame with the class ffmpeg_frame
  19. $Frame = new ffmpeg_frame($image);
  20. // Choose the frame you want to save as jpeg
  21. $thumbnailOf = (int) round($movie->getFrameCount() / 2.5);
  22. // Receives the frame
  23. $frame = $movie->GetFrame($thumbnailOf);
  24. // Convert to a GD image
  25. $image = $frame->toGDImage();
  26. // Save to disk.
  27. //echo $movie_file.'.jpg';
  28. imagejpeg($image, $movie_file.'.jpg', 100);
  29.  
  30. return $movie_file.'.jpg';
  31. }
  32.  
  33.  
  34. Ref : http://itwigle.com/twig/Capturing_video_thumbnails_with_PHP

Report this snippet  

You need to login to post a comment.