2017-05-17 17 views
4

多くの時間を検索しましたが、解決策が見つかりませんでした。この場合はコードを投稿できません。これは申し訳ありません。2つの動画が同じであることを確認する

私はメディアフォルダと多くのビデオがこのフォルダにアップロードされているのと同じように、2つ以上のビデオが同じであることを確認することができます。次に、新しいビデオをアップロードしたら、そのビデオが既に終了しているかどうかを確認する必要があります。

1. if i have video demo.mp4 then when i will try to upload same video then give error 
2. if i change video name like demo.mp4 to demo1.mp4 then i will give same error cause video name different but video content same 
3. if i upload video demo5.mp4 then show me no error 

私はすでに画像が

include('compareImages.php'); 
    $new_image_name = $uploadfile_temp; 
    $compareMachine = new compareImages($new_image_name); 
    $image1Hash = $compareMachine->getHasString(); 
    $files = glob("uploads/*.*"); 
     $check_image_duplicate = 0; 
     for ($i = 0; $i < count($files); $i++) { 
      $filename = $files[$i]; 
      $image2Hash = $compareMachine->hasStringImage($filename); 
      $diff = $compareMachine->compareHash($image2Hash); 
      if($diff < 10){ 
       $check_image_duplicate = 1; 
       //unlink($new_image_name); 
       break; 
       } 

     } 

を使用して比較確認しかし、私はビデオを比較することはできません。誰か助けてください

+0

'システム( "md5sumは");' 2 http://stackoverflow.com/questions/3277724/get-md5-checksum-for-very-large-files – pokeybit

+1

を比較したりしてみてくださいます。http: //php.net/manual/en/function.md5-file.php#94494 – pokeybit

+0

ありがとうございます。あなたのリンク –

答えて

3

テスト済みで、コードはhttp://php.net/manual/en/function.md5-file.php#94494ではありません。

<?php 
define('READ_LEN', 4096); 

if(files_identical('demo.mp4', 'demo1.mp4')) 
    echo 'files identical'; 
else 
    echo 'files not identical'; 

// pass two file names 
// returns TRUE if files are the same, FALSE otherwise 
function files_identical($fn1, $fn2) { 
    if(filetype($fn1) !== filetype($fn2)) 
     return FALSE; 

    if(filesize($fn1) !== filesize($fn2)) 
     return FALSE; 

    if(!$fp1 = fopen($fn1, 'rb')) 
     return FALSE; 

    if(!$fp2 = fopen($fn2, 'rb')) { 
     fclose($fp1); 
     return FALSE; 
    } 

    $same = TRUE; 
    while (!feof($fp1) and !feof($fp2)) 
     if(fread($fp1, READ_LEN) !== fread($fp2, READ_LEN)) { 
      $same = FALSE; 
      break; 
     } 

    if(feof($fp1) !== feof($fp2)) 
     $same = FALSE; 

    fclose($fp1); 
    fclose($fp2); 

    return $same; 
} 
?> 
+0

完璧で、私もあなたのリンクとしてそれを見つける。どうもありがとうございました –

関連する問題