function procRequestTime($stream_id, $req_time) { global $mvStreamImageTable, $mvShellOggFrameGrab, $mvImageGranularityRate; if (!$req_time) { $req_time = '0'; } if (count(explode(":", $req_time)) == 3) { $req_time = ntp2seconds($req_time); } else { if (!is_numeric($req_time) && $req_time >= 0) { throw "error in req time format"; } } //query the image db to find the closest to req time (while still being in front) $dbr =& wfGetDB(DB_READ); //if($req_time<$mvImageGranularityRate)$req_time = $mvImageGranularityRate; $select = " `id`, `time`, `time`-'{$req_time}' as distance "; $cond = " `stream_id`={$stream_id} \n\t\t\t\tAND (`time`-'{$req_time}')>=0 \n\t\t\t\tAND (`time`-'{$req_time}')<= {$mvImageGranularityRate}"; $opt['ORDER BY'] = ' `distance` ASC '; $opt['LIMIT'] = 1; $res = $dbr->select($mvStreamImageTable, $select, $cond, 'MV_StreamImage::procRequestTime', $opt); //print $dbr->lastQuery(); //die; if ($dbr->numRows($res) == 0) { //could do a request to generate image for video here: if (MV_StreamImage::genLocalStreamImage($stream_id, $req_time, '320x240')) { //we just generated the current request time return it as valid: return $req_time; } else { return false; } } else { $img_row = $dbr->fetchObject($res); $req_time = $img_row->time; } return $req_time; }
function get_adjust_disp($titleKey = 'new', $mvd_id = 'new', $disp_buttons = true) { global $mvgScriptPath; // $out = ''; //some good old fashioned variable overloading: if ($mvd_id == 'new' || $mvd_id == 'seq') { global $mvDefaultClipLength; //$out.='start context: ' .$this->start_context . '<br />'; //$out.='end context: ' .$this->end_context . '<br />'; $start_time = isset($this->start_context) ? $this->start_context : seconds2ntp(0); $end_time = isset($this->end_context) ? seconds2ntp(ntp2seconds($this->start_context) + $mvDefaultClipLength) : seconds2ntp($mvDefaultClipLength); //$mvd_type = ''; } else { $mvTitle = new MV_Title($titleKey); if (!$mvTitle->validRequestTitle()) { return wfMsg('mvMVDFormat'); } $start_time = $mvTitle->getStartTime(); $end_time = $mvTitle->getEndTime(); //$mvd_type = $mvTitle->getMvdTypeKey(); } /* * @@todo move some of this to CSS */ $out .= ' <span id="mv_adjust_msg_' . $mvd_id . '"></span> <table style="background:transparent;position:relative" width="94%" border="0"><tr><td width="40"> <span id="track_time_start_' . $mvd_id . '" style="font-size:small">0:00:00</span> </td><td>' . '<div id="container_track_' . $mvd_id . '" style="width:100%; height: 5px; background-color: rgb(170, 170, 170); border:1px solid black; position: relative">'; //add some overlays to make the track look like it ends/starts at 0+-7px $out .= '<div style="position:absolute;left:0px;width:7px;height: 5px;background-color: white;border-right:1px solid black;"></div>' . '<div style="position:absolute;right:0px;width:7px;height: 5px;background-color: white;border-left:1px solid black;"></div>'; //the reszie div structure: $out .= '<div id="resize_' . $mvd_id . '" style="height: 20px; position: absolute;"> <div id="handle1_' . $mvd_id . '" style="background:no-repeat url(\'' . $mvgScriptPath . '/skins/images/slider_handle_green.gif\')"; class="ui-resizable-w ui-resizable-handle"></div> <div id="handle2_' . $mvd_id . '" style="background:no-repeat url(\'' . $mvgScriptPath . '/skins/images/slider_handle_red.gif\')"; class="ui-resizable-e ui-resizable-handle"></div> <div id="dragSpan_' . $mvd_id . '" class="ui-dragSpan"></div> </div> </div>' . '</td><td width="50"> <span id="track_time_end_' . $mvd_id . '" style="font-size:small">0:00:00</span> </td></tr></table> <br />'; //output a dummy form /*$out.='<form class="mv_css_form" id="mvd_adj_form_'.$mvd_id.'" method="GET" action="" ' . 'onSubmit="mv_adjust_submit(\''.$mvd_id.'\');return false;">';*/ $out .= '<span style="float:left;"><label class="mv_css_form" for="mv_start_hr_' . $mvd_id . '"><i>' . wfMsg('mv_start_desc') . ':</i></label> ' . '<input class="mv_adj_hr" size="8" maxlength="8" value="' . $start_time . '" id="mv_start_hr_' . $mvd_id . '" name="mv_start_hr_' . $mvd_id . '">' . '</span>'; $out .= '<span style="float:left;"><label class="mv_css_form" for="mv_end_hr_' . $mvd_id . '"><i>' . wfMsg('mv_end_desc') . ':</i></label> ' . '<input class="mv_adj_hr" size="8" maxlength="8" value="' . $end_time . '" id="mv_end_hr_' . $mvd_id . '" name="mv_end_hr_' . $mvd_id . '">' . '</span>'; //output page text (if not "new") //if($mvd_id!='new') // $out.=$this->get_fd_mvd_request( $titleKey, $mvd_id); /*$out.='<table width="100%">'. '<tr><td>'.wfMsg('mv_start_desc').'</td>'. '<td><input name="mv_start_hr_'.$mvd_id.'" type="text" value=""></td>'. '</tr><tr>'. '<input type="text" value=""><br /> */ //clear any floats: $out .= '<div style="clear:both"></div>'; //not used now that adjust is integrated with edit: /*if($disp_buttons){ $out.='<input style="font-weight:bold;" type="submit" value="'.wfMsg('mv_adjust_submit').'"> '; $out.='<input id="mv_adjust_preview_'.$mvd_id.'" type="button" value="'.wfMsg('mv_adjust_preview').'" onClick="mv_adjust_preview(\''.$mvd_id.'\')"> '; $out.='<input type="hidden" id="mv_adjust_preview_stop_'.$mvd_id.'" value="'.wfMsg('mv_adjust_preview_stop').'">'; $out.= '<a href="javascript:mv_disp_mvd(\''.$titleKey. '\',\''. $mvd_id.'\');return false;">' . wfMsgExt('cancel', array('parseinline')).'</a>'; }*/ //$out.='</form>'; return $out; }
function parseTitle($title) { global $mvDefaultClipLength; //the metavid namespace: //stream:stream_name || //mvd:type:stream_name_date/start_time/end_time $parts = split('/', $title); if (!isset($parts[1])) { $parts[1] = ''; } //check for type: $sub_parts = split(':', $parts[0]); if (count($sub_parts) == 2) { if ($sub_parts[0] == '' && $sub_parts[1] == '') { $this->stream_name = null; $this->type_marker = null; $this->hasMVDType = false; } else { $this->stream_name = $sub_parts[1]; $this->type_marker = $sub_parts[0]; $this->hasMVDType = true; } } else { if ($parts[0] == '') { $this->stream_name = null; } else { //print_r($sub_parts); //@@todo do look up of single part request $this->stream_name = $sub_parts[0]; //$this->stream_name = null; } $this->hasMVDType = false; } //check if the type isTime or "type" if (isset($parts[1])) { if (mvIsNtpTime($parts[1])) { $this->start_time = $parts[1]; if (isset($parts[2])) { if (mvIsNtpTime($parts[2])) { $this->end_time = $parts[2]; } } } } //(support null endtimes) //if the endtime is unset set it to the default length after the start time: //if(!isset($end_time)){ //$this->end_time = seconds2ntp(ntp2seconds($this->start_time) + $mvDefaultClipLength) ; //} //@@todo make sure start time is not negative & end time is not > duration //validate the start time: if (mvIsNtpTime($this->start_time) == false) { $this->start_time = null; } //validate the end time: if ($this->end_time != null) { if (mvIsNtpTime($this->end_time) == false) { $this->end_time = null; } //make sure the end time is > than the start time: if (ntp2seconds($this->start_time) > ntp2seconds($this->end_time)) { //@@TODO better error handling $this->start_time = null; $this->end_time = null; } } }
function do_insert_stream_file($mvStream, $path, $quality_msg) { global $mvVideoArchivePaths; $dbw = wfGetDB(DB_WRITE); //get file duration from nfo file (if avaliable ): $nfo_url = $path . '.nfo'; $nfo_txt = @file($nfo_url); if ($nfo_txt) { if (isset($nfo_txt[0])) { list($na, $len) = explode('n:', $nfo_txt[0]); $len = trim($len); //trim leading zero if ($len[0] == '0') { $len = substr($len, 1); } //trim sub frame times: if (strpos($len, '.') !== false) { $len = substr($len, 0, strpos($len, '.')); } $dur = ntp2seconds($len); } else { echo "empty nfo file: {$nfo_url} \n"; $dur = 0; } } else { echo "missing nfo file: {$nfo_url} \n"; $dur = 0; } $sql = "INSERT INTO `mv_stream_files` (`stream_id`, `file_desc_msg`, `path`, `duration`)" . " VALUES ('{$mvStream->id}', '{$quality_msg}', " . " '{$path}', {$dur} )"; $dbw->query($sql); }