public static function getProgress($job, $format = null)
    {
        // Get the temporary directory
        $tmpdir = self::getTempPath();

        // The code below has been adapted from Jimbo
        // http://stackoverflow.com/questions/11441517/ffmpeg-progress-bar-encoding-percentage-in-php
        $content = @file_get_contents($tmpdir.$job.'.sonustmp');

        if($content)
        {
            // Get duration of source
            preg_match("/Duration: (.*?), start:/", $content, $matches);

            $rawDuration = $matches[1];

            // rawDuration is in 00:00:00.00 format. This converts it to seconds.
            $ar = array_reverse(explode(":", $rawDuration));
            $duration = floatval($ar[0]);
            if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
            if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;

            // Get the time in the file that is already encoded
            preg_match_all("/time=(.*?) bitrate/", $content, $matches);

            $rawTime = array_pop($matches);

            // This is needed if there is more than one match
            if (is_array($rawTime))
            {
                $rawTime = array_pop($rawTime);
            }

            // rawTime is in 00:00:00.00 format. This converts it to seconds.
            $ar = array_reverse(explode(":", $rawTime));
            $time = floatval($ar[0]);
            if (!empty($ar[1])) $time += intval($ar[1]) * 60;
            if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;

            // Calculate the progress
            $progress = round(($time/$duration) * 100);

            // Output to array
            $output = array(
                'Duration' => $rawDuration,
                'Current'  => $rawTime,
                'Progress' => $progress
                );

            // Return data
            switch ($format) 
            {
                case 'array':
                    return $output;
                    break;
                
                default:
                    return json_encode($output);
                    break;
            }
        } else {
            return null;
        }
    }