手机上的缓存,.m3u8.sqlite文件转换为视频文件

<?php
//设置源和目标文件路径
$path_soc = 'C:\Users\qinyu\Desktop\SQLite样本\';
$path_des = 'C:\Users\qinyu\Desktop\SQLite样本\';

$filesArr = getDirContent($path_soc);
$key = "";
$ts_encode_con = "";
$filesnum = sizeof($filesArr);
for($i = 0; $i < $filesnum; $i++ ){
    $allnum = $i + 1;
    echo '提取解密进度:' . $allnum . '/' . $filesnum . "\r\n";
    $db = new SQLite3($path_soc . $filesArr[$i]);
    $results = $db->query('select VALUE FROM caches where key like \'%get_dk%\'');
    while ($row = $results->fetchArray()) {
        $key = $row[0];
    }
    $results = $db->query('select key FROM caches where key like \'%start%\'');
    while ($row = $results->fetchArray()) {
        $a = strstr($row[0], "&end", true);
        $a = strstr($a, "start=");
        $idArr[] = str_replace("start=", "", $a );
    }
    sort($idArr);
    for($j=0; $j < sizeof($idArr); $j++) {
        $text = "select VALUE FROM caches where key like '%start={$idArr[$j]}&end=%'";
        //echo $text . "\r\n";
        $results = $db->query($text);
        while ($row = $results->fetchArray()) {
            $ts_encode_con .= $row[0];
        }
    }
    $db->close();
    $result = $path_des . $filesArr[$i] . '.ts';
    $result = str_replace(".m3u8.sqlite", "", $result);
    decode($ts_encode_con, $key, $result);
    unset($idArr);
    unset($ts_encode_con);
}
function getDirContent($path){
    if(!is_dir($path)) return false;
    $arr = array();
    $data = scandir($path);
    foreach ($data as $value) if($value != '.' && $value != '..'){
        $arr[] = $value;
    }
    return $arr;
}
function decode($con, $key, $result){
    $f = fopen($result, 'wb');
    fwrite($f, decrypt($con, $key));
    fclose($f);
}
function decrypt($string, $key)
{
    $decrypted = openssl_decrypt($string, 'AES128', $key, OPENSSL_RAW_DATA);
    return $decrypted;
}
?>

上面的代码,修改前两行的源文件夹和目标文件夹路径就可以用了,使用效果:

视频太大的时候,把1024的内存调大就可以了,比如10240

转:https://www.qinyuanyang.com/post/250.html