Skip to content

Instantly share code, notes, and snippets.

/ffmpegmonitor Secret

Created May 29, 2014 19:03
Show Gist options
  • Select an option

  • Save anonymous/d4743d73b9ad4a988b5d to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/d4743d73b9ad4a988b5d to your computer and use it in GitHub Desktop.
if ($retval==0)
{
$lastline="ENC:".end(explode('ENC:',$lastline));
$encline=explode(":",$lastline,2);
// job in progress
if ($encline[0]=="ENC")
{
if (strpos($encline[1], 'time=')>1)
{
$encodepasses=$runningworkflow["passes_total"];
$currenttime=reset(explode(" ",end(explode("time=",$encline[1],2)),2));
$currenttime=ffmpeg_to_ms($currenttime);
$percent=round(($currenttime/$duration)*100,2);
if ($runningworkflow['current_pass']="0")
{
$percent=0;
}
else
{
if (($percent>0)&&($percent<100))
{
$percent=round(100/$runningworkflow['passes_total']*$runningworkflow['passes_current']
-100/$runningworkflow['passes_total']+$percent/$runningworkflow['passes_total'],2);
}
}
//echo $duration."<-".$currenttime."=".$percentagecomplete."\%\n";
$jobcount=$jobcount+1;
// inject into memcache nodes
foreach ($APP_CONF["MEMCACHE_NODES"] as $memcachenode)
{
$m = new Memcache();
$m->connect($memcachenode, $APP_CONF["MEMCACHE_PORT"]);
if (!$m->set(md5($runningworkflow["workflow_key"]), $percent, FALSE,
$APP_CONF["MEMCACHE_EXPIRATION"]))
{
log_message(reset(explode(".",basename(__FILE__))).".".__FUNCTION__,
"Error Storing Percentage Complete Data on Memcache Node ".$memcachenode);
}
$m = NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment