public void Submit_Advanced_JobTest() { ZencoderClient client = new ZencoderClient(API_KEY, true); JobRequest jobRequest = new JobRequest(InputSample, new OutputSetting(OutputBaseUrl, OutputFilename)); jobRequest.download_connections = 3; jobRequest.region = RegionSetting.UnitedStates; OutputSetting output2 = new OutputSetting(OutputBaseUrl, "output.ogg"); output2.aspect_mode = VideoAspectModeSetting.Letterbox; output2.audio_bitrate = 96; output2.audio_channels = 1; output2.audio_codec = AudioCodecSetting.Vorbis; output2.audio_quality = QualitySetting.MediumHi; output2.audio_sample_rate = 44100; output2.autolevel = true; output2.bitrate_cap = 500; output2.buffer_size = 300; output2.clip_length = "6.5"; output2.deblock = true; output2.deinterlace = VideoDeinterlaceSetting.Detect; output2.denoise = VideoDenoiseSetting.Strong; output2.frame_rate = 24; output2.height = 220; output2.keyframe_interval = 100; output2.label = "vorbis"; output2.max_frame_rate = 30; output2.NotificationSettings = new List<NotificationSetting>(); output2.NotificationSettings.Add(new NotificationSetting(NotificationType.Email, "*****@*****.**")); output2.NotificationSettings.Add(new NotificationSetting(new NotificationAdvancedSettings("json", "http://cdeutsch.com"))); output2.quality = QualitySetting.High; output2.skip_audio = false; output2.skip_video = false; output2.speed = VideoSpeedSetting.Slow_BetterCompression; output2.start_clip = "0:00:02"; output2.thumbnails = new ThumbnailSetting(); output2.thumbnails.base_url = OutputBaseUrl; output2.thumbnails.format = ThumbnailFormatSetting.PNG; output2.thumbnails.interval = 5; output2.thumbnails.number = 3; output2.thumbnails.prefix = "thumb_"; output2.thumbnails.size = "120x80"; output2.thumbnails.start_at_first_frame = true; output2.thumbnails.public_s3 = false; output2.upscale = true; output2.video_bitrate = 400; output2.video_codec = VideoCodecSetting.Theora; output2.watermark = new WatermarkSetting(); output2.watermark.url = WatermarkImageUrl; output2.watermark.width = "10"; output2.watermark.height = "10"; output2.watermark.x = "20"; output2.watermark.y = "-10%"; output2.width = 400; jobRequest.outputs.Add(output2); JobResponse jobResponse = client.SubmitJob(jobRequest); //check progress. JobOutputProgressResponse progress = client.GetJobOutputProgress(jobResponse.outputs[0].id); //get job and run tests. JobListingResponse job = client.GetJob(jobResponse.id); //tests Assert.AreEqual(jobRequest.input, job.job.input_media_file.url, true, "Input does not match"); //you can testing test these if the job has reached a certain status. if (job.job.state == "failed" || job.job.state == "finished") { Assert.AreEqual(jobRequest.outputs[1].audio_bitrate, job.job.output_media_files[1].audio_bitrate_in_kbps, "Audio bitrate does not match"); Assert.AreEqual(jobRequest.outputs[1].audio_codec, job.job.output_media_files[1].audio_codec, true, "Audio codec does not match"); Assert.AreEqual(jobRequest.outputs[1].audio_sample_rate, job.job.output_media_files[1].audio_sample_rate, "Audio sample rate does not match"); Assert.AreEqual(jobRequest.outputs[1].audio_channels.Value.ToString(), job.job.output_media_files[1].channels, "Audio channels does not match"); Assert.AreEqual(jobRequest.outputs[1].frame_rate, job.job.output_media_files[1].frame_rate, "Video frame rate does not match"); Assert.AreEqual(jobRequest.outputs[1].height, job.job.output_media_files[1].height, "Video height does not match"); Assert.AreEqual(jobRequest.outputs[1].label, job.job.output_media_files[1].label, true, "Video label does not match"); Assert.AreEqual(jobRequest.outputs[1].video_codec, job.job.output_media_files[1].video_codec, true, "Video codec does not match"); Assert.AreEqual(jobRequest.outputs[1].width, job.job.output_media_files[1].width, "Video width does not match"); } //cleanup. client.CancelJob(jobResponse.id); client.DeleteJob(jobResponse.id); }
/// <summary> /// Submits a new encoding job. /// </summary> /// <param name="job"></param> public JobResponse SubmitJob(JobRequest job) { ValidateConfiguration(); //use restsharp to make the api call. RestClient client = GetClient(); RestRequest request = new RestRequest("jobs", Method.POST); request.RequestFormat = DataFormat.Json; //add global settings to job before it serialilzed. job.api_key = api_key; job.test = test; //use our own serializer so we can exclude null values. //request.AddBody(job); request.AddParameter(ContentType, Serializer.Serialize(job), ParameterType.RequestBody); request.OnBeforeDeserialization = resp => { if (resp.StatusCode == HttpStatusCode.BadRequest) { request.RootElement = "Error"; } }; RestResponse<JobResponse> response = client.Execute<JobResponse>(request); ValidateResponse(response, HttpStatusCode.Created); if (response.ErrorException != null) { throw response.ErrorException; } return response.Data; }
public void SubmitJobTest() { ZencoderClient client = new ZencoderClient(API_KEY, true); JobRequest jobRequest = new JobRequest(InputSample, new OutputSetting(OutputBaseUrl, OutputFilename)); JobResponse jobResponse = client.SubmitJob(jobRequest); //check progress. JobOutputProgressResponse progress = client.GetJobOutputProgress(jobResponse.outputs[0].id); //list jobs. List<JobListingResponse> jobList = client.ListJobs(); JobListingResponse job = client.GetJob(jobResponse.id); //cleanup. client.CancelJob(jobResponse.id); client.DeleteJob(jobResponse.id); Assert.AreEqual("queued", progress.state, "Progress does not equal 'queued'."); }