Hello!
How i can get this info in array from video file?
Hi @boomuo,
Here is the way to get this information:
$ffprobe = FFMpeg\FFProbe::create();
$video_dimensions = $ffprobe
->streams( $full_video_path ) // extracts streams informations
->videos() // filters video streams
->first() // returns the first video stream
->getDimensions(); // returns a FFMpeg\Coordinate\Dimension object
$width = $video_dimensions->getWidth();
$height = $video_dimensions->getHeight();
$duration = $ffprobe->format( $full_video_path )->get('duration');
// This is in the main doc...
$ffprobe
->streams($full_video_path) // extracts streams informations
->videos() // filters video streams
->first() // returns the first video stream
->get('codec_name'); // returns the codec_name property
Thanks to let me know if this solves your question.
Thank you, but very low speed, 1sec+. Maybe this all lib low speed?
This code high speed (0.2sec):
$cmd = $this->ffmpegPath." -i $filePath -hide_banner 2>&1";
$ffmpeg = shell_exec($cmd);
$search = "/Duration: (.*?)\./";
preg_match($search, $ffmpeg, $matches);
$data['duration'] = $matches[1];
$time_sec = explode(':', $data['duration']);
$data['durationSecond'] = ($time_sec['0']*3600)+($time_sec['1']*60)+$time_sec['2'];
$search = "|Video:.* (\d{3,4}+x\d{3,4})|";
preg_match($search, $ffmpeg, $matches);
$data['video'] = $matches[1];
return $data;
How i can create screenshots to video? Simple: rows-3, colls - 4, width every little screen - 200px. Will that posible on this lib?
If you think that there are differences between the library and the command line, the best way to test it is to mesure the time your script takes to run, to take the exact command line executed by the script from the logs, and to execute it measuring as well the duration.
If you still think this is an issue, please open a new ticket.
With regards to the screenshots, everything is explained in the doc here:
https://github.com/PHP-FFMpeg/PHP-FFMpeg#extracting-image
including the resize options:
https://github.com/PHP-FFMpeg/PHP-FFMpeg#extracting-image
Please read the doc first.
Thanks
Most helpful comment
Hi @boomuo,
Here is the way to get this information:
Thanks to let me know if this solves your question.