private function createNewMultimediaObjectWithTrack()
 {
     $track = new Track();
     $track->addTag('profile:master');
     $track->setPath('path/to/track.mp4');
     $multimediaObject = new MultimediaObject();
     $multimediaObject->setTitle('MultimediaObject test');
     $multimediaObject->addTrack($track);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     return $multimediaObject;
 }
 private function addDefaultAudioPic(MultimediaObject $multimediaObject, Track $track)
 {
     $picFile = $this->createPicFile();
     if (null === $picFile) {
         return false;
     }
     $multimediaObject = $this->mmsPicService->addPicFile($multimediaObject, $picFile);
     if ($multimediaObject !== null) {
         if ($multimediaObject instanceof MultimediaObject) {
             $this->logger->info(__CLASS__ . '[' . __FUNCTION__ . '] ' . 'Extracted pic from track ' . $track->getId() . ' into MultimediaObject "' . $multimediaObject->getId() . '"');
         }
         return true;
     }
     return false;
 }
 /**
  * Completes track information from a given path using mediainfo.
  * @param Track $track
  */
 public function autocompleteTrack(Track $track)
 {
     $only_audio = true;
     //initialized true until video track is found.
     if (!$track->getPath()) {
         throw new \BadMethodCallException('Input track has no path defined');
     }
     $xml = simplexml_load_string($this->getMediaInfo($track->getPath()));
     if (!$this->xmlHasMediaContent($xml)) {
         throw new \InvalidArgumentException("This file has no accesible video " . "nor audio tracks\n" . $track->getPath());
     }
     foreach ($xml->File->track as $xml_track) {
         switch ((string) $xml_track['type']) {
             case "General":
                 $track->setMimetype($xml_track->Internet_media_type);
                 $track->setBitrate(intval($xml_track->Overall_bit_rate[0]));
                 $aux = intval((string) $xml_track->Duration[0]);
                 $track->setDuration(ceil($aux / 1000));
                 $track->setSize((string) $xml_track->File_size[0]);
                 break;
             case "Video":
                 $track->setVcodec((string) $xml_track->Format[0]);
                 $track->setFramerate((string) $xml_track->Frame_rate[0]);
                 $track->setWidth(intval($xml_track->Width));
                 $track->setHeight(intval($xml_track->Height));
                 $only_audio = false;
                 break;
             case "Audio":
                 $track->setAcodec((string) $xml_track->Format[0]);
                 $track->setChannels(intval($xml_track->Channel_s_));
                 break;
         }
         $track->setOnlyAudio($only_audio);
     }
 }
 public function testRemoveTrackFromMultimediaObject()
 {
     $this->createBroadcasts();
     $series = $this->factoryService->createSeries();
     $multimediaObject = $this->factoryService->createMultimediaObject($series);
     $this->assertEquals(0, count($multimediaObject->getTracks()));
     $this->assertEquals(0, count($this->repoJobs->findAll()));
     $job = new Job();
     $job->setMmId($multimediaObject->getId());
     $job->setStatus(Job::STATUS_FINISHED);
     $job->setProfile('master');
     $track = new Track();
     $track->addTag('profile:master');
     $multimediaObject->addTrack($track);
     $this->dm->persist($job);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     $this->assertEquals(1, count($multimediaObject->getTracks()));
     $this->assertEquals(1, count($this->repoJobs->findAll()));
     $multimediaObject = $this->repoMmobj->find($multimediaObject->getId());
     $track = $multimediaObject->getTracks()[0];
     $this->trackService->removeTrackFromMultimediaObject($multimediaObject, $track->getId());
     $this->assertEquals(0, count($multimediaObject->getTracks()));
     $this->assertEquals(0, count($this->repoJobs->findAll()));
 }
 /**
  * Completes track information from a given path using mediainfo.
  * @param Track $track
  */
 public function autocompleteTrack(Track $track)
 {
     $only_audio = true;
     //initialized true until video track is found.
     if (!$track->getPath()) {
         throw new \BadMethodCallException('Input track has no path defined');
     }
     $json = json_decode($this->getMediaInfo($track->getPath()));
     if (!$this->jsonHasMediaContent($json)) {
         throw new \InvalidArgumentException("This file has no accesible video " . "nor audio tracks\n" . $track->getPath());
     }
     $track->setMimetype(mime_content_type($track->getPath()));
     $track->setBitrate(intval($json->format->bit_rate));
     $aux = intval((string) $json->format->duration);
     $track->setDuration(ceil($aux));
     $track->setSize((string) $json->format->size);
     foreach ($json->streams as $stream) {
         switch ((string) $stream->codec_type) {
             case "video":
                 $track->setVcodec((string) $stream->codec_name);
                 $track->setFramerate((string) $stream->avg_frame_rate);
                 $track->setWidth(intval($stream->width));
                 $track->setHeight(intval($stream->height));
                 $only_audio = false;
                 break;
             case "audio":
                 $track->setAcodec((string) $stream->codec_name);
                 $track->setChannels(intval($stream->channels));
                 break;
         }
         $track->setOnlyAudio($only_audio);
     }
 }
 public function testRepository()
 {
     //$rank = 1;
     $status = MultimediaObject::STATUS_PUBLISHED;
     $record_date = new \DateTime();
     $public_date = new \DateTime();
     $title = 'titulo cualquiera';
     $subtitle = 'Subtitle paragraph';
     $description = "Description text";
     $duration = 300;
     $broadcast = $this->createBroadcast(Broadcast::BROADCAST_TYPE_PRI);
     $mmobj = new MultimediaObject();
     //$mmobj->setRank($rank);
     $mmobj->setStatus($status);
     $mmobj->setRecordDate($record_date);
     $mmobj->setPublicDate($public_date);
     $mmobj->setTitle($title);
     $mmobj->setSubtitle($subtitle);
     $mmobj->setDescription($description);
     $mmobj->setDuration($duration);
     $mmobj->setBroadcast($broadcast);
     $this->dm->persist($mmobj);
     $this->dm->flush();
     $this->assertEquals(1, count($this->repo->findAll()));
     $this->assertEquals($broadcast, $mmobj->getBroadcast());
     $broadcast = $this->createBroadcast(Broadcast::BROADCAST_TYPE_PUB);
     $mmobj->setBroadcast($broadcast);
     $this->dm->persist($mmobj);
     $this->dm->flush();
     $this->assertEquals($broadcast, $mmobj->getBroadcast());
     $t1 = new Track();
     $t1->setTags(array('master'));
     $t2 = new Track();
     $t2->setTags(array('mosca', 'master', 'old'));
     $t3 = new Track();
     $t3->setTags(array('master', 'mosca'));
     $t4 = new Track();
     $t4->setTags(array('flv', 'itunes', 'hide'));
     $t5 = new Track();
     $t5->setTags(array('flv', 'webtv'));
     $t6 = new Track();
     $t6->setTags(array('track6'));
     $t6->setHide(true);
     $this->dm->persist($t1);
     $this->dm->persist($t2);
     $this->dm->persist($t3);
     $this->dm->persist($t4);
     $this->dm->persist($t5);
     $this->dm->persist($t6);
     $mmobj->addTrack($t3);
     $mmobj->addTrack($t2);
     $mmobj->addTrack($t1);
     $mmobj->addTrack($t4);
     $mmobj->addTrack($t5);
     $mmobj->addTrack($t6);
     $this->dm->persist($mmobj);
     $this->dm->flush();
     $this->assertEquals(5, count($mmobj->getFilteredTracksWithTags()));
     $this->assertEquals(3, count($mmobj->getFilteredTracksWithTags(array('master'))));
     $this->assertEquals(1, count($mmobj->getFilteredTracksWithTags(array('master'), array('mosca', 'old'))));
     $this->assertEquals(0, count($mmobj->getFilteredTracksWithTags(array(), array('mosca', 'old'), array('master'))));
     $this->assertEquals(3, count($mmobj->getFilteredTracksWithTags(array(), array(), array('flv'))));
     $this->assertEquals(0, count($mmobj->getFilteredTracksWithTags(array(), array(), array('flv', 'master'))));
     $this->assertEquals(5, count($mmobj->getFilteredTracksWithTags(array(), array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mmobj->getFilteredTracksWithTags(array('mosca', 'old'), array(), array(), array('old'))));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags()));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags(array('master'))));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags(array('master'), array('mosca', 'old'))));
     $this->assertEquals(0, count($mmobj->getFilteredTrackWithTags(array(), array('mosca', 'old'), array('master'))));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags(array(), array(), array('flv'))));
     $this->assertEquals(0, count($mmobj->getFilteredTrackWithTags(array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags(array(), array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags(array('mosca', 'old'), array(), array(), array('old'))));
     $this->assertEquals(1, count($mmobj->getFilteredTrackWithTags(array(), array(), array(), array('master', 'mosca'))));
     $this->assertEquals(null, count($mmobj->getFilteredTrackWithTags(array('track6'))));
     $this->assertEquals(null, count($mmobj->getFilteredTracksWithTags(array('track6'))));
 }
 public function testGetFirstUrlPic()
 {
     // SERIES SECTION
     $series = $this->factoryService->createSeries();
     $absolute = false;
     $this->assertEquals($this->defaultSeriesPic, $this->picService->getFirstUrlPic($series, $absolute));
     $absolute = true;
     $this->assertEquals($this->localhost . $this->defaultSeriesPic, $this->picService->getFirstUrlPic($series, $absolute));
     $seriesUrl1 = '/uploads/series1.jpg';
     $seriesPic1 = new Pic();
     $seriesPic1->setUrl($seriesUrl1);
     $series->addPic($seriesPic1);
     $this->dm->persist($series);
     $this->dm->flush();
     $this->assertEquals($seriesUrl1, $this->picService->getFirstUrlPic($series));
     $seriesUrl2 = '/uploads/series2.jpg';
     $seriesPic2 = new Pic();
     $seriesPic2->setUrl($seriesUrl2);
     $series->addPic($seriesPic2);
     $this->dm->persist($series);
     $series->upPicById($seriesPic2->getId());
     $this->dm->persist($series);
     $this->dm->flush();
     $this->assertEquals($seriesUrl2, $this->picService->getFirstUrlPic($series));
     // MULTIMEDIA OBJECT SECTION
     // Workaround for detached Series document
     $this->dm->clear(get_class($series));
     $series = $this->dm->find('PumukitSchemaBundle:Series', $series->getId());
     $mm = $this->factoryService->createMultimediaObject($series);
     $mm->setSeries($series);
     $this->dm->persist($mm);
     $this->dm->flush();
     $track = new Track();
     $track->setOnlyAudio(false);
     $mm->addTrack($track);
     $this->dm->persist($mm);
     $this->dm->flush();
     $absolute = false;
     $this->assertEquals($this->defaultVideoPic, $this->picService->getFirstUrlPic($mm, $absolute));
     $absolute = true;
     $this->assertEquals($this->localhost . $this->defaultVideoPic, $this->picService->getFirstUrlPic($mm, $absolute));
     $track->setOnlyAudio(true);
     $this->dm->persist($mm);
     $this->dm->flush();
     $absolute = false;
     $hd = true;
     $this->assertEquals($this->defaultAudioHDPic, $this->picService->getFirstUrlPic($mm, $absolute, $hd));
     $hd = false;
     $this->assertEquals($this->defaultAudioSDPic, $this->picService->getFirstUrlPic($mm, $absolute, $hd));
     $absolute = true;
     $hd = true;
     $this->assertEquals($this->localhost . $this->defaultAudioHDPic, $this->picService->getFirstUrlPic($mm, $absolute, $hd));
     $hd = false;
     $this->assertEquals($this->localhost . $this->defaultAudioSDPic, $this->picService->getFirstUrlPic($mm, $absolute, $hd));
     $mmUrl1 = '/uploads/video1.jpg';
     $mmPic1 = new Pic();
     $mmPic1->setUrl($mmUrl1);
     $mm->addPic($mmPic1);
     $this->dm->persist($mm);
     $this->dm->flush();
     $this->assertEquals($mmUrl1, $this->picService->getFirstUrlPic($mm));
     $absolute = true;
     $this->assertEquals($this->localhost . $mmUrl1, $this->picService->getFirstUrlPic($mm, $absolute));
     $mmUrl2 = '/uploads/video2.jpg';
     $mmPic2 = new Pic();
     $mmPic2->setUrl($mmUrl2);
     $mm->addPic($mmPic2);
     $this->dm->persist($mm);
     $mm->upPicById($mmPic2->getId());
     $this->dm->persist($mm);
     $this->dm->flush();
     $this->assertEquals($mmUrl2, $this->picService->getFirstUrlPic($mm));
     $absolute = true;
     $this->assertEquals($this->localhost . $mmUrl2, $this->picService->getFirstUrlPic($mm, $absolute));
 }
 public function testAutocompleteTrackWithAudioAndVideo()
 {
     $file1 = $this->resources_dir . "CAMERA.mp4";
     $file2 = $this->resources_dir . "SCREEN.mp4";
     $track1 = new Track();
     $track2 = new Track();
     $is = new InspectionFfmpegService();
     $track1->setPath($file1);
     $track2->setPath($file2);
     $is->autocompleteTrack($track1);
     $is->autocompleteTrack($track2);
     $mime_type1 = 'video/mp4';
     $bitrate1 = '4320609';
     // mediainfo ='4323478';
     $duration1 = '2';
     $size1 = '551784';
     $vcodec1 = 'h264';
     // mediainfo = 'AVC';
     $framerate1 = '25.000';
     // Also works with $framerate = '25';
     $width1 = '960';
     $height1 = '720';
     $acodec1 = 'aac';
     //mediainfo = 'AAC';
     // Test general properties
     $this->assertEquals($mime_type1, $track1->getMimetype());
     $this->assertEquals($bitrate1, $track1->getBitrate());
     $this->assertEquals($duration1, $track1->getDuration());
     $this->assertEquals($size1, $track1->getSize());
     // Test video properties
     $this->assertEquals($vcodec1, $track1->getVcodec());
     $this->assertEquals($framerate1, $track1->getFramerate());
     $this->assertEquals($width1, $track1->getWidth());
     $this->assertEquals($height1, $track1->getHeight());
     // Test audio properties
     $this->assertFalse($track1->getOnlyAudio());
     $this->assertEquals($acodec1, $track1->getAcodec());
     $mime_type2 = 'video/mp4';
     $bitrate2 = '847600';
     $duration2 = '2';
     $size2 = '116545';
     $vcodec2 = 'h264';
     // mediainfo = 'AVC';
     $framerate2 = '10';
     // mediainfo = 9.091', it is variable fr. with max =10;
     $width2 = '1200';
     // FIXME mediainfo and ffprobe shows height = 900.
     $height2 = '900';
     $acodec2 = 'aac';
     //mediainfo = 'AAC';
     // Test general properties
     $this->assertEquals($mime_type2, $track2->getMimetype());
     $this->assertEquals($bitrate2, $track2->getBitrate());
     $this->assertEquals($duration2, $track2->getDuration());
     $this->assertEquals($size2, $track2->getSize());
     // Test video properties
     $this->assertEquals($vcodec2, $track2->getVcodec());
     $this->assertEquals($framerate2, $track2->getFramerate());
     $this->assertEquals($width2, $track2->getWidth());
     $this->assertEquals($height2, $track2->getHeight());
     // Test audio properties
     $this->assertFalse($track2->getOnlyAudio());
     $this->assertEquals($acodec2, $track2->getAcodec());
 }
 public function testIsOnlyAudio()
 {
     $mm = new MultimediaObject();
     $t1 = new Track();
     $t1->setOnlyAudio(true);
     $t2 = new Track();
     $t2->setOnlyAudio(true);
     $t3 = new Track();
     $t3->setOnlyAudio(true);
     $t4 = new Track();
     $t4->setOnlyAudio(true);
     $t5 = new Track();
     $t5->setOnlyAudio(true);
     $mm->addTrack($t3);
     $mm->addTrack($t2);
     $mm->addTrack($t1);
     $mm->addTrack($t4);
     $mm->addTrack($t5);
     $this->assertTrue($mm->isOnlyAudio());
     $t5->setOnlyAudio(false);
     $this->assertFalse($mm->isOnlyAudio());
 }
 public function testGenerateJobsForAudio()
 {
     $track = new Track();
     $track->addTag("master");
     $track->setPath("path");
     $track->setOnlyAudio(true);
     $mmobj = new MultimediaObject();
     $mmobj->addTrack($track);
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGA'));
     $this->assertEquals(array('audio'), $jobs);
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGC'));
     $this->assertEquals(array('audio', 'audio2'), $jobs);
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGB'));
     $this->assertEquals(array('audio2'), $jobs);
     //generate a video2 from an audio has no sense.
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGP'));
     $this->assertEquals(array(), $jobs);
     //generate a video from an audio has no sense.
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGFP'));
     $this->assertEquals(array(), $jobs);
     //generate a video from an audio has no sense.
 }
 /**
  * Completes track information from a given path using ffmpeg.
  * @param Track $track
  */
 public function autocompleteTrack(Track $track)
 {
     if (!$track->getPath()) {
         throw new \BadMethodCallException('Input track has no path defined');
     }
     $file = $track->getPath();
     $movie = new \ffmpeg_movie($file, false);
     $finfo = new \finfo();
     if (!$this->fileHasMediaContent($finfo, $file)) {
         throw new \InvalidArgumentException("This file has no video nor audio tracks");
     }
     $only_audio = true;
     // General
     $track->setMimetype($finfo->file($file, FILEINFO_MIME_TYPE));
     $track->setBitrate($movie->getBitRate());
     $track->setDuration(ceil($movie->getDuration()));
     $track->setSize(filesize($file));
     if ($movie->hasVideo()) {
         $only_audio = false;
         $track->setVcodec($movie->getVideoCodec());
         $track->setFramerate($movie->getFrameRate());
         $track->setWidth($movie->getFrameWidth());
         $track->setHeight($movie->getFrameHeight());
     }
     if ($movie->hasAudio()) {
         $track->setAcodec($movie->getAudioCodec());
         $track->setChannels($movie->getAudioChannels());
     }
     $track->setOnlyAudio($only_audio);
 }
Beispiel #12
0
 public function testIsMaster()
 {
     $t1 = new Track();
     $t1->addTag('master');
     $this->assertTrue($t1->isMaster());
     $t1->removeTag('master');
     $this->assertFalse($t1->isMaster());
 }
 /**
  * Get aspect
  * Return aspect ratio. Check is not zero.
  *
  * @param Track $track
  * @return float aspect ratio
  */
 private function getAspect(Track $track)
 {
     if (0 == $track->getHeight()) {
         return 0;
     }
     return 1.0 * $track->getWidth() / $track->getHeight();
 }
 public function importRecording($opencastId, $invert = false)
 {
     $mediaPackage = $this->opencastClient->getMediaPackage($opencastId);
     $seriesRepo = $this->dm->getRepository('PumukitSchemaBundle:Series');
     if (isset($mediaPackage["series"])) {
         $series = $seriesRepo->findOneBy(array("properties.opencast" => $mediaPackage["series"]));
     } else {
         $series = $seriesRepo->findOneBy(array("properties.opencast" => "default"));
     }
     if (!$series) {
         $series = $this->importSeries($mediaPackage);
     }
     $multimediaobjectsRepo = $this->dm->getRepository('PumukitSchemaBundle:MultimediaObject');
     $onemultimediaobjects = $multimediaobjectsRepo->findOneBy(array("properties.opencast" => $mediaPackage["id"]));
     if ($onemultimediaobjects == null) {
         $title = $mediaPackage["title"];
         $properties = $mediaPackage["id"];
         $recDate = $mediaPackage["start"];
         $multimediaObject = $this->factoryService->createMultimediaObject($series);
         $multimediaObject->setSeries($series);
         $multimediaObject->setRecordDate($recDate);
         $multimediaObject->setProperty("opencast", $properties);
         $multimediaObject->setProperty("opencastinvert", boolval($invert));
         $multimediaObject->setProperty("opencasturl", $this->opencastClient->getPlayerUrl() . "?id=" . $properties);
         $multimediaObject->setTitle($title);
         if (isset($mediaPackage["language"])) {
             $multimediaObject->setProperty("opencastlanguage", strtolower($mediaPackage["language"]));
         } else {
             $multimediaObject->setProperty("opencastlanguage", 'en');
         }
         foreach ($this->otherLocales as $locale) {
             $multimediaObject->setTitle($title, $locale);
         }
         //Multiple tracks
         if (isset($mediaPackage["media"]["track"][0])) {
             for ($i = 0; $i < count($mediaPackage["media"]["track"]); $i++) {
                 $tags = $mediaPackage["media"]["track"][$i]["tags"];
                 $url = $mediaPackage["media"]["track"][$i]["url"];
                 $mime = $mediaPackage["media"]["track"][$i]["mimetype"];
                 $duration = $mediaPackage["media"]["track"][$i]["duration"];
                 $track = new Track();
                 if (isset($mediapackage["media"]["track"][$i]["audio"])) {
                     $acodec = $mediaPackage["media"]["track"][$i]["audio"]["encoder"]["type"];
                     $track->setAcodec($acodec);
                 }
                 if (isset($mediaPackage["language"])) {
                     $track->setLanguage(strtolower($mediaPackage["language"]));
                 }
                 if (isset($mediaPackage["media"]["track"][$i]["video"])) {
                     $vcodec = $mediaPackage["media"]["track"][$i]["video"]["encoder"]["type"];
                     $track->setVcodec($vcodec);
                     $framerate = $mediaPackage["media"]["track"][$i]["video"]["framerate"];
                     $track->setFramerate($framerate);
                 }
                 if (!$track->getVcodec() && $track->getAcodec()) {
                     $track->setOnlyAudio(true);
                 }
                 $track->addTag("opencast");
                 $track->addTag($mediaPackage["media"]["track"][$i]["type"]);
                 $track->setUrl($url);
                 $track->setPath($this->opencastService->getPath($url));
                 $track->setMimeType($mime);
                 $track->setDuration($duration / 1000);
                 $this->inspectionService->autocompleteTrack($track);
                 $multimediaObject->setDuration($track->getDuration());
                 $multimediaObject->addTrack($track);
             }
         } else {
             $tags = $mediaPackage["media"]["track"]["tags"];
             $url = $mediaPackage["media"]["track"]["url"];
             $mime = $mediaPackage["media"]["track"]["mimetype"];
             $duration = $mediaPackage["media"]["track"]["duration"];
             $track = new Track();
             if (isset($mediapackage["media"]["track"]["audio"])) {
                 $acodec = $mediaPackage["media"]["track"]["audio"]["encoder"]["type"];
                 $track->setAcodec($acodec);
             }
             if (isset($mediaPackage["media"]["track"]["video"])) {
                 $vcodec = $mediaPackage["media"]["track"]["video"]["encoder"]["type"];
                 $track->setVcodec($vcodec);
                 $framerate = $mediaPackage["media"]["track"]["video"]["framerate"];
                 $track->setFramerate($framerate);
             }
             if (!$track->getVcodec() && $track->getAcodec()) {
                 $track->setOnlyAudio(true);
             }
             $track->addTag("opencast");
             $track->addTag($mediaPackage["media"]["track"]["type"]);
             $track->setUrl($url);
             $track->setPath($this->opencastService->getPath($url));
             $track->setMimeType($mime);
             $track->setDuration($duration / 1000);
             $this->inspectionService->autocompleteTrack($track);
             $multimediaObject->setDuration($track->getDuration());
             $multimediaObject->addTrack($track);
         }
         for ($j = 0; $j < count($mediaPackage["attachments"]["attachment"]); $j++) {
             if (isset($mediaPackage["attachments"]["attachment"][$j]["type"])) {
                 if ($mediaPackage["attachments"]["attachment"][$j]["type"] == "presenter/search+preview") {
                     $tags = $mediaPackage["attachments"]["attachment"][$j]["tags"];
                     $url = $mediaPackage["attachments"]["attachment"][$j]["url"];
                     $pic = new Pic();
                     $pic->setTags(array($tags));
                     $pic->setUrl($url);
                     $multimediaObject->addPic($pic);
                 }
             }
         }
         $tagRepo = $this->dm->getRepository('PumukitSchemaBundle:Tag');
         $opencastTag = $tagRepo->findOneByCod('TECHOPENCAST');
         if ($opencastTag) {
             $tagService = $this->tagService;
             $tagAdded = $tagService->addTagToMultimediaObject($multimediaObject, $opencastTag->getId());
         }
         $this->dm->persist($multimediaObject);
         $this->dm->flush();
         if ($track) {
             $opencastUrls = $this->getOpencastUrls($opencastId);
             $this->opencastService->genSbs($multimediaObject, $opencastUrls);
         }
     }
 }
 protected function incNumView(MultimediaObject $multimediaObject, Track $track = null)
 {
     $dm = $this->get('doctrine_mongodb.odm.document_manager');
     $multimediaObject->incNumview();
     $track && $track->incNumview();
     $dm->persist($multimediaObject);
     $dm->flush();
 }
 public function testPicExtractorAudioError()
 {
     // TODO: Remove this line when adding final default audio image
     $this->markTestSkipped('S');
     $mmsPicService = $this->getMockBuilder('Pumukit\\SchemaBundle\\Services\\MultimediaObjectPicService')->disableOriginalConstructor()->getMock();
     $mmsPicService->expects($this->any())->method('addPicFile')->will($this->returnValue(null));
     $picExtractorService = $this->getMockBuilder('Pumukit\\EncoderBundle\\Services\\PicExtractorService')->disableOriginalConstructor()->getMock();
     $picExtractorService->expects($this->any())->method('extractPic')->will($this->returnValue('success'));
     $picExtractorListener = new PicExtractorListener($this->dm, $mmsPicService, $picExtractorService, $this->logger, $this->autoExtractPic);
     $series = $this->factoryService->createSeries();
     $mm = $this->factoryService->createMultimediaObject($series);
     $track = new Track();
     $track->addTag("master");
     $track->setPath($this->videoPath);
     $track->setOnlyAudio(true);
     $track->setWidth(640);
     $track->setHeight(480);
     $mm->addTrack($track);
     $this->dm->persist($mm);
     $this->dm->flush();
     $this->assertTrue($mm->getPics()->isEmpty());
     $this->assertEquals(0, count($mm->getPics()->toArray()));
     $this->assertFalse($this->invokeMethod($picExtractorListener, 'generatePic', array($mm, $track)));
 }
Beispiel #17
0
 public function createTrack(MultimediaObject $multimediaObject, $pathEnd, $profileName, $language = null, $description = array())
 {
     $profile = $this->profileService->getProfile($profileName);
     $track = new Track();
     $track->addTag('profile:' . $profileName);
     if ($profile['master']) {
         $track->addTag('master');
     }
     if ($profile['display']) {
         $track->addTag('display');
     }
     foreach (array_filter(preg_split('/[,\\s]+/', $profile['tags'])) as $tag) {
         $track->addTag(trim($tag));
     }
     if (!empty($description)) {
         $track->setI18nDescription($description);
     }
     $track->setLanguage($language);
     $track->setPath($pathEnd);
     if (isset($profile['streamserver']['url_out'])) {
         $track->setUrl(str_replace(realpath($profile['streamserver']['dir_out']), $profile['streamserver']['url_out'], $pathEnd));
     }
     $this->inspectionService->autocompleteTrack($track);
     $track->setOnlyAudio($track->getWidth() == 0);
     $track->setHide(!$profile['display']);
     $multimediaObject->setDuration($track->getDuration());
     $multimediaObject->addTrack($track);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     return $track;
 }
 public function testAutocompleteTrackWithAudioAndVideo()
 {
     $file1 = $this->resources_dir . "CAMERA.mp4";
     $file2 = $this->resources_dir . "SCREEN.mp4";
     $track1 = new Track();
     $track2 = new Track();
     $is = new InspectionMediainfoService();
     $track1->setPath($file1);
     $track2->setPath($file2);
     $is->autocompleteTrack($track1);
     $is->autocompleteTrack($track2);
     $mime_type1 = 'video/mp4';
     $bitrate1 = 4300000;
     $duration1 = '2';
     $size1 = '551784';
     $vcodec1 = 'AVC';
     $framerate1 = '25.000';
     // Also works with $framerate = '25';
     $width1 = '960';
     $height1 = '720';
     $acodec1 = 'AAC';
     // Test general properties
     $this->assertEquals($mime_type1, $track1->getMimetype());
     $this->assertTrue($track1->getBitrate() > $bitrate1);
     $this->assertEquals($duration1, $track1->getDuration());
     $this->assertEquals($size1, $track1->getSize());
     // Test video properties
     $this->assertEquals($vcodec1, $track1->getVcodec());
     $this->assertEquals($framerate1, $track1->getFramerate());
     $this->assertEquals($width1, $track1->getWidth());
     $this->assertEquals($height1, $track1->getHeight());
     // Test audio properties
     $this->assertFalse($track1->getOnlyAudio());
     $this->assertEquals($acodec1, $track1->getAcodec());
     $mime_type2 = 'video/mp4';
     $bitrate2 = 847600;
     $duration2 = 2;
     $size2 = 116545;
     $vcodec2 = 'AVC';
     $framerate2 = '9.091';
     // Also works with $framerate = '25';
     $width2 = 1200;
     $height2 = 900;
     $acodec2 = 'AAC';
     // Test general properties
     $this->assertEquals($mime_type2, $track2->getMimetype());
     $this->assertEquals($bitrate2, $track2->getBitrate());
     $this->assertEquals($duration2, $track2->getDuration());
     $this->assertEquals($size2, $track2->getSize());
     // Test video properties
     $this->assertEquals($vcodec2, $track2->getVcodec());
     $this->assertEquals($framerate2, $track2->getFramerate());
     $this->assertEquals($width2, $track2->getWidth());
     $this->assertEquals($height2, $track2->getHeight());
     // Test audio properties
     $this->assertFalse($track2->getOnlyAudio());
     $this->assertEquals($acodec2, $track2->getAcodec());
 }