SHARE
TWEET

ffmpeg-php example code

amereservant Feb 8th, 2012 13,188 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * FFMPEG-PHP Test Script
  4.  *
  5.  * Special thanks to http://www.sajithmr.me/ffmpeg-sample-code for this code example!
  6.  * See the tutorial at http://myownhomeserver.com on how to install ffmpeg-php.
  7.  */
  8. // Check if the ffmpeg-php extension is loaded first
  9. extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
  10.  
  11. // Determine the full path for our video
  12. $vid = realpath('./vid2.avi');
  13.  
  14. // Create the ffmpeg instance and then display the information about the video clip.
  15. $ffmpegInstance = new ffmpeg_movie($vid);
  16. echo "getDuration: " . $ffmpegInstance->getDuration() . "<br />".
  17. "getFrameCount: " . $ffmpegInstance->getFrameCount() . "<br />".
  18. "getFrameRate: " . $ffmpegInstance->getFrameRate() . "<br />".
  19. "getFilename: " . $ffmpegInstance->getFilename() . "<br />".
  20. "getComment: " . $ffmpegInstance->getComment() . "<br />".
  21. "getTitle: " . $ffmpegInstance->getTitle() . "<br />".
  22. "getAuthor: " . $ffmpegInstance->getAuthor() . "<br />".
  23. "getCopyright: " . $ffmpegInstance->getCopyright() . "<br />".
  24. "getArtist: " . $ffmpegInstance->getArtist() . "<br />".
  25. "getGenre: " . $ffmpegInstance->getGenre() . "<br />".
  26. "getTrackNumber: " . $ffmpegInstance->getTrackNumber() . "<br />".
  27. "getYear: " . $ffmpegInstance->getYear() . "<br />".
  28. "getFrameHeight: " . $ffmpegInstance->getFrameHeight() . "<br />".
  29. "getFrameWidth: " . $ffmpegInstance->getFrameWidth() . "<br />".
  30. "getPixelFormat: " . $ffmpegInstance->getPixelFormat() . "<br />".
  31. "getBitRate: " . $ffmpegInstance->getBitRate() . "<br />".
  32. "getVideoBitRate: " . $ffmpegInstance->getVideoBitRate() . "<br />".
  33. "getAudioBitRate: " . $ffmpegInstance->getAudioBitRate() . "<br />".
  34. "getAudioSampleRate: " . $ffmpegInstance->getAudioSampleRate() . "<br />".
  35. "getVideoCodec: " . $ffmpegInstance->getVideoCodec() . "<br />".
  36. "getAudioCodec: " . $ffmpegInstance->getAudioCodec() . "<br />".
  37. "getAudioChannels: " . $ffmpegInstance->getAudioChannels() . "<br />".
  38. "hasAudio: " . $ffmpegInstance->hasAudio();
RAW Paste Data
Want to get better at PHP?
Learn to code PHP in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top