#!/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)"; $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)"; } $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/ba_english/MOVIES', 'avi_audio_stats_en.txt'); stat_audio_avi(__DIR__.'/../single_files/ba_german/MOVIES', 'avi_audio_stats_ger.txt'); stat_audio_avi(__DIR__.'/../single_files/ba_special_edition/MOVIES', 'avi_audio_stats_se.txt'); stat_audio_wav(__DIR__.'/../single_files/ba_english/AUDIO', 'wav_audio_stats_en.txt'); stat_audio_wav(__DIR__.'/../single_files/ba_german/AUDIO', 'wav_audio_stats_ger.txt'); stat_audio_wav(__DIR__.'/../single_files/ba_special_edition/AUDIO', 'wav_audio_stats_se.txt'); stat_avi(__DIR__.'/../single_files/ba_english/MOVIES', 'avi_video_stats_en_caseinsensitive.txt', false); stat_avi(__DIR__.'/../single_files/ba_german/MOVIES', 'avi_video_stats_ger_caseinsensitive.txt', false); stat_avi(__DIR__.'/../single_files/ba_special_edition/MOVIES', 'avi_video_stats_se_caseinsensitive.txt', false); stat_avi(__DIR__.'/../single_files/ba_english/MOVIES', 'avi_video_stats_en_casesensitive.txt', true); stat_avi(__DIR__.'/../single_files/ba_german/MOVIES', 'avi_video_stats_ger_casesensitive.txt', true); stat_avi(__DIR__.'/../single_files/ba_special_edition/MOVIES', 'avi_video_stats_se_casesensitive.txt', true);