PHPでアップロードする前にビデオファイルの長さを検出しようとしている
ので、たとえば1分未満の場合は、アップロードを拒否します。
それが不可能な場合、ビデオをアップロードした後にどうすればよいですか?
質問する
23455 次
2 に答える
14
あなたは またはgetID3video duration
で取得できますffmpeg
例
$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 />");
または
ob_start();
passthru("ffmpeg -i working_copy.flv 2>&1");
$duration = ob_get_contents();
$full = ob_get_contents();
ob_end_clean();
$search = "/duration.*?([0-9]{1,})/";
print_r($duration);
$duration = preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);
print_r('<pre>');
print_r($matches[1][0]);
print_r($full);
参照してください
http://getid3.sourceforge.net/
PHPでビデオの長さ、サイズ、サイズを取得するにはどうすればよいですか?
ありがとう
:D
于 2012-04-06T12:26:55.587 に答える
0
これをチェックするために来る人々にとって、これは2017年にもう少し進んだソリューションです
first download the latest version from the first link above in the accepted answer the (green checkmark)
require_once('getid/getid3/getid3.php'); //path to your get id file if you do not include this in your file it will result in an error meaning the code will not work
$file = "sade.mp4"; //what you want extract info from maybe mp3,or mp4 file anything you want to get file size in bytes or time duration
$uuuuu = "videos/"; //path to your video file it could also be music not only video
$getID3 = new getID3; //initialize engine
$ThisFileInfo = $getID3->analyze($uuuuu.$file);
getid3_lib::CopyTagsToComments($ThisFileInfo);
echo '<pre>'.htmlentities(print_r($ThisFileInfo, true)).'</pre>'; //use this to print array to pick whatever you like that you want value like playduration, filesize
于 2017-03-19T15:36:12.323 に答える