/** * @test * @return Job */ public function createJob() { $inputConfig = new HttpInputConfig(); $inputConfig->url = self::URL_FILE; $input = Input::create($inputConfig); /* CREATE VIDEO STREAM CONFIG */ $videoStreamConfig = new VideoStreamConfig(); $videoStreamConfig->bitrate = 1024000; $videoStreamConfig->height = 202; $videoStreamConfig->width = 480; /* CREATE AUDIO STREAM CONFIGS */ $audioStreamConfig = new AudioStreamConfig(); $audioStreamConfig->bitrate = 256000; $encodingProfileConfig = new EncodingProfileConfig(); $encodingProfileConfig->name = $this->getName() . 'EncodingProfile'; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); $jobConfig = new JobConfig(); $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; $jobConfig->manifestTypes[] = ManifestTypes::MPD; /* CREATE JOB */ $job = Job::create($jobConfig); $this->assertInstanceOf(Job::class, $job); $this->assertNotNull($job->jobId); $this->assertNotEquals($job->status, Job::STATUS_ERROR); return $job; }
protected function listEncodingProfile() { $this->markTestIncomplete("incomplete"); foreach (EncodingProfile::getListAll() as $output) { $this->checkEncodingProfile($output); } }
/** * @test * @depends createLiveStreamOutput * @return LiveStream */ public function createLiveStream(Output $output) { $encodingProfiles = EncodingProfile::getListAll(); $this->assertGreaterThan(0, count($encodingProfiles)); $liveStream = LiveStream::create("testliveinstance", "stream", $encodingProfiles[0], $output, 30); $this->assertNotNull($liveStream->id); return $liveStream; }
public function view($page = 'overview') { if (!file_exists(APPPATH . '/views/pages/' . $page . '.php')) { show_404(); } $data['title'] = ucfirst($page); $data['api_key'] = $this->session->api_key; $data['api_url'] = Bitcodin::getBaseUrl(); if (!isset($this->session->page_limit) or !is_numeric($this->session->page_limit)) { $this->session->page_limit = 10; } $data['page_limit'] = $this->session->page_limit; $page_files = get_filenames(APPPATH . '/views/pages'); $menu_items = array(); foreach ($page_files as $file) { $name = basename($file, '.php'); $menu_items[] = ucfirst($name); } $index = array_search('Home', $menu_items); $home = $menu_items[$index]; unset($menu_items[$index]); array_unshift($menu_items, $home); if ($page == 'overview') { Bitcodin::setApiToken($this->session->api_key); try { $encodingProfiles = EncodingProfile::getListAll(); if (count($encodingProfiles) <= 0) { $encProf = new \stdClass(); $encProf->encodingProfileId = 0; $encProf->name = "No encoding profile available"; $encodingProfiles = array("No encoding profiles found"); } $outputs = Output::getListAll(); if (count($outputs) <= 0) { $output = new \stdClass(); $output->outputId = 0; $output->name = "No output available"; $outputs = array($output); } } catch (BitcodinException $ex) { $output = new \stdClass(); $output->outputId = 0; $output->name = "No output available"; $outputs = array($output); $encProf = new \stdClass(); $encProf->encodingProfileId = 0; $encProf->name = "No encoding profile available"; $encodingProfiles = array($encProf); } $data['encodingProfiles'] = $encodingProfiles; $data['outputs'] = $outputs; } $data['menu_items'] = $menu_items; $this->load->view('templates/header', $data); $this->load->view('pages/' . $page, $data); $this->load->view('templates/footer', $data); }
public function create($label, $streamKey, $encProfId, $outputId, $timeshift) { Bitcodin::setApiToken($this->session->api_key); try { Bitcodin::setApiToken($this->session->api_key); $encProf = EncodingProfile::get($encProfId); $output = Output::get($outputId); LiveStream::create($label, $streamKey, $encProf, $output, $timeshift); } catch (\Exception $ex) { echo "<div class='top-buffer'></div><div class='alert alert-danger' role='alert'>" . $ex->getMessage() . "</div>"; } redirect('overview'); }
public function testMultiLanguageJob() { $inputConfig = new HttpInputConfig(); $inputConfig->url = self::URL_FILE; $inputConfig->skipAnalysis = true; $input = Input::create($inputConfig); $audioMetaDataJustSound = new AudioMetaData(); $audioMetaDataJustSound->defaultStreamId = 0; $audioMetaDataJustSound->label = 'Just Sound'; $audioMetaDataJustSound->language = 'de'; $audioMetaDataSoundAndVoice = new AudioMetaData(); $audioMetaDataSoundAndVoice->defaultStreamId = 1; $audioMetaDataSoundAndVoice->label = 'Sound and Voice'; $audioMetaDataSoundAndVoice->language = 'en'; /* CREATE VIDEO STREAM CONFIG */ $videoStreamConfig = new VideoStreamConfig(); $videoStreamConfig->bitrate = 2400000; $videoStreamConfig->height = 720; $videoStreamConfig->width = 1280; /* CREATE AUDIO STREAM CONFIGS */ $audioStreamConfig = new AudioStreamConfig(); $audioStreamConfig->bitrate = 256000; $encodingProfileConfig = new EncodingProfileConfig(); $encodingProfileConfig->name = 'SkippedAnalysisProfile'; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); $jobConfig = new JobConfig(); $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->manifestTypes[] = ManifestTypes::MPD; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; $jobConfig->speed = JobSpeedTypes::STANDARD; $jobConfig->audioMetaData[] = $audioMetaDataJustSound; $jobConfig->audioMetaData[] = $audioMetaDataSoundAndVoice; /* CREATE JOB */ $job = Job::create($jobConfig); $this->assertInstanceOf('bitcodin\\Job', $job); $this->assertNotNull($job->jobId); $this->assertNotEquals($job->status, Job::STATUS_ERROR); return $job; }
$aspectRatio = $inputWidth / $inputHeight; // Predefined widths $widths = array(426, 640, 854, 1280, 1920); $bitrates = array(400 * 1000, 800 * 1000, 1200 * 1000, 2400 * 1000, 4800 * 1000); $heights = array(); foreach ($widths as $width) { array_push($heights, getHeight($width, $aspectRatio)); } $videoStreamConfigurations = array(); for ($i = 0; $i < count($widths); $i++) { $videoStreamConfiguration = new VideoStreamConfig(); $videoStreamConfiguration->width = $widths[$i]; $videoStreamConfiguration->height = $heights[$i]; $videoStreamConfiguration->bitrate = $bitrates[$i]; array_push($videoStreamConfigurations, $videoStreamConfiguration); } $audioStreamConfig = new AudioStreamConfig(); $audioStreamConfig->bitrate = 128000; $encodingProfileConfig = new EncodingProfileConfig(); $encodingProfileConfig->name = 'API TEST PROFILE DELETE'; $encodingProfileConfig->videoStreamConfigs = $videoStreamConfigurations; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig; $encodingProfile = EncodingProfile::create($encodingProfileConfig); $jobConfig = new JobConfig(); $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; $jobConfig->manifestTypes[] = ManifestTypes::MPD; $job = Job::create($jobConfig); EncodingProfile::delete($encodingProfile->encodingProfileId);
$videoStreamConfig2 = new VideoStreamConfig(); $videoStreamConfig2->bitrate = 2400000; $videoStreamConfig2->height = 720; $videoStreamConfig2->width = 1280; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig2; $videoStreamConfig3 = new VideoStreamConfig(); $videoStreamConfig3->bitrate = 1200000; $videoStreamConfig3->height = 480; $videoStreamConfig3->width = 854; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig3; /* CREATE AUDIO STREAM CONFIGS */ $audioStreamConfig = new AudioStreamConfig(); $audioStreamConfig->bitrate = 256000; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); $jobConfig = new JobConfig(); $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->speed = JobSpeedTypes::STANDARD; $jobConfig->manifestTypes[] = ManifestTypes::MPD; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; /* CREATE JOB */ $job = Job::create($jobConfig); /* WAIT TIL JOB IS FINISHED */ do { $job->update(); sleep(1); } while ($job->status != Job::STATUS_FINISHED && $job->status != Job::STATUS_ERROR); $outputConfig = new AzureOutputConfig(); $outputConfig->name = "TestAzureOutput";
/** * @return EncodingProfile */ private function getMultiLanguageEncodingProfile() { /* CREATE VIDEO STREAM CONFIG */ $videoStreamConfig = new VideoStreamConfig(); $videoStreamConfig->bitrate = 1024000; $videoStreamConfig->height = 202; $videoStreamConfig->width = 480; /* CREATE AUDIO STREAM CONFIGS */ $audioStreamConfigSoundHigh = new AudioStreamConfig(); $audioStreamConfigSoundHigh->bitrate = 256000; $audioStreamConfigSoundHigh->defaultStreamId = 0; $audioStreamConfigSoundLow = new AudioStreamConfig(); $audioStreamConfigSoundLow->bitrate = 156000; $audioStreamConfigSoundLow->defaultStreamId = 0; $audioStreamConfigSoundAndVoiceHigh = new AudioStreamConfig(); $audioStreamConfigSoundAndVoiceHigh->bitrate = 256000; $audioStreamConfigSoundAndVoiceHigh->defaultStreamId = 1; $audioStreamConfigSoundAndVoiceLow = new AudioStreamConfig(); $audioStreamConfigSoundAndVoiceLow->bitrate = 156000; $audioStreamConfigSoundAndVoiceLow->defaultStreamId = 1; $encodingProfileConfig = new EncodingProfileConfig(); $encodingProfileConfig->name = 'TestEncodingProfile_' . $this->getName() . '@JobMultiLanguageTest'; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfigSoundHigh; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfigSoundLow; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfigSoundAndVoiceHigh; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfigSoundAndVoiceLow; /* CREATE ENCODING PROFILE */ return EncodingProfile::create($encodingProfileConfig); }
public function testMergeChannelsMultiAudioStreamJob() { $inputConfig = new HttpInputConfig(); $inputConfig->url = 'http://bitbucketireland.s3.amazonaws.com/at_test/mono_streams.mkv'; $input = Input::create($inputConfig); /* CREATE VIDEO STREAM CONFIG */ $videoStreamConfig = new VideoStreamConfig(); $videoStreamConfig->bitrate = 512000; $videoStreamConfig->height = 202; $videoStreamConfig->width = 480; /* CREATE AUDIO STREAM CONFIGS */ $audioStreamConfig1 = new AudioStreamConfig(); $audioStreamConfig1->bitrate = 256000; $audioStreamConfig1->defaultStreamId = 0; $audioStreamConfig2 = new AudioStreamConfig(); $audioStreamConfig2->bitrate = 128000; $audioStreamConfig2->defaultStreamId = 1; $encodingProfileConfig = new EncodingProfileConfig(); $encodingProfileConfig->name = 'Multi Audio Stream Profile'; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig1; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig2; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); $audioMetaData12 = new AudioMetaData(); $audioMetaData12->defaultStreamId = 0; $audioMetaData12->label = 'Channel 1 and 2'; $audioMetaData12->language = 'en'; $audioMetaData34 = new AudioMetaData(); $audioMetaData34->defaultStreamId = 1; $audioMetaData34->label = 'Channel 3 and 4'; $audioMetaData34->language = 'en'; $mergeAudioChannelConfig12 = new MergeAudioChannelConfig(); $mergeAudioChannelConfig12->audioChannels = array(1, 2); $mergeAudioChannelConfig34 = new MergeAudioChannelConfig(); $mergeAudioChannelConfig34->audioChannels = array(3, 4); $jobConfig = new JobConfig(); $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; $jobConfig->manifestTypes[] = ManifestTypes::MPD; $jobConfig->speed = JobSpeedTypes::STANDARD; $jobConfig->audioMetaData[] = $audioMetaData12; $jobConfig->audioMetaData[] = $audioMetaData34; $jobConfig->mergeAudioChannelConfigs[] = $mergeAudioChannelConfig12; $jobConfig->mergeAudioChannelConfigs[] = $mergeAudioChannelConfig34; /* CREATE JOB */ $job = Job::create($jobConfig); $this->assertInstanceOf('bitcodin\\Job', $job); $this->assertNotNull($job->jobId); $this->assertNotEquals($job->status, Job::STATUS_ERROR); return $job; }
$videoStreamConfig->height = 1080; $videoStreamConfig = new \bitcodin\VideoStreamConfig(); $videoStreamConfig->bitrate = 2400000; $videoStreamConfig->width = 1280; $videoStreamConfig->height = 720; $videoStreamConfig = new \bitcodin\VideoStreamConfig(); $videoStreamConfig->bitrate = 1200000; $videoStreamConfig->width = 854; $videoStreamConfig->height = 480; /* CREATE AUDIO STREAM CONFIGS */ $audio = new \bitcodin\AudioStreamConfig(); $audio->bitrate = 128000; $encodingProfileConfig->videoStreamConfigs[] = $videoStreamConfig; $encodingProfileConfig->audioStreamConfigs[] = $audio; /* CREATE ENCODING PROFILE */ $encodingProfile = \bitcodin\EncodingProfile::create($encodingProfileConfig); /* CREATE OUTPUT */ $outputConfig = new \bitcodin\S3OutputConfig(); $outputConfig->name = "Livestream Output Config"; $outputConfig->accessKey = "YOUR ACCESS KEY"; $outputConfig->secretKey = "YOUR SECRET KEY"; $outputConfig->bucket = "YOUR BUCKETNAME"; $outputConfig->prefix = "livestream" . $namingPostfix; $outputConfig->makePublic = true; $output = \bitcodin\Output::create($outputConfig); /* CREATE LIVE STREAM */ $livestreamName = "livestream-test-" . $namingPostfix; $livestreamStreamKey = "livestreamtestone"; $timeShift = 30; $liveEdgeOffset = 10; // Defines the offset in seconds to the time the first segment of your livestream was available. Value range: 1 to 3600
/** * @test * @dataProvider encodingProfileWithCroppingConfigProvider * @expectedException \bitcodin\exceptions\BitcodinException * * @param EncodingProfileConfig $encodingProfileConfig */ public function createEncodingProfileWithInvalidCroppingConfig(EncodingProfileConfig $encodingProfileConfig) { EncodingProfile::create($encodingProfileConfig); }
/** * @test * @dataProvider encodingProfileWithWatermarkConfigProvider * @expectedException \bitcodin\exceptions\BitcodinException * * @param EncodingProfileConfig $encodingProfileConfig */ public function createEncodingProfileWithInvalidWatermarkConfig(EncodingProfileConfig $encodingProfileConfig) { EncodingProfile::create($encodingProfileConfig); }
/** * @test * @expectedException \bitcodin\exceptions\BitcodinException */ public function createWithoutAnyStreamConfigs() { $encodingProfileConfig = new EncodingProfileConfig(); EncodingProfile::create($encodingProfileConfig); }
/** * @depends analyzeFtpInput_File4 */ public function testCreateFtpInputJob_File4(Input $input) { $encodingProfileConfig = AbstractEncodingProfileTest::encodingProfileProvider($this->getName())['defaultEncodingProfileConfig'][0]; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); $jobConfig = new JobConfig(); $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; $jobConfig->manifestTypes[] = ManifestTypes::MPD; /* CREATE JOB */ $job = Job::create($jobConfig); $this->assertInstanceOf(Job::class, $job); $this->assertNotNull($job->jobId); $this->assertNotEquals($job->status, Job::STATUS_ERROR); return $job; }
/** * @return EncodingProfile */ private function getMultiLanguageEncodingProfile() { $audioStreamConfigGermanLow = new AudioStreamConfig(); $audioStreamConfigGermanLow->bitrate = 156000; $audioStreamConfigGermanLow->defaultStreamId = 0; $encodingProfileConfig = new EncodingProfileConfig(); $encodingProfileConfig->name = 'TestEncodingProfile_' . $this->getName() . '@JobMultiLanguageTest'; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfigGermanLow; // CREATE ENCODING PROFILE return EncodingProfile::create($encodingProfileConfig); }