Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _get_video_attributes($video, $ffmpeg) {
- $command = $ffmpeg . ' -i ' . $video . ' -vstats 2>&1';
- $output = shell_exec($command);
- $regex_sizes = "/Video: ([^,]*), ([^,]*), ([0-9]{1,4})x([0-9]{1,4}), ([^,]*), ([0-9]{1,4})/"; // or : $regex_sizes = "/Video: ([^rn]*), ([^,]*), ([0-9]{1,4})x([0-9]{1,4})/"; (code from @1owk3y)
- if (preg_match($regex_sizes, $output, $regs)) {
- $codec = $regs [1] ? $regs [1] : null;
- $width = $regs [3] ? $regs [3] : null;
- $height = $regs [4] ? $regs [4] : null;
- $fps = $regs [6] ? $regs [6] : null;
- }
- $regex_duration = "/Duration: ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}).([0-9]{1,2})/";
- if (preg_match($regex_duration, $output, $regs)) {
- $hours = $regs [1] ? $regs [1] : null;
- $mins = $regs [2] ? $regs [2] : null;
- $secs = $regs [3] ? $regs [3] : null;
- $ms = $regs [4] ? $regs [4] : null;
- }
- return array('codec' => $codec,
- 'width' => $width,
- 'height' => $height,
- 'hours' => $hours,
- 'mins' => $mins,
- 'secs' => $secs,
- 'ms' => $ms,
- 'fps' => $fps,
- );
- }
- if($duration < 10){
- $interval = floor($duration / 2);
- $image = "thumb/".$filenopath."_thumb_".$num.".jpg";
- shell_exec($ffmpeg." -ss ".$interval." -i ".$upfile." -vf select='eq(pict_type,I)' -vframes 1 -vf scale=-1:240 ".$thumb."00".$i.".jpg");
- rename($image,"thumb/".$image);
- }else{
- for ($i = 1; $i <= 6; $i++) {
- $interval = floor(($i - 0.5) * $duration / $i);
- $log = $ffmpeg." -ss ".$interval." -i ".$upfile." -vf select='eq(pict_type,I)' -vframes 1 -vf scale=-1:240 ".$thumb."00".$i.".jpg".PHP_EOL;
- //file_put_contents('./log'.date("j.n.Y").'.txt', $log, FILE_APPEND);
- shell_exec($ffmpeg." -ss ".$interval." -i ".$upfile." -vf select='eq(pict_type,I)' -vframes 1 -vf scale=-1:240 ".$thumb."00".$i.".jpg");
- }
Add Comment
Please, Sign In to add comment