function curldownload($remote_file, $local_file)
{
    $pid = simple_run_background("curl -L -C - -o {$local_file} {$remote_file}");
    print "started download with pid: {$pid} \n";
    $remote_size = remotefsize($remote_file);
    $prev_byte = 0;
    while (is_process_running($pid)) {
        $speed = hr_bytes((filesize($local_file) - $prev_byte) / 10);
        echo "downloaded (" . hr_bytes(filesize($local_file)) . ' of ' . hr_bytes($remote_size) . ") " . $speed . "/s \n";
        $prev_byte = filesize($local_file);
        clearstatcache();
        sleep(10);
    }
    return true;
}
 if ($genNewFlv) {
     $local_fl = $mvMountedDest . $stream_name . '.new.flv';
 } else {
     $local_fl = $mvMountedDest . $stream_name . '.flv';
 }
 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();