#!/usr/bin/env php <?php /** ************************************************************ * Metadata maker process for a single file * Use this to test the metadata processor */ if (!isset($argv[1])) { echo "Usage: " . $argv[0] . " <filename> \n Shows metadata of <filename> from the ffmpeg parser\n"; exit(127); } require_once __DIR__ . '/../../../common.php'; require_once __DIR__ . '/../libs/api.php'; require_once __DIR__ . '/../libs/ffmpeg.php'; $ffmpeg = new Ffmpeg(); $m = $ffmpeg->getFfmpegMetadata($argv[1]); print_r($m);
/** * Takes an image file, moves the file and adds database entry * @param the verified REAL name of the local file including path * @param name of file according to user/browser or just the name excluding path * @param desired category * @param title of image, if empty will be created from $name * @param description of image, if empty will remain empty * @todo deleteImage (video) * @return returns true if successfull otherwise returns an ImageUploadError */ function importImage($tmpName, $name, $cat, $title = '', $desc = '') { global $rsgConfig; $my =& JFactory::getUser(); $database =& JFactory::getDBO(); $destination = fileUtils::move_uploadedFile_to_orignalDir($tmpName, $name); if (is_a($destination, imageUploadError)) { return $destination; } $parts = pathinfo($destination); // fill $imgTitle if empty if ($imgTitle == '') { $imgTitle = substr($parts['basename'], 0, -(strlen($parts['extension']) + ($parts['extension'] == '' ? 0 : 1))); } // replace names with the new name we will actually use $parts = pathinfo($destination); $newName = $parts['basename']; $imgName = $parts['basename']; //Destination becomes original video, just for readability $original_video = $destination; $result = true; do { // New video will be located in display folder $newVideo = JPATH_DISPLAY . DS . $newName . "." . $rsgConfig->get("videoConverter_extension"); $result = Ffmpeg::convertVideo($original_video, $newVideo); if (!$result) { $result = new imageUploadError($imgName, "error converting video: <pre>" . print_r($result->getMessage(), true) . "</pre>"); break; } // get first frame of the video to genetrate a thumbnail from $videoPreviewImage = JPATH_ORIGINAL . DS . $newName . ".png"; $result = Ffmpeg::capturePreviewImage($original_video, $videoPreviewImage); if (!$result) { $result = new imageUploadError($imgName, "error capturing preview image: <pre>" . print_r($result->getMessage(), true) . "</pre>"); break; } //Get details of the original image. $width = getimagesize($videoPreviewImage); if (!$width) { $result = new imageUploadError($videoPreviewImage, "not an image OR can't read {$videoPreviewImage}"); break; } else { //the actual image width $width = $width[0]; } $result = imgUtils::makeThumbImage($videoPreviewImage, $newName); // remove the temporary preview image JFile::delete($videoPreviewImage); if (!$result) { $result = new imageUploadError($imgName, JText::_('ERROR CREATING THUMB IMAGE') . ": " . $videoPreviewImage); break; } // determine ordering $database->setQuery("SELECT COUNT(1) FROM #__rsgallery2_files WHERE gallery_id = '{$cat}'"); $ordering = $database->loadResult() + 1; //Store image details in database $alias = mysql_real_escape_string(JFilterOutput::stringURLSafe($title)); $desc = mysql_real_escape_string($desc); $title = mysql_real_escape_string($title); $database->setQuery("INSERT INTO #__rsgallery2_files" . " (title, name, descr, gallery_id, date, ordering, userid, alias) VALUES" . " ('{$title}', '{$newName}', '{$desc}', '{$cat}', now(), '{$ordering}', '{$my->id}', '{$alias}')"); if (!$database->query()) { $result = new imageUploadError($parts['basename'], $database->stderr(true)); break; } } while (false); if ($result !== true) { // clean up if (JFile::exists($newVideo)) { JFile::delete($newVideo); } if (JFile::exists($videoPreviewImage)) { JFile::delete($videoPreviewImage); } imgUtils::deleteImage($newName); } return $result; }
#!/usr/bin/env php <?php /** ************************************************************ * Metadata maker process, may be launch as many time as needed * on the machine having a proper ffmpeg installed. * this is a daemon: it never returns * you should launch it using an init script */ require_once __DIR__ . '/../../../common.php'; require_once __DIR__ . '/../libs/api.php'; require_once __DIR__ . '/../libs/ffmpeg.php'; require_once MODULES . '/users/libs/users.php'; $api = new Api(); $ffmpeg = new Ffmpeg(); $api->log_caller = "metadata-daemon"; declare (ticks=1); // In case termination signal, Ctrl-C or other exit-requesting signal: function sig_handler($signo) { global $task, $api; switch ($signo) { case SIGTERM: case SIGHUP: case SIGINT: case SIGQUIT: $api->log(LOG_INFO, "Got Signal {$signo}, cleanup and quit."); if ($task) { $api->setTaskFailedUnlock($task["id"]); } exit; break;
#!/usr/bin/php <?php // Configuration require_once __DIR__ . '/common.php'; require_once MODULES . '/api/libs/ffmpeg.php'; require_once MODULES . '/api/libs/api.php'; $api = new api(); $ffmpeg = new Ffmpeg(); $ffmpeg->DEBUG = 1; if (count($argv) < 2) { echo "USAGE: test_metadata.php <filename>\n"; echo "tells the metadata of a file\n\n"; exit; } print_r($ffmpeg->getFfmpegMetadata($argv[1]));
#!/usr/bin/env php <?php /** ************************************************************ * Transcoder process, may be launch as many time as needed * on the machine having a proper ffmpeg installed. * this is a daemon: it never returns * you should launch it using an init script */ require_once __DIR__ . '/../../../common.php'; require_once __DIR__ . '/../libs/api.php'; require_once __DIR__ . '/../libs/ffmpeg.php'; require_once MODULES . '/users/libs/users.php'; $api = new Api(); $ffmpeg = new Ffmpeg(); $api->log_caller = "transcoder-daemon"; declare (ticks=1); // In case termination signal, Ctrl-C or other exit-requesting signal: function sig_handler($signo) { global $task, $api; switch ($signo) { case SIGTERM: case SIGHUP: case SIGINT: case SIGQUIT: $api->log(LOG_INFO, "Got Signal {$signo}, cleanup and quit."); if ($task) { $api->setTaskFailedUnlock($task["id"]); } exit; break;
function batchupload_2($ziplist, $extractDir) { /* Info for javascript on input element names and values: Step 2 Button: Upload --> task=save_batchupload Delete checkbox name: delete[1] Item title field name: ptitle[] Gallery select name: category[] Description area name: descr[] */ global $rsgOption; JHTML::_('behavior.mootools'); $database = JFactory::getDBO(); //Get variables from form $selcat = rsgInstance::getInt('selcat', null); $ftppath = rsgInstance::getVar('ftppath', null); $xcat = rsgInstance::getInt('xcat', null); $batchmethod = rsgInstance::getVar('batchmethod', null); ?> <script language="javascript" type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm, missingCat = false, categories = $$('#adminForm input[name^=category]', '#adminForm select[name^=category]'); for (i=0 ; i<categories.length ; i++) { if (categories[i].value <= 0) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "+' (#'+i+')'); return; missingCat = true; break; } } if (pressbutton == 'save_batchupload'){ if (missingCat == true) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "); } else { form.submit(); } } } //--> </script> <form action="index2.php" method="post" name="adminForm" id="adminForm"> <table class="adminform"> <tr> <th colspan="5" class="sectionname"><font size="4"><?php echo JText::_('Step 2'); ?> </font></th> </tr> <tr> <?php // Initialize k (the column reference) to zero. $k = 0; $i = 0; foreach ($ziplist as $filename) { $k++; //Check if filename is dir if (is_dir(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename)) { continue; } else { //Check if file is allowed $allowed_ext = array('gif', 'jpg', 'png'); $allowedVideo_ext = array('flv', 'avi', 'mov'); $ext = fileHandler::getImageType(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename); if (in_array($ext, $allowedVideo_ext)) { // build preview image $basePath = JPATH_SITE . '/media/' . $extractDir . '/'; require_once JPATH_RSGALLERY2_ADMIN . 'includes/video.utils.php'; Ffmpeg::capturePreviewImage($basePath . $filename, $basePath . $filename . '.png'); $displayImage = $filename . '.png'; $i++; } else { if (!in_array($ext, $allowed_ext)) { continue; } else { $displayImage = $filename; $i++; } } } ?> <td align="center" valign="top" bgcolor="#CCCCCC"> <table class="adminform" border="0" cellspacing="1" cellpadding="1"> <tr> <th colspan="2"> </th> </tr> <tr> <td colspan="2" align="right"><?php echo JText::_('Delete'); ?> #<?php echo $i - 1; ?> : <input type="checkbox" name="delete[<?php echo $i - 1; ?> ]" value="true" /></td> </tr> <tr> <td align="center" colspan="2"><img src="<?php echo JURI_SITE . "/media/" . $extractDir . "/" . $displayImage; ?> " alt="" border="1" width="100" align="center" /></td> </tr> <input type="hidden" value="<?php echo $filename; ?> " name="filename[]" /> <tr> <td><?php echo JText::_('Title'); ?> </td> <td> <input type="text" name="ptitle[]" size="15" /> </td> </tr> <tr> <td><?php echo JText::_('Gallery'); ?> </td> <td><?php if ($selcat == 1 && $xcat !== '0') { ?> <input type="text" name="cat_text" value="<?php echo htmlspecialchars(stripslashes(galleryUtils::getCatnameFromId($xcat))); ?> " readonly /> <input type="hidden" name="category[]" value="<?php echo $xcat; ?> " /> <?php } else { echo galleryUtils::galleriesSelectList(null, 'category[]', false); } ?> </td> </tr> <tr> <td><?php echo JText::_('Description'); ?> </td> <td><textarea cols="15" rows="2" name="descr[]"></textarea></td> </tr> </table> </td> <?php if ($k == 5) { echo "</tr><tr>"; $k = 0; } } ?> </table> <input type="hidden" name="teller" value="<?php echo $i; ?> " /> <input type="hidden" name="extractdir" value="<?php echo $extractDir; ?> " /> <input type="hidden" name="option" value="com_rsgallery2" /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="task" value="save_batchupload" /> </form> <?php }