Zencoder has a really nice API builder on their website and tools like John Sheehan's RestSharp make calling web services from .NET easier then ever. But why not take it a step further and get it down to one line of code to submit an encoding job? That's what I've done over my Thanksgiving weekend and the results are on GitHub in my ZencoderWrapper repository.
One liner transcode:
JobResponse job = new ZencoderClient(API_KEY).SubmitJob("http://cdeutsch.com/input.avi", "ftp://ftpuser:email@example.com/videos/", "output.mp4");
You'll need to create an account on Zencoder to use the service. And if you want to encode more then 5 seconds of video you'll need to pick a payment option. You can alternatively use the ZencoderWrapper to create your account:
CreateAccountRequest account = new CreateAccountRequest("firstname.lastname@example.org", "password123");
Here's a more advanced example of creating an Ogg Vorbis file with thumbnails and notifications:
ZencoderClient client = new ZencoderClient(API_KEY); JobRequest jobRequest = new JobRequest("http://cdeutsch.com/input.avi", new OutputSetting("ftp://ftpuser:email@example.com/videos/", "output.ogg")); //configure output settings. jobRequest.outputs.audio_codec = AudioCodecSetting.Vorbis; jobRequest.outputs.video_codec = VideoCodecSetting.Theora; //add a notification. jobRequest.outputs.NotificationSettings = new List<NotificationSetting>(); jobRequest.outputs.NotificationSettings.Add(new NotificationSetting(NotificationType.Email, "firstname.lastname@example.org")); //create thumbnails jobRequest.outputs.thumbnails = new ThumbnailSetting(); jobRequest.outputs.thumbnails.base_url = "ftp://ftpuser:email@example.com/thumbs/"; jobRequest.outputs.thumbnails.format = ThumbnailFormatSetting.PNG; jobRequest.outputs.thumbnails.interval = 5; jobRequest.outputs.thumbnails.number = 3; jobRequest.outputs.thumbnails.prefix = "thumb_"; jobRequest.outputs.thumbnails.size = "120x80"; jobRequest.outputs.thumbnails.start_at_first_frame = true; //submit the job JobResponse job = client.SubmitJob(jobRequest);
Here's how to check the status of the job we just created:
//get job details. JobListingResponse job = client.GetJob(job.id);
Here's how to check to the status of the job's output file (there can be multiple outputs):
//get progress of first (in this case only) output file. JobOutputProgressResponse progress = client.GetJobOutputProgress(job.outputs.id);
And finally here's how to get a list of all of your jobs:
//get list of jobs List<JobListingResponse> jobList = client.ListJobs();
If I can convince Implex (the company I work for) to outsource their encoding to Zencoder I'll be using this wrapper for their QwikCast product. I also have another personal project I plan to use the wrapper in.
If you end up using it shoot me a message I'd love the feedback!
Not sure how I overlooked this earlier (either missed the Zencoder "Libraries" link or just got carried away with the idea of trying something new I guess) but Chad Burggraf has already created an excellent C# Zencoder client. I may end up using his library over my own for the asynchronous support. Part of it will depend on if Chad's library can compile with Mono since the personal project I want to build will ultimately be running on OSX. I'm not sure if my library will compile in Mono "as-is", but I believe RestSharp will and I don't think I used anything special beyond what's contained in RestSharp.