function download($file_source, $file_target, $sn) { // Preparations $file_source = str_replace(' ', '%20', html_entity_decode($file_source)); // fix url format if (file_exists($file_target)) { chmod($file_target, 0777); } // add write permission $remote_size = remotefsize($file_source); // Begin transfer if (($rh = fopen($file_source, 'rb')) === FALSE) { return false; } // fopen() handles if (($wh = fopen($file_target, 'wb')) === FALSE) { return false; } // error messages. $i = 0; while (!feof($rh)) { // report progress every 2000 if ($i == 2000) { $i = 0; $lfs = filesize($file_target); print hr_bytes($lfs) . ' of ' . hr_bytes($remote_size) . " of {$sn} \n"; clearstatcache(); } $i++; // unable to write to file, possibly because the harddrive has filled up if (fwrite($wh, fread($rh, 8192)) === FALSE) { fclose($rh); fclose($wh); return false; } } // Finished without errors fclose($rh); fclose($wh); return true; }
print "looking at: {$local_fl} \n"; clearstatcache(); if (!is_file($local_fl)) { $doneWithTrascode = false; print "flv NOT found run trascode for: {$source_file}\n"; //replace input: $current_encodeCMD = str_replace('$input', $mvMountedSource . $source_file, $flvEncodeCommand); //replace output $current_encodeCMD = str_replace('$output', $local_fl, $current_encodeCMD); print "\nrun:{$current_encodeCMD} \n\n"; $pid = simple_run_background($current_encodeCMD); sleep(1); //give time for the proccess to start up while (is_process_running($pid)) { clearstatcache(); print "running trascode: " . hr_bytes(filesize($local_fl)) . "\n"; sleep(10); } //now it should be there if (is_file($local_fl)) { //flv is found print "flv found: " . $mvMountedDest . $stream_name . ".flv \n"; //check for .meta if (!is_file($local_fl . META_DATA_EXT)) { echo "gennerating flv metadata for {$local_fl} \n"; $flv = new MyFLV(); try { $flv->open($local_fl); } catch (Exception $e) { die("<pre>The following exception was detected while trying to open a FLV file:\n" . $e->getMessage() . "</pre>"); }