How to get video duration, dimension and size in PHP?

getID3 supports video formats. See: http://getid3.sourceforge.net/ Edit: So, in code format, that’d be like: include_once(‘pathto/getid3.php’); $getID3 = new getID3; $file = $getID3->analyze($filename); echo(“Duration: “.$file[‘playtime_string’]. ” / Dimensions: “.$file[‘video’][‘resolution_x’].” wide by “.$file[‘video’][‘resolution_y’].” tall”. ” / Filesize: “.$file[‘filesize’].” bytes<br />”); Note: You must include the getID3 classes before this will work! See the above link. Edit: If … Read more

ffmpeg for a android (using tutorial: “ffmpeg and Android.mk”)

After looking around the net. The only working solution I found is supplied by Bambuser which ported ffmpeg to use in their android application. Code is here: http://bambuser.com/opensource Basically you copy the .so files to your jni/lib directory, along with any .h files you might need, create a JNI wrapper through javah, and it works. … Read more

Fetch frame count with ffmpeg

ffprobe ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 input.mp4 This actually counts packets instead of frames but it is much faster. Result should be the same. If you want to verify by counting frames change -count_packets to -count_frames and nb_read_packets to nb_read_frames. What the ffprobe options mean -v error This hides “info” … Read more

OpenCV with Network Cameras

I enclosed C++ code for grabbing frames. It requires OpenCV version 2.0 or higher. The code uses cv::mat structure which is preferred to old IplImage structure. #include “cv.h” #include “highgui.h” #include <iostream> int main(int, char**) { cv::VideoCapture vcap; cv::Mat image; const std::string videoStreamAddress = “rtsp://cam_address:554/live.sdp”; /* it may be an address of an mjpeg stream, … Read more

ffmpeg in a bash pipe

Caveat: I’ve never used ffmpeg, but in working with other questions concerning the program, it appears that, like ssh, ffmpeg reads from standard input without actually using it, so the first call to Convert is consuming the rest of the file list after read gets the first line. Try this Convert() { ffmpeg -i “$1” … Read more

FFMPEG (libx264) “height not divisible by 2”

The answer to the original question should not scale the video but instead fix the height not divisible by 2 error. This can be achieve using this filter: -vf “pad=ceil(iw/2)*2:ceil(ih/2)*2” Full command: ffmpeg -i frame_%05d.jpg -vcodec libx264 \ -vf “pad=ceil(iw/2)*2:ceil(ih/2)*2” -r 24 \ -y -an video.mp4 Basically, .h264 needs even dimensions so this filter will: … Read more

How to add transparent watermark in center of a video with ffmpeg?

Examples to add a watermark / logo image on video using the overlay filter. Centered ffmpeg -i input.mp4 -i logo.png -filter_complex “overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2” -codec:a copy output.mp4 or with the shortened overlay options: overlay=(W-w)/2:(H-h)/2 Top left This is the easy one because the default, if you provide no options to overlay, is to place the image in … Read more