public static void Run() { /* Create BitcodinApi */ const string apiKey = "YOUR_API_KEY"; var bitApi = new BitcodinApi(apiKey); var inputConfig = new HttpInputConfig { Url = "http://bitbucketireland.s3.amazonaws.com/Sintel-two-audio-streams-short.mkv" }; Input input; try { input = bitApi.CreateInput(inputConfig); Console.WriteLine("Could create input: " + input.Filename); } catch (BitcodinApiException e) { Console.WriteLine("Could not create input: " + e); return; } var encodingProfileConfig = new EncodingProfileConfig { Name = "MyApiTestEncodingProfile" }; /* CREATE VIDEO STREAM CONFIGS */ var videoStreamConfig1 = new VideoStreamConfig { Bitrate = 4800000, Height = 1080, Width = 1920 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig1); var videoStreamConfig2 = new VideoStreamConfig { Bitrate = 2400000, Height = 720, Width = 1280 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig2); var videoStreamConfig3 = new VideoStreamConfig { Bitrate = 1200000, Height = 480, Width = 854 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig3); /* CREATE AUDIO STREAM CONFIGS */ var audioStreamConfig = new AudioStreamConfig { Bitrate = 128000 }; encodingProfileConfig.AudioStreamConfigs.Add(audioStreamConfig); /* CREATE ENCODING PROFILE */ EncodingProfile encodingProfile; try { encodingProfile = bitApi.CreateEncodingProfile(encodingProfileConfig); Console.WriteLine("Could create encoding profile: " + encodingProfile.Name); } catch (BitcodinApiException e) { Console.WriteLine("Could not create encoding profile: " + e); return; } /* CREATE DRM WIDEVINE CONFIG */ var widevineDrmConfig = new WidevineDrmConfig { RequestUrl = "http://license.uat.widevine.com/cenc/getcontentkey", SigningKey = "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9", SigningIv = "d58ce954203b7c9a9a9d467f59839249", ContentId = "746573745f69645f4639465043304e4f", Provider = "widevine_test", Method = DrmMethod.MpegCenc }; /* Create Job */ Console.WriteLine("Create Job"); var jobConfig = new JobConfig { EncodingProfileId = encodingProfile.EncodingProfileId, InputId = input.InputId }; jobConfig.ManifestTypes.Add(ManifestType.MpegDashMpd); jobConfig.ManifestTypes.Add(ManifestType.HlsM3U8); jobConfig.Speed = Speed.Standard; jobConfig.DrmConfig = widevineDrmConfig; Job job; try { job = bitApi.CreateJob(jobConfig); } catch (BitcodinApiException e) { Console.WriteLine("Could not create job: " + e); return; } JobDetails jobDetails; do { try { jobDetails = bitApi.GetJobDetails(job.JobId); Console.WriteLine("Status: " + jobDetails.JobStatus + " - Enqueued Duration: " + jobDetails.EnqueueDuration + "s" + " - Realtime Factor: " + jobDetails.RealtimeFactor + " - Encoded Duration: " + jobDetails.EncodedDuration + "s" + " - Output: " + jobDetails.BytesWritten / (double)1024 / 1024 + "MB" + " - Duration: " + jobDetails.Duration + " - FrameRate: " + jobDetails.FrameRate + " - JobId: " + jobDetails.JobId + " - SegmentsSplitted: " + jobDetails.SegmentsSplitted); } catch (BitcodinApiException) { Console.WriteLine("Could not get any job details"); return; } if (jobDetails.JobStatus.ToUpper().Equals(Enum.GetName(typeof(JobStatus), 4))) { Console.WriteLine("Error during transcoding"); return; } Thread.Sleep(2000); } while (!jobDetails.JobStatus.ToUpper().Equals(Enum.GetName(typeof(JobStatus), 3))); Console.WriteLine("Job with ID " + job.JobId + " finished successfully!"); var outputConfig = new FtpOutputConfig { Name = "TestFtpOutput", Host = "ftp.yourdomain.com/content", Username = "******", Password = "******" }; Output output; try { output = bitApi.CreateOutput(outputConfig); Console.WriteLine("Output has been created: " + output.Name); } catch (BitcodinApiException e) { Console.WriteLine("Could not create Output: " + e); return; } var transferConfig = new TransferConfig { JobId = job.JobId, OutputId = output.OutputId }; try { bitApi.Transfer(transferConfig); Console.WriteLine("Output has been transfered"); } catch (BitcodinApiException e) { Console.WriteLine("Could not transfer Output: " + e); } }
public static void Run() { /* Create BitcodinApi */ const string apiKey = "YOUR_API_KEY"; var bitApi = new BitcodinApi(apiKey); var inputConfig = new HttpInputConfig { Url = "http://eu-storage.bitcodin.com/inputs/Sintel.2010.720p.mkv" }; Input input; try { input = bitApi.CreateInput(inputConfig); Console.WriteLine("Could create input: " + input.Filename); } catch (BitcodinApiException e) { Console.WriteLine("Could not create input: " + e); return; } var encodingProfileConfig = new EncodingProfileConfig { Name = "MyApiTestEncodingProfile" }; /* CREATE VIDEO STREAM CONFIGS */ var videoStreamConfig1 = new VideoStreamConfig { Bitrate = 4800000, Height = 1080, Width = 1920 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig1); var videoStreamConfig2 = new VideoStreamConfig { Bitrate = 2400000, Height = 720, Width = 1280 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig2); var videoStreamConfig3 = new VideoStreamConfig { Bitrate = 1200000, Height = 480, Width = 854 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig3); /* CREATE AUDIO STREAM CONFIGS */ var audioStreamConfig = new AudioStreamConfig { Bitrate = 128000 }; encodingProfileConfig.AudioStreamConfigs.Add(audioStreamConfig); /* CREATE ENCODING PROFILE */ EncodingProfile encodingProfile; try { encodingProfile = bitApi.CreateEncodingProfile(encodingProfileConfig); Console.WriteLine("Could create encoding profile: " + encodingProfile.Name); } catch (BitcodinApiException e) { Console.WriteLine("Could not create encoding profile: " + e); return; } /* CREATE OUTPUT */ var outputConfig = new FtpOutputConfig { Name = "TestFtpOutput", Host = "ftp.yourdomain.com/content", Username = "******", Password = "******" }; Output output; try { output = bitApi.CreateOutput(outputConfig); Console.WriteLine("Could create Output: " + output.Name); } catch (BitcodinApiException e) { Console.WriteLine("Could not create Output: " + e); return; } /* Create Job */ var jobConfig = new JobConfig { EncodingProfileId = encodingProfile.EncodingProfileId, InputId = input.InputId, OutputId = output.OutputId, Speed = Speed.Standard }; jobConfig.ManifestTypes.Add(ManifestType.MpegDashMpd); jobConfig.ManifestTypes.Add(ManifestType.HlsM3U8); Job job; try { job = bitApi.CreateJob(jobConfig); } catch (BitcodinApiException e) { Console.WriteLine("Could not create job: " + e); return; } /* WAIT TIL JOB IS FINISHED */ JobDetails jobDetails; do { try { jobDetails = bitApi.GetJobDetails(job.JobId); Console.WriteLine("Status: " + jobDetails.JobStatus + " - Enqueued Duration: " + jobDetails.EnqueueDuration + "s" + " - Realtime Factor: " + jobDetails.RealtimeFactor + " - Encoded Duration: " + jobDetails.EncodedDuration + "s" + " - Output: " + jobDetails.BytesWritten / (double)1024 / 1024 + "MB"); } catch (BitcodinApiException) { Console.WriteLine("Could not get any job details"); return; } if (jobDetails.JobStatus.Equals(Enum.GetName(typeof(JobStatus), 4))) { Console.WriteLine("Error during transcoding"); return; } Thread.Sleep(2000); } while (!jobDetails.JobStatus.Equals(Enum.GetName(typeof(JobStatus), 3))); Console.WriteLine("Job with ID " + job.JobId + " finished successfully!"); /*TRANSFER */ Console.WriteLine("Transfering"); var transferConfig = new TransferConfig { JobId = job.JobId, OutputId = output.OutputId }; try { bitApi.Transfer(transferConfig); Console.WriteLine("Transfer finished..."); } catch (BitcodinApiException e) { Console.WriteLine("Could not transfer Output: " + e); } }
public static void Run() { /* Create BitcodinApi */ const string apiKey = "YOUR_API_KEY"; var bitApi = new BitcodinApi(apiKey); var inputConfig = new HttpInputConfig { Url = "http://bitbucketireland.s3.amazonaws.com/Sintel-two-audio-streams-short.mkv" }; Input input; try { input = bitApi.CreateInput(inputConfig); Console.WriteLine("Could create input: " + input.Filename); } catch (BitcodinApiException e) { Console.WriteLine("Could not create input: " + e); return; } var encodingProfileConfig = new EncodingProfileConfig { Name = "MyApiTestEncodingProfile" }; /* CREATE VIDEO STREAM CONFIGS */ var videoStreamConfig1 = new VideoStreamConfig { Bitrate = 4800000, Height = 1080, Width = 1920 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig1); var videoStreamConfig2 = new VideoStreamConfig { Bitrate = 2400000, Height = 720, Width = 1280 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig2); var videoStreamConfig3 = new VideoStreamConfig { Bitrate = 1200000, Height = 480, Width = 854 }; encodingProfileConfig.VideoStreamConfigs.Add(videoStreamConfig3); /* CREATE AUDIO STREAM CONFIGS */ var audioStreamConfig = new AudioStreamConfig { Bitrate = 128000 }; encodingProfileConfig.AudioStreamConfigs.Add(audioStreamConfig); /* CREATE ENCODING PROFILE */ EncodingProfile encodingProfile; try { encodingProfile = bitApi.CreateEncodingProfile(encodingProfileConfig); Console.WriteLine("Could create profile: " + encodingProfile.Name); } catch (BitcodinApiException e) { Console.WriteLine("Could not create encoding profile: " + e); return; } /* Create Job */ Console.WriteLine("Create Job"); var jobConfig = new JobConfig { EncodingProfileId = encodingProfile.EncodingProfileId, InputId = input.InputId }; jobConfig.ManifestTypes.Add(ManifestType.MpegDashMpd); jobConfig.StartTime = 90; // Transcoded video will start at 01:30 (90 seconds) jobConfig.Speed = Speed.Standard; Job job; try { job = bitApi.CreateJob(jobConfig); } catch (BitcodinApiException e) { Console.WriteLine("Could not create job: " + e); return; } JobDetails jobDetails; do { try { jobDetails = bitApi.GetJobDetails(job.JobId); Console.WriteLine("Status: " + jobDetails.JobStatus + " - Enqueued Duration: " + jobDetails.EnqueueDuration + "s" + " - Realtime Factor: " + jobDetails.RealtimeFactor + " - Encoded Duration: " + jobDetails.EncodedDuration + "s" + " - Output: " + jobDetails.BytesWritten / (double)1024 / 1024 + "MB" + " - Duration: " + jobDetails.Duration + " - FrameRate: " + jobDetails.FrameRate + " - JobId: " + jobDetails.JobId + " - SegmentsSplitted: " + jobDetails.SegmentsSplitted); } catch (BitcodinApiException) { Console.WriteLine("Could not get any job details"); return; } if (jobDetails.JobStatus.ToUpper().Equals(Enum.GetName(typeof(JobStatus), 4))) { Console.WriteLine("Error during transcoding"); return; } Thread.Sleep(2000); } while (!jobDetails.JobStatus.ToUpper().Equals(Enum.GetName(typeof(JobStatus), 3))); Console.WriteLine("Job with ID " + job.JobId + " finished successfully!"); var outputConfig = new FtpOutputConfig { Name = "TestFtpOutput", Host = "ftp.yourdomain.com/content", Username = "******", Password = "******" }; Output output; try { output = bitApi.CreateOutput(outputConfig); Console.WriteLine("Output has been created: " + output.Name); } catch (BitcodinApiException e) { Console.WriteLine("Could not create Output: " + e); return; } var transferConfig = new TransferConfig { JobId = job.JobId, OutputId = output.OutputId }; try { bitApi.Transfer(transferConfig); Console.WriteLine("Output has been transfered"); } catch (BitcodinApiException e) { Console.WriteLine("Could not transfer Output: " + e); } }
public Output.Output CreateOutput(FtpOutputConfig config) { return(Post <Output.Output>("output/create", config)); }