Skip to content

Instantly share code, notes, and snippets.

@brettcvz
Created March 21, 2013 16:00
Show Gist options
  • Select an option

  • Save brettcvz/5214190 to your computer and use it in GitHub Desktop.

Select an option

Save brettcvz/5214190 to your computer and use it in GitHub Desktop.

Revisions

  1. brettcvz created this gist Mar 21, 2013.
    36 changes: 36 additions & 0 deletions fpio_zencoder.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <!-- 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>