Skip to content

Instantly share code, notes, and snippets.

@brettcvz
Created March 21, 2013 16:00
Show Gist options
  • Save brettcvz/5214190 to your computer and use it in GitHub Desktop.
Save brettcvz/5214190 to your computer and use it in GitHub Desktop.
Full js for integrating filepicker.io and zencoder
<!-- Replace the previous script tag with this one -->
<script type="text/javascript">
$(function() {
//Put your Filepicker.io API key here:
filepicker.setKey('A9gfeq0CMTMeP1dR86vcxz');
//Zencoder API key
var zenKey = 'ce887203717c4417267eeb7b59b55885';
$('a').click(function(e) {
e.preventDefault(); // This keeps the normal link behavior from happening
//Specifying all the extensions that zencoder can handle, you may want to choose a subset
var acceptedExtensions = ['3g2','3gp','3gp2','3gpp','3gpp2','aac','ac3','eac3','ec3','f4a','f4b','f4v','flv','highwinds','m4a','m4b','m4r','m4v','mkv','mov','mp3','mp4','oga','ogg','ogv','ogx','ts','webm','wma','wmv'];
filepicker.pickAndStore({extensions: acceptedExtensions},{location: 's3'},function(fpfiles){
// This is the simplest Zencoder API call you can make.
// This will output an h.264 mp4 with AAC audio and
// save it to Zencoder's temporary storage on S3.
var request = {
input: fpfiles[0].url
}
// Let's use $.ajax instead of $.post so we can specify custom headers.
$.ajax({
url: 'https://app.zencoder.com/api/v2/jobs',
type: 'POST',
data: JSON.stringify(request),
headers: { "Zencoder-Api-Key": zenKey },
dataType: 'json',
success: function(data) {
$('body').append('Job created! <a href="https://app.zencoder.com/jobs/'+ data.id +'">View Job</a>')
},
error: function(data) {
console.log(data);
}
});
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment