function do_annotate_speeches($stream, $force) { print "do annotations for {$stream->name} \n"; $dbr = wfGetDB(DB_SLAVE); if ($force) { global $botUserName; // get wiki stream id: $wikiStream = new MV_Stream(array('name' => $stream->name)); // first remove all bot edited pages: $mvd_rows =& MV_Index::getMVDInRange($wikiStream->getStreamId(), null, null, 'Anno_en'); foreach ($mvd_rows as $row) { $title = Title::newFromText($row->wiki_title, MV_NS_MVD); $current = Revision::newFromTitle($title); if ($current->getUserText() == $botUserName) { $article = new Article($title); $article->doDelete('mvbot removal'); print "removed {$row->wiki_title} \n"; } else { print "skiped {$roe->wiki_title} (last edit by: " . $current->getUserText() . ")\n"; } } } // get all mvd's $mvStream = MV_Stream::newStreamByName($stream->name); if ($mvStream->doesStreamExist()) { $dbr = wfGetDB(DB_SLAVE); // get all pages in range (up 10k) $mvd_rows =& MV_Index::getMVDInRange($mvStream->getStreamId(), null, null, 'Ht_en', false, 'Spoken_By', array('LIMIT' => 10000)); if (count($mvd_rows) != 0) { print "looking at " . count($mvd_rows) . " text rows\n"; $prev_person = ''; $prev_st = $prev_et = 0; foreach ($mvd_rows as $mvd) { //print "On: ".$mvd->Spoken_By."\n"; if ($mvd->Spoken_By) { if ($prev_person == '') { $prev_person = $mvd->Spoken_By; // init case: $prev_st = $mvd->start_time; $prev_et = $mvd->end_time; } else { if ($prev_person == $mvd->Spoken_By) { // continue // print "acumulating for $mvd->Spoken_by \n"; $prev_et = $mvd->end_time; } else { // diffrent person: if more than 1 min long if ($prev_et - $prev_st > 60) { $doSpeechUpdate = true; print "insert annotation {$prev_person}: " . seconds2npt($prev_st) . " to " . seconds2npt($prev_et) . " \n"; // check for existing speech by in range if so skip (add subtract 1 to start/end (to not get matches that land on edges) (up to 10,000 meta per stream) $mvd_anno_rows = MV_Index::getMVDInRange($mvStream->getStreamId(), $prev_st + 1, $prev_et - 1, 'Anno_en', false, 'Speech_by'); foreach ($mvd_anno_rows as $row) { if ($row->Speech_by) { print ".. range already has: {$row->Speech_by} skip\n"; $doSpeechUpdate = false; break; } } if ($doSpeechUpdate) { $page_txt = '[[Speech by:=' . str_replace('_', ' ', $prev_person) . ']]'; $annoTitle = Title::makeTitle(MV_NS_MVD, 'Anno_en:' . $mvStream->getStreamName() . '/' . seconds2npt($prev_st) . '/' . seconds2npt($prev_et)); do_update_wiki_page($annoTitle, $page_txt); } } $prev_person = $mvd->Spoken_By; // init case: $prev_st = $mvd->start_time; } } } } print "\n\ndone with annotation inserts got to " . seconds2npt($prev_et) . ' of ' . seconds2npt($mvStream->getDuration()) . "\n"; } else { print "no annotations added 0 mvd transcript pages found\n"; } } }
function generate($take_duration) { global $mvgIP; require_once $mvgIP . '/includes/MV_Index.php'; $s = MV_Stream::newStreamByName($this->name); if (!$s->db_load_stream()) { return "An error occured while loading stream info please notify Administrator"; } $stream_duration = $s->getDuration(); if ($stream_duration === NULL) { return "Error: Stream Duration not set"; } $sitting_id = $s->getSittingId(); $editors = $this->getAssignedEditors($sitting_id); $readers = $this->getAssignedReaders($sitting_id); $reporters = $this->getAssignedReporters($sitting_id); $editors_count = count($editors); $readers_count = count($readers); $reporters_count = count($reporters); $html = ''; if ($editors_count == 0) { $html .= "No Editors Assigned"; return $html; } if ($readers_count == 0) { $html .= "No Readers Assigned"; return $html; } if ($reporters_count == 0) { $html .= "No Reporters Assigned"; return $html; } //delete all existing take transcripts $dbr =& wfGetDB(DB_SLAVE); $result =& MV_Index::getMVDInRange($s->getStreamId(), 0, $s->getDuration(), $this->mvd_tracks); while ($row = $dbr->fetchObject($result)) { $title = Title::newFromText($row->wiki_title, MV_NS_MVD); $art = new Article($title); if ($art->exists()) { $art->doDelete("new takes generated", true); } } $num_editor = 0; $num_reader = 0; $num_reporter = 0; for ($i = 0; $i < $stream_duration; $i = $i + $take_duration) { $start_time = $i; $end_time = $i + $take_duration; $title_text = 'Take_en:' . $this->name . '/' . seconds2ntp($start_time) . '/' . seconds2ntp($end_time); $title = Title::newFromText($title_text, MV_NS_MVD); $editor = User::newFromId($editors[$num_editor]); $editor_name = $editor->getRealName(); $reader = User::newFromId($readers[$num_editor]); $reader_name = $reader->getRealName(); $reporter = User::newFromId($reporters[$num_editor]); $reporter_name = $reporter->getRealName(); $article = new Article($title); $text = '[[Edited By::' . $editor_name . ']], ' . '[[Read By::' . $reader_name . ']], ' . '[[Reported By::' . $reporter_name . ']], ' . '[[Status::Incomplete]]'; $article->doEdit($text, 'Automatically Generated', EDIT_NEW); if ($num_editor < $editors_count - 1) { $num_editor++; } else { $num_editor = 0; } if ($num_reader < $readers_count - 1) { $num_reader++; } else { $num_reader = 0; } if ($num_reporter < $reporters_count - 1) { $num_reporter++; } else { $num_reporter = 0; } } $html .= 'Takes Successfully Generated'; return $html; }
require_once 'maintenance_util.inc.php'; if (count($args) == 0 || isset($options['help'])) { print ' USAGE php ogg_thumb_insert.php stream_name filename interval duration EXAMPLE where stream.ogg is 10min 20 seconds long and we get a frame every 5 seconds: ogg_thumb_insert.php stream_name stream.ogg 5 620 Notes: if possible you want to use the source footage rather than the ogg to generate the thumbnails (ie the mpeg2 or dv) '; exit; } $stream_name = $args[0]; $filename = $args[1]; $interval = $args[2]; $duration = $args[3]; $MV_Stream = MV_Stream::newStreamByName($stream_name); $stream_id = $MV_Stream->getStreamId(); $filedir = '../stream_images/' . MV_StreamImage::getRelativeImagePath($stream_id); $dbw = $dbr = wfGetDB(DB_MASTER); for ($i = 0; $i < $duration; $i += $interval) { shell_exec("ffmpeg -ss {$i} -i {$filename} -vcodec mjpeg -vframes 1 -an -f rawvideo -y {$filedir}/{$i}.jpg"); if (is_file("{$filedir}/{$i}.jpg")) { $dbw->query("INSERT INTO `mv_stream_images` (`stream_id`, `time`) VALUES ({$stream_id}, {$i})"); } else { print "failed to create file: {$filedir}/{$i}.jpg \n"; } }