Advanced Profiles

Panda provides complete control over the commands used to convert video. You can log in to your Panda account over the web and choose from our presets, or you can use the API to access the bare metal.

The examples use panda_gem and panda_client_php. The ruby examples can be run from script/console, so that config/initalizers/panda.rb will connect Panda for you.

Seeing your profiles

This will list all the profiles that exist for the cloud you’re connected to:

>> Panda::Profile.all
=> [#<Panda::Profile:0x23b40a0 @errors=[], @changed_attributes={}, @attributes={"preset_name"=>"h264", "name"=>nil, "updated_at"=>"2010/07/09 10:42:41 +0000", "title"=>"MP4 (H.264)", "id"=>"89fbdfbb16cb8a2961d5", "extname"=>".mp4", "cloud_id"=>"ae661bf5b9a868df9ad", "height"=>320, "width"=>480, "created_at"=>"2010/07/09 10:42:41 +0000"}>]

Creating a profile

All of the fields below are required when creating an advanced profile.

  • name is a unique (to this cloud) name used to identify your profile.
  • width and height set what the dimensions of the output video will be.
  • extname is the file extension, beginning with ’.’, of the output video.
  • command is the video conversion command (in most cases an ffmpeg command).

You can also specify an optional title, which is a non-unique description. An ID will be created for you; older API implementations use this instead of the Name.

Panda provides full access to a suite of powerful video conversion tools. These tools can be used together in one profile to output a variety of formats. To execute multiple commands in one profile, you must separate each with a \n (newline) or ; (semicolon).

Let’s create a custom h.264 profile. Using the Ruby gem:

profile = Panda::Profile.create(
  :name => "my new preset",
  :width => "480",
  :height => "320",
  :extname => ".mp4",
  :command => "ffmpeg -i $input_file$ -vcodec libx264 -acodec libfaac -ab 128k -ar 22050 -ac 2 -b 256k -flags +loop -cmp +chroma -partitions 0 -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 $resolution_and_padding$ -y $record_id$_noqt.mp4\nqt-faststart $record_id$_noqt.mp4 $output_file$"
)

In PHP:

$panda->post('/profiles.json', array(
    'name' => "mp4",
    'width' => 480,
    'height' => 320,
    'extname' => ".mp4",
    'command' => "ffmpeg -i $input_file$ -vcodec libx264 -acodec libfaac -ab 128k -ar 22050 -ac 2 -b 256k -flags +loop -cmp +chroma -partitions 0 -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 $resolution_and_padding$ -y $record_id$_noqt.mp4\nqt-faststart $record_id$_noqt.mp4 $output_file$"));

Variables

Panda provides variables you can use in your commands:

  • $input_file$ : input filename
  • $output_file$ : output filename
  • $width$ : width defined in your profile
  • $height$ : height defined in your profile
  • $record_id$ : Encoding ID
  • $resolution_and_padding$ : scale and letterbox your video (recommended)

Useful profiles

You may not find a preset for your exactly need but the following examples should help you to encode videos into some popular formats.

FLV

profile = Panda::Profile.create(
  :name => "flv",
  :width => "480",
  :height => "320",
  :extname => ".flv",
  :command => "ffmpeg -i $input_file$ -ar 44100 -r 29.97 $resolution_and_padding$ -y $output_file$"
)  

AVI

profile = Panda::Profile.create(
  :name => "avi",
  :width => "480",
  :height => "320",
  :extname => ".avi",
  :command => "ffmpeg -i $input_file$ -vcodec msmpeg4 -vb 2560000 -vtag MP43 -acodec libmp3lame -ab 96000 -ar 44100 -r 29.97 $resolution_and_padding$ -y $output_file$"
)    

WMV

profile = Panda::Profile.create(
  :name => "wmv",
  :width => "480",
  :height => "320",
  :extname => ".wmv",
  :command => "ffmpeg -i $input_file$ -b 1000k -vcodec wmv2 -ar 44100 -ab 56000 -ac 2 -acodec wmav2 $resolution_and_padding$ -y $output_file$"
)      

HandBrakeCLI

HandBrakeCLI is now available as an experimental tool. It comes with some presets to help you creating simple profiles.

Here is a profile using HandBrakeCLI

profile = Panda::Profile.create(
  :name => "iPhone and iPod",
  :width => "480",
  :height => "320",
  :extname => ".mp4",
  :command => "HandBrakeCLI -i $input_file$ -o $output_file$ $resolution$ --preset=\"iPhone & iPod Touch\""
)  

Available conversion tools

Here is the list of conversion tools available in Panda.

FFMpeg

See http://ffmpeg.org

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.

We provide a recent ffmpeg, compiled from the svn repository with as many codecs as we could get our hands on (See full list of Supported File Formats and Codecs). If for some reason we are missing one you require, please let us know via the Support Forum.

command name : ffmpeg

FFMpeg2Theora

See http://v2v.cc/~j/ffmpeg2theora/

command name : ffmpeg2theora

segmenter

Segmenter (h264 segmented streaming for Apple devices).

See http://bit.ly/116naF

command name : segmenter

qt-faststart

See http://bit.ly/a1bg5d

command name : qt-faststart

yamdi

See http://yamdi.sourceforge.net/

command name : yamdi

HandBrakeCLI

See http://trac.handbrake.fr/wiki/CLIGuide

command name : HandBrakeCLI

Lame

A high quality MPEG Audio Layer III (MP3) encoder.

command name : lame

Other tools coming soon

  • mencoder
  • mp4box
  • mp4creator