Skip to main content

New features: custom output paths & iOS update

Today we have deployed some very interesting improvements on our platform. Let’s review them all.

Custom output filename paths (store your files in subdirectories!)

Many of you have requested a way to store video inside folders instead of having everything in the root of your bucket. We think we found a nice solution to solve this problem.

When you upload a video there is now a new optional attribute called path_format. It enables you to specify destination and name of a video and it’s encodings.

The path_format variable is a string representing the complete video path without the extension name. It can be constructed using some provided keywords.

The better way to explain this is with a few examples (the following examples use the Panda Rubygem version 1.1.0)

Panda::Video.create(:file => ..., :path_format => "my-example/:id")

This will save the output files inside the folder “my-example/” and the ID will be used as part of the filename. Here is the example of the generated files after having encoded the video.

http://yourbucket.s3.amazonaws.com/my-example/_video_id.flv
http://yourbucket.s3.amazonaws.com/my-example/_video_id_1.jpg
http://yourbucket.s3.amazonaws.com/my-example/_encoding_id.mp4
http://yourbucket.s3.amazonaws.com/my-example/_encoding_id_1.jpg

http://yourbucket.s3.amazonaws.com/my-example/_encoding_id_7.jpg

Panda::Video.create(:file => ..., :path_format => "my-example/:id/my_file_name")

This will save the output files inside the folder “my-example/id/” and the text my_file_name will be used as part of the filename.

http://yourbucket.s3.amazonaws.com/my-example/_video_id/my_file_name.flv
http://yourbucket.s3.amazonaws.com/my-example/_video_id/my_file_name_1.jpg
http://yourbucket.s3.amazonaws.com/my-example/_encoding_id/my_file_name.mp4
http://yourbucket.s3.amazonaws.com/my-example/_encoding_id/my_file_name_1.jpg

http://yourbucket.s3.amazonaws.com/my-example/_encoding_id/my_file_name_7.jpg

The API provides some other keywords.

:id         => The id of the video or the encoding.
:video_id   => The id of the video.
:original   => The original filename of the uploaded video
:date       => The date the video was uploaded. ('2009-10-09')
:profile    => The profile name used by the encoding ('original' is used when the file is the original video)
:type       => The video type, 'original' or 'encodings'
:resolution => The resolution of the video or the encoding. ('480x340')

How should I construct the path_format?

You should take care with the way you construct the path_format. It allows you to save your videos in a very simple a flexible way but it’s up to you ensure uniqueness of the filenames inside your bucket.

If you create a video with :path_format => "my-panda-video" all videos will be called my-panda-video with a different extension (my-panda-video.flv, panda-panda-video.mp4). But this should not be done, because if your original file has the same extension as your encoding profile, the encoding output will override the original video.

SOME TIPS

The presence of :id always ensures uniqueness.

Using :video_id does not ensure uniqueness.

e.g. “folder/:video/:type/my-video” works if you don’t have two profiles generating two different encoding having the same extension name. Otherwise one is overwritten.

Using :video_id and :profile together does ensure the uniqueness if you add profile name to all your profiles.

e.g. “folder/:video_id/:profile/my-video”

All other keywords are not unique.

How do I download my encodings now?

The API returns a new variable when asking for the properties of a video or encoding called “path”

GET /encodings/12323.json
{
  "id":"1234567890"
  "extname": ".mp4"
  "path": "1234567890"
}

You can now construct the complete path this way (this example is in Ruby):

encoding = get('/encodings/12323.json')
encoding_url = encoding['path'] + encoding['extname']
screenshot_url = encoding['path'] + "_4.jpg"

If your are Using the Panda Rubygem version 1.1.0 or above, you will be able to get your encodings as before.

encoding = Panda::Encoding.find '12323'
encoding.url
encoding.screenshots[3]

New iOS (iPhone and iPad) preset

The iOS preset has been re-worked and improved to make it easier to use. There are two main changes.

  1. We will no longer upload the non-segmented .ts files in your bucket.
  2. The extname of your encodings is now correctly set to .m3u8 instead of .ts. This means that from now on the Panda Gem and other client libraries will return the correct url for this profile.

Identify profiles by name instead of ID

We have found it very convenient to be able to specify which encoding to use when sending a video. Now you can do it even more easily by specifying the profile name instead of its ID.

For example:

Panda::Video.create(:file => ..., :profiles => 'h264,my-custom-name')
video.encodings.create(:profile_name => 'ogg')

We hope you find these features useful, and look forward to showing you what else we’ve got in development shortly.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.