Exemplo n.º 1
4
 /**
  * Create track from local hard drive with job service
  * 
  * @param MultimediaObject $multimediaObject
  * @param UploadedFile $file
  * @param string $profile
  * @param int $priority
  * @param string $language
  * @param array $description
  * @return MultimediaObject
  */
 public function createTrackFromLocalHardDrive(MultimediaObject $multimediaObject, UploadedFile $trackFile, $profile, $priority, $language, $description)
 {
     if (null === $this->profileService->getProfile($profile)) {
         throw new \Exception("Can't find given profile with name " . $profile);
     }
     if (UPLOAD_ERR_OK != $trackFile->getError()) {
         throw new \Exception($trackFile->getErrorMessage());
     }
     if (!is_file($trackFile->getPathname())) {
         throw new FileNotFoundException($trackFile->getPathname());
     }
     $pathFile = $trackFile->move($this->tmpPath . "/" . $multimediaObject->getId(), $trackFile->getClientOriginalName());
     $this->jobService->addJob($pathFile, $profile, $priority, $multimediaObject, $language, $description);
     return $multimediaObject;
 }
 /**
  * TODO add doc
  */
 private function generateJobs(MultimediaObject $multimediaObject, $pubChannelCod)
 {
     $jobs = array();
     foreach ($this->profiles as $targetProfile => $profile) {
         $targets = $this->getTargets($profile['target']);
         if (in_array($pubChannelCod, $targets['standard']) && $multimediaObject->isOnlyAudio() == $profile['audio']) {
             if (!$multimediaObject->isOnlyAudio() && 0 != $profile['resolution_ver']) {
                 $profileAspectRatio = $profile['resolution_hor'] / $profile['resolution_ver'];
                 $multimediaObjectAspectRatio = $multimediaObject->getTrackWithTag("master")->getAspectRatio();
                 if (1.5 > $profileAspectRatio !== 1.5 > $multimediaObjectAspectRatio) {
                     $this->logger->info(sprintf("JobGeneratorListener can't create a new job (%s) for multimedia object %s using standard target, " . "because a video profile aspect ratio(%f) is diferent to video aspect ratio (%f)", $targetProfile, $multimediaObject->getId(), $profileAspectRatio, $multimediaObjectAspectRatio));
                     continue;
                 }
             }
             $master = $multimediaObject->getTrackWithTag("master");
             $this->logger->info(sprintf("JobGeneratorListener creates new job (%s) for multimedia object %s using standard target", $targetProfile, $multimediaObject->getId()));
             $jobs[] = $this->jobService->addUniqueJob($master->getPath(), $targetProfile, 2, $multimediaObject, $master->getLanguage());
         }
         if (in_array($pubChannelCod, $targets['force'])) {
             if ($multimediaObject->isOnlyAudio() && !$profile['audio']) {
                 $this->logger->info(sprintf("JobGeneratorListener can't create a new job (%s) for multimedia object %s using forced target, because a video profile can't be created from an audio", $targetProfile, $multimediaObject->getId()));
                 continue;
             }
             $master = $multimediaObject->getTrackWithTag("master");
             $this->logger->info(sprintf("JobGeneratorListener creates new job (%s) for multimedia object %s using forced target", $targetProfile, $multimediaObject->getId()));
             $jobs[] = $this->jobService->addUniqueJob($master->getPath(), $targetProfile, 2, $multimediaObject, $master->getLanguage());
         }
     }
     return $jobs;
 }
 /**
  * Utilizando la libreria ffmpeg_php se genera un Pic que se asocia con el objeto
  * multimedia al que pertenece el archivo.
  *
  * @param MultimediaObject $multimediaObject
  * @param Track $track
  * @param integer $frame numero del frame donde se realiza la captura.
  * @return PIC o null si mal
  */
 private function createPic(MultimediaObject $multimediaObject, Track $track, $frame = 25)
 {
     $currentDir = 'series/' . $multimediaObject->getSeries()->getId() . '/video/' . $multimediaObject->getId();
     $absCurrentDir = $this->targetPath . "/" . $currentDir;
     $picFileName = date('ymdGis') . '.jpg';
     $aux = null;
     @mkdir($absCurrentDir, 0777, true);
     $aspectTrack = $this->getAspect($track);
     if (0 !== $aspectTrack) {
         $newHeight = intval(1.0 * $this->width / $aspectTrack);
         if ($newHeight <= $this->height) {
             $newWidth = $this->width;
         } else {
             $newHeight = $this->height;
             $newWidth = intval(1.0 * $this->height * $aspectTrack);
         }
     } else {
         $newHeight = $this->height;
         $newWidth = $this->width;
     }
     $vars = array("{{ss}}" => intval($frame / 25), "{{size}}" => $newWidth . "x" . $newHeight, "{{input}}" => $track->getPath(), "{{output}}" => $absCurrentDir . '/' . $picFileName);
     $commandLine = str_replace(array_keys($vars), array_values($vars), $this->command);
     $process = new Process($commandLine);
     $process->setTimeout(60);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     //log $process->getOutput()
     if (file_exists($absCurrentDir . '/' . $picFileName)) {
         $multimediaObject = $this->mmsPicService->addPicUrl($multimediaObject, $this->targetUrl . '/' . $currentDir . '/' . $picFileName);
     }
     return true;
 }
