I've completed Zencoder integration / proof of concept - after many
challenges :)
Here is the code for the zencoder api request:
class zencoder():
@classmethod
def create_job(cls,input_url,output_url,notification_url):
result=urlfetch.fetch("https://app.zencoder.com/api/v2/jobs",method=
"POST",
payload=json.dumps({
"input":input_url,
"outputs":[
{
"url":output_url,
"format": "mp4"
}],
"thumbnails": [
{
"number": 7
}],
"notifications":[
{
"format": "json",
"url": notification_url
}]
}),
headers={"Zencoder-Api-Key": zencoder_api_key,"Content-Type":
"application/json"})
logging.info(result.content)
return json.loads(result.content)
It's currently very basic but enough to get started - should be self
explanatory
The biggest challenge was the GCS integration, getting the url format
right, finding credentials, formatting credentials etc.
Here is a usage
upload_files = self.get_file_infos('video')
file_info = upload_files[0]
logging.info(file_info.gs_object_name)
blob_key=blobstore.create_gs_key(file_info.gs_object_name)
#url=images.get_serving_url(blob_key,size=1600)
url="gcs://%s:%s@%s"%(urllib.quote(gcs_key),urllib.quote(gcs_secret),
file_info.gs_object_name[4:])
output_url="gcs://%s:%s@%s-encoded.mp4"%(urllib.quote(gcs_key),urllib.quote(
gcs_secret),file_info.gs_object_name[4:])
zencoder_output=zencoder.create_job(url,output_url,app_url+"/video/output")
logging.info("GG :D")
self.response.out.write("INPUT URL %s <br /> OUTPUT URL %s <br />
OBJECT_NAME %s <br /> KEY %s <br /> ZENCODER %s"%(url,output_url,file_info.
gs_object_name,blob_key,zencoder_output))
Should be self explanatory, you have to escape the + found in the gcs_secret
And the gcs_key/gcs_secret are in the old google api console,
https://code.google.com/apis/console/
You have to enable "Interoperable Access" from the Google Storage tab, and
then use the access key/secret from that
Works great, feels great
On Monday, August 19, 2013 4:18:04 PM UTC+3, Kaan Soral wrote:
>
> @Vinny P, thanks a lot for the really valuable answer and @Jeff thanks a
> lot for the insight
>
> I read this file which mislead me into believing GCS was not supported:
> https://app.zencoder.com/docs/faq/transfer - if that's not the case -
> great :)
>
> Range requests would also be an interesting but challenging solution if
> GCS was not supported
>
> I wish there was a "videos" library, similar to "images" that would ease
> video operations :)
>
> On Monday, August 19, 2013 8:38:16 AM UTC+3, Vinny P wrote:
>>
>> On Sun, Aug 18, 2013 at 1:05 PM, Kaan Soral
>>
>>> This issue has been on my mind, let's say a user uploads an 2gb .mov
>>> file, and let's say one decides to use a service like zencoder
>>> The upload to external service and the download from external service
>>> both sound challenging
>>>
>>
>>
>> For Zencoder specifically, you don't need to worry about uploading and
>> downloading from that service. Zencoder starts by downloading the file you
>> specify ( https://app.zencoder.com/docs/api/jobs/create ), so you can
>> specify a url from Cloud Storage, the Blobstore, or a custom URL handler
>> (i.e. to a servlet, script, etc).
>>
>> Zencoder will then upload the completed processed file to a cloud service
>> you specify (
>> https://app.zencoder.com/docs/api/encoding/general-output-settings/url
>> notice
>> that GCS is a supported service in the list).
>>
>>
>> On Sun, Aug 18, 2013 at 1:05 PM, Kaan Soral
>>
>>> Generally it's easy to upload a file to AppEngine, and download a file
>>> from AppEngine, thanks to Blobstore upload/download handlers, however as
>>> far as I know, there aren't any helpers that will do the reverse, upload
>>> file from AppEngine, and download file to AppEngine from an URL
>>>
>>>
>>
>> If you want to discuss upload/download in general (not using Zencoder),
>> then you have a few options. For downloading specifically, there is a
>> "Range" HTTP header you can provide. Basically you can download a single
>> file in multiple separate HTTP requests, and in each request declare a
>> separate byte range to download (for a quick primer, see
>> http://benramsey.com/blog/2008/05/206-partial-content-and-range-requests/
>> ).
>>
>> For uploading, you can upload a file in chunks to most HTTP-compliant
>> services (Apache, nginx, and most other popular servers have built-in
>> support for this).
>>
>> As a side note, this question is better handled on a case-by-case,
>> service-dependent issue. There are several different ways to solve this
>> problem, I'm only enumerating one option as an example.
>>
>>
>>
>> -----------------
>> -Vinny P
>> Technology & Media Advisor
>> Chicago, IL
>>
>> App Engine Code Samples: http://www.learntogoogleit.com
>>
>>
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.