#!/usr/bin/php $n) { if (!isset($tot2[strtoupper($c)])) $tot2[strtoupper($c)] = 0; $tot2[strtoupper($c)] += $n; if ($case_sensitive) { echo "Total $c (case sensitive): $n\n"; } else { echo "Total $c (case insensitive): $n\n"; } } $cont = ob_get_contents(); ob_end_clean(); file_put_contents($outfile, $cont); } function stat_audio_wav($moviedir, $outfile) { ob_start(); $x = $moviedir.'/*.WAV'; $ary = glob($x); $x = $moviedir.'/*.wav'; $ary = array_merge($ary, glob($x)); $x = $moviedir.'/*.Wav'; $ary = array_merge($ary, glob($x)); sort($ary); $tot = array(); foreach ($ary as $a) { $m = file_get_contents($a); $codec = substr($m, 0x14, 2); $codec = '0x'.zeropad(dechex(ord($codec[1])),2).zeropad(dechex(ord($codec[0])),2); if ($codec == '0x0001') $codec = "Microsoft PCM ($codec)"; if ($codec == '0x0011') $codec = "Intel DVI ADPCM ($codec)"; $a = basename($a); echo "$a: $codec\n"; if (!isset($tot[$codec])) $tot[$codec] = 0; $tot[$codec]++; } echo "---\n"; $tot2 = array(); foreach ($tot as $c => $n) { if (!isset($tot2[strtoupper($c)])) $tot2[strtoupper($c)] = 0; $tot2[strtoupper($c)] += $n; echo "Total $c: $n\n"; } $cont = ob_get_contents(); ob_end_clean(); file_put_contents($outfile, $cont); } function stat_audio_avi($moviedir, $outfile) { ob_start(); $x = $moviedir.'/*.AVI'; $ary = glob($x); $x = $moviedir.'/*.avi'; $ary = array_merge($ary, glob($x)); $x = $moviedir.'/*.Avi'; $ary = array_merge($ary, glob($x)); sort($ary); $tot = array(); foreach ($ary as $a) { $m = file_get_contents($a); $x = substr($m, 0xE8, 4); if ($x != 'auds') { $codec = 'no audio'; } else { $codec = substr($m, 0x128, 2); $codec = '0x'.zeropad(dechex(ord($codec[1])),2).zeropad(dechex(ord($codec[0])),2); if ($codec == '0x0001') $codec = "Microsoft PCM ($codec)"; if ($codec == '0x0011') $codec = "Intel DVI ADPCM ($codec)"; } $a = basename($a); echo "$a: $codec\n"; if (!isset($tot[$codec])) $tot[$codec] = 0; $tot[$codec]++; } echo "---\n"; $tot2 = array(); foreach ($tot as $c => $n) { if (!isset($tot2[strtoupper($c)])) $tot2[strtoupper($c)] = 0; $tot2[strtoupper($c)] += $n; echo "Total $c: $n\n"; } $cont = ob_get_contents(); ob_end_clean(); file_put_contents($outfile, $cont); } stat_audio_avi(__DIR__.'/../single_files/*/movies/movies_a', 'avi_audio_stats.txt'); stat_audio_wav(__DIR__.'/../single_files/*/sounds', 'wav_audio_stats.txt'); stat_avi(__DIR__.'/../single_files/*/movies/movies_a', 'avi_video_stats_caseinsensitive.txt', false); stat_avi(__DIR__.'/../single_files/*/movies/movies_a', 'avi_video_stats_casesensitive.txt', true); file_put_contents('smacker.txt', "Num smacker: " . count(glob(__DIR__.'/../single_files/*/movies/movies_s/*.smk')));