Exemplo n.º 4
0
 private function logView($when, MultimediaObject $multimediaObject, Track $track = null)
 {
     $log = new ViewsLog('/', '8.8.8.8', 'test', '', $multimediaObject->getId(), null);
     $log->setDate($when);
     $this->dm->persist($log);
     $this->dm->flush();
     return $log;
 }
 private function checkMultimediaObject(MultimediaObject $multimediaObject)
 {
     if (!isset($this->profiles[$this->targetProfile])) {
         $this->logger->warning(sprintf('CMAR JobGeneratorListener profile "%s" doesn\'t exist', $this->targetProfile));
         return;
     }
     $sbs = $multimediaObject->getTrackWithTag('sbs');
     $publicTracks = $multimediaObject->getTracksWithTag('profile:' . $this->targetProfile);
     if ($sbs && !$publicTracks) {
         $this->logger->info(sprintf("CMAR JobGeneratorListener creates new job (%s) for SbS in multimedia object %s", $this->targetProfile, $multimediaObject->getId()));
         $jobs[] = $this->jobService->addUniqueJob($sbs->getPath(), $this->targetProfile, 2, $multimediaObject, $sbs->getLanguage());
     }
 }
 /**
  * Set a pic from an url into the multimediaObject
  */
 public function addPicFile(MultimediaObject $multimediaObject, UploadedFile $picFile)
 {
     if (UPLOAD_ERR_OK != $picFile->getError()) {
         throw new \Exception($picFile->getErrorMessage());
     }
     if (!is_file($picFile->getPathname())) {
         throw new FileNotFoundException($picFile->getPathname());
     }
     $path = $picFile->move($this->targetPath . "/" . $multimediaObject->getId(), $picFile->getClientOriginalName());
     $pic = new Pic();
     $pic->setUrl(str_replace($this->targetPath, $this->targetUrl, $path));
     $pic->setPath($path);
     $multimediaObject->addPic($pic);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     return $multimediaObject;
 }
Exemplo n.º 7
0
 /**
  * Add a material from a file into the multimediaObject
  */
 public function addMaterialFile(MultimediaObject $multimediaObject, UploadedFile $materialFile, $formData)
 {
     if (UPLOAD_ERR_OK != $materialFile->getError()) {
         throw new \Exception($materialFile->getErrorMessage());
     }
     if (!is_file($materialFile->getPathname())) {
         throw new FileNotFoundException($materialFile->getPathname());
     }
     $material = new Material();
     $material = $this->saveFormData($material, $formData);
     $path = $materialFile->move($this->targetPath . "/" . $multimediaObject->getId(), $materialFile->getClientOriginalName());
     $material->setPath($path);
     $material->setUrl(str_replace($this->targetPath, $this->targetUrl, $path));
     $multimediaObject->addMaterial($material);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     return $multimediaObject;
 }
 /**
  * Find similar multimedia objects to a given one
  * with same tags, from different series,
  * broadcast public, status normal,
  * maximum 20 and random
  *
  * @param MultimediaObject $multimediaObject
  * @param array $tags
  * @return ArrayCollection
  */
 public function findRelatedMultimediaObjects(MultimediaObject $multimediaObject)
 {
     $qb = $this->createQueryBuilder()->field('_id')->notEqual($multimediaObject->getId())->field('series')->notEqual($multimediaObject->getSeries()->getId())->field('status')->equals(MultimediaObject::STATUS_PUBLISHED);
     // Broadcast public
     $broadcastRepo = $this->dm->getRepository('PumukitSchemaBundle:Broadcast');
     $broadcast = $broadcastRepo->findPublicBroadcast();
     $qb->field('broadcast')->references($broadcast);
     // Includes PUCHWEBTV code
     $tagRepo = $this->dm->getRepository('PumukitSchemaBundle:Tag');
     $unescoTag = $tagRepo->findOneByCod('UNESCO');
     $codes = array();
     foreach ($multimediaObject->getTags() as $tag) {
         if ($unescoTag) {
             if ($tag->isDescendantOf($unescoTag)) {
                 $codes[] = $tag->getCod();
             }
         }
     }
     $qb->field('tags.cod')->in($codes);
     // Limit 20 and random order
     $qb->limit(20)->sort('rank', mt_rand(0, 1) ? 1 : -1);
     $aux = $qb->getQuery()->execute();
     return $aux;
 }
