Platform documentation & tutorials

Integrate Panda with your web app

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/initializers/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 name: "h264", created_at: "2011/10/17 12:05:33 +0000", aspect_mode: "letterbox", preset_name: "h264", title: "MP4 (H.264)", updated_at: "2011/10/17 12:05:33 +0000", video_bitrate: 500, audio_bitrate: 128, id: "12345678", extname: ".mp4", upscale: true, cloud_id: "56789012", height: 320, width: 480>]

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.
  • audio_bitrate and video_bitrate set the bitrates of the output video.
  • 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:

Panda::Profile.create!({
  :name => "my new preset",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".mp4",
  :command => "ffmpeg06 -i $input_file$ -acodec libfaac -vcodec libx264 -vpre normal -vb $video_bitrate$k -ab $audio_bitrate$k -y $output_file$"
})

In PHP:

$panda->post('/profiles.json', array(
    'name' => "mp4",
    'width' => 480,
    'height' => 320,
    'extname' => ".mp4",
    'command' => "ffmpeg06 -i $input_file$ -acodec libfaac -vcodec libx264 -vpre normal -vb $video_bitrate$k -ab $audio_bitrate$k -y $output_file$"
));

In php, if you are using double quotes command => " ...\$input\$ ", don’t forget to escape $ or profile variables will be considered as php variables!

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
  • $filters$ : scale your video considering the aspect mode and resolution attributes of your profile.
  • $audio_sample_rate$ : audio sample rate (positive integer, default: 44100)
  • $audio_channels$ : audio channels (positive integer, default: copy)
  • $audio_bitrate$ : audio_bitrate (positive integer)
  • $video_bitrate$ : video_bitrate (positive integer)
  • $max_audio_bitrate$ : audio bitrate threshold
  • $max_video_bitrate$ : video bitrate threshold
  • $fps$ : frame rate (default: copy)

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

Panda::Profile.create!({
  :name => "flv",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".flv",
  :command => "ffmpeg06 -i $input_file$ -ar 44100 -r 29.97 -vb $video_bitrate$k -ab $audio_bitrate$k $resolution$ -y $output_file$"
})  

AVI

Panda::Profile.create!({
  :name => "avi",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".avi",
  :command => "ffmpeg06 -i $input_file$ -vcodec msmpeg4 -acodec libmp3lame -vtag MP43 -ar 44100 -r 29.97 -vb $video_bitrate$k -ab $audio_bitrate$k $resolution$ -y $output_file$"
})    

WMV

Panda::Profile.create!({
  :name => "wmv",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".wmv",
  :command => "ffmpeg06 -i $input_file$ -vcodec wmv2 -acodec wmav2 -ar 44100 -vb $video_bitrate$k -ab $audio_bitrate$k $resolution$ -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

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 : ffmpeg06

Older versions : ffmpeg

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

Mencoder

An other video encoder built from the same code as MPlayer.

command name : mencoder