Exemplo n.º 9
0
 /**
  * Add job
  */
 public function addJob($pathFile, $profile, $priority, MultimediaObject $multimediaObject, $language = null, $description = array(), $initVars = array())
 {
     $this->checkService();
     if (!is_file($pathFile)) {
         $this->logger->addError('[addJob] FileNotFoundException: Could not find file "' . $pathFile);
         throw new FileNotFoundException($pathFile);
     }
     if (null === $this->profileService->getProfile($profile)) {
         $this->logger->addError('[addJob] Can not find given profile with name "' . $profile);
         throw new \Exception("Can't find given profile with name " . $profile);
     }
     if (null === $multimediaObject) {
         $this->logger->addError('[addJob] Given null multimedia object');
         throw new \Exception("Given null multimedia object");
     }
     try {
         $duration = $this->inspectionService->getDuration($pathFile);
     } catch (\Exception $e) {
         $this->logger->addError('[addJob] InspectionService getDuration error message: ' . $e->getMessage());
         throw new \Exception($e->getMessage());
     }
     $job = new Job();
     $job->setMmId($multimediaObject->getId());
     $job->setProfile($profile);
     $job->setPathIni($pathFile);
     $job->setDuration($duration);
     $job->setPriority($priority);
     $job->setInitVars($initVars);
     if (null !== $language) {
         //TODO languageId is only language "es", "en", "gl"
         $job->setLanguageId($language);
     }
     if (!empty($description)) {
         $job->setI18nDescription($description);
     }
     if ($email = $this->getUserEmail()) {
         $job->setEmail($email);
     }
     $job->setTimeini(new \DateTime('now'));
     $this->dm->persist($job);
     $this->dm->flush();
     $this->setPathEndAndExtensions($job);
     $this->logger->addInfo('[addJob] Added job with id: ' . $job->getId());
     $this->executeNextJob();
     return $job;
 }
Exemplo n.º 10
0
 /**
  * @Route("/mm/{id}", methods="GET", name="pumukit_encoder_mm")
  */
 public function multimediaObjectAction(MultimediaObject $multimediaObject, Request $request)
 {
     return $this->redirect($this->generateUrl('pumukitnewadmin_mms_index', array('id' => $multimediaObject->getSeries()->getId(), 'mmid' => $multimediaObject->getId())));
 }
Exemplo n.º 11
0
 /**
  * @Template("PumukitNewAdminBundle:Material:list.html.twig")
  */
 public function listAction(MultimediaObject $multimediaObject)
 {
     return array('mmId' => $multimediaObject->getId(), 'materials' => $multimediaObject->getMaterials());
 }
Exemplo n.º 12
0
 /**
  * TODO See: Pumukit\EncoderBundle\Controller\InfoController::deleteJobAction
  *
  * @ParamConverter("multimediaObject", class="PumukitSchemaBundle:MultimediaObject", options={"id" = "mmId"})
  */
 public function deleteJobAction(MultimediaObject $multimediaObject, Request $request)
 {
     $this->get('pumukitencoder.job')->deleteJob($request->get('jobId'));
     $this->addFlash('success', 'delete job');
     return $this->redirect($this->generateUrl('pumukitnewadmin_track_list', array('id' => $multimediaObject->getId())));
 }
Exemplo n.º 13
0
 /**
  * Clone a multimedia object.
  *
  * @param  MultimediaObject $src
  * @return MultimediaObject
  */
 public function cloneMultimediaObject(MultimediaObject $src)
 {
     $new = new MultimediaObject();
     $new->setI18nTitle($src->getI18nTitle());
     $new->setI18nSubtitle($src->getI18nSubtitle());
     $new->setI18nDescription($src->getI18nDescription());
     $new->setI18nLine2($src->getI18nLine2());
     $new->setI18nKeyword($src->getI18nKeyword());
     $new->setCopyright($src->getCopyright());
     $new->setLicense($src->getLicense());
     // NOTE: #7408 Specify which properties are clonable
     $new->setProperty("subseries", $src->getProperty("subseries"));
     $new->setProperty("subseriestitle", $src->getProperty("subseriestitle"));
     $new->setProperty("clonedfrom", $src->getId());
     foreach ($src->getTags() as $tag) {
         $tagAdded = $this->tagService->addTagToMultimediaObject($new, $tag->getId(), false);
     }
     foreach ($src->getRoles() as $embeddedRole) {
         foreach ($embeddedRole->getPeople() as $embeddedPerson) {
             $new->addPersonWithRole($embeddedPerson, $embeddedRole);
         }
     }
     $new->setSeries($src->getSeries());
     if ($broadcast = $src->getBroadcast()) {
         $new->setBroadcast($broadcast);
         $this->dm->persist($broadcast);
     }
     $new->setPublicDate($src->getPublicDate());
     $new->setRecordDate($src->getRecordDate());
     $new->setStatus(MultimediaObject::STATUS_BLOQ);
     $this->dm->persist($new);
     $this->dm->flush();
     return $new;
 }
Exemplo n.º 14
0
 public function addMultimediaObject(MultimediaObject $multimediaObject)
 {
     $this->addSeries($multimediaObject->getSeries());
     $this->add($multimediaObject->getTitle(), "pumukit_webtv_multimediaobject_index", array("id" => $multimediaObject->getId()));
 }