You are here

public function video_zencoder::preset_settings in Video 6.5

Overrides video_transcoder::preset_settings

File

plugins/video_zencoder/transcoders/video_zencoder.inc, line 224
Transcoder class file to handle Zencoder settings and conversions.

Class

video_zencoder

Code

public function preset_settings(&$form_state, video_preset $preset) {
  $settings = $preset
    ->getSettings();
  $form = array();
  $form['help'] = array(
    '#type' => 'item',
    '#title' => t('Note'),
    '#value' => t('Take a look at the <a href="@zencoder-api">Zencoder API documentation</a> for more information about these configuration options.
It is usually not necessary to change these settings as Zencoder has sensible defaults for each output format.', array(
      '@zencoder-api' => 'https://app.zencoder.com/docs/api/encoding',
    )),
  );
  $onetofive = array(
    '' => '',
  ) + array_combine(range(1, 5), range(1, 5));
  $truefalse = array(
    '' => '',
    'true' => t('Yes'),
    'false' => t('No'),
  );
  $videocodecs = array(
    '',
    'h264',
    'mpeg4',
    'theora',
    'vp6',
    'vp8',
    'wmv',
  );
  $audiocodecs = array(
    '',
    'aac',
    'amr',
    'mp3',
    'vorbis',
    'wma',
  );
  $audiochannels = array(
    '',
    1,
    2,
  );
  $form['quality'] = array(
    '#type' => 'select',
    '#title' => t('Video quality'),
    '#default_value' => isset($settings['quality']) ? $settings['quality'] : '',
    '#options' => $onetofive,
  );
  $form['audio_quality'] = array(
    '#type' => 'select',
    '#title' => t('Audio quality'),
    '#default_value' => isset($settings['audio_quality']) ? $settings['audio_quality'] : '',
    '#options' => $onetofive,
  );
  $form['speed'] = array(
    '#type' => 'select',
    '#title' => t('Transcoding speed'),
    '#default_value' => isset($settings['speed']) ? $settings['speed'] : '',
    '#options' => $onetofive,
  );
  $form['upscale'] = array(
    '#type' => 'select',
    '#title' => t('Allow upscaling'),
    '#default_value' => isset($settings['upscale']) ? $settings['upscale'] : '',
    '#options' => $truefalse,
  );
  $form['frame_rate'] = array(
    '#type' => 'textfield',
    '#title' => t('Frame rate'),
    '#default_value' => isset($settings['frame_rate']) ? $settings['frame_rate'] : '',
    '#maxlength' => 15,
    '#size' => 15,
  );
  $form['max_frame_rate'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum frame rate'),
    '#default_value' => isset($settings['max_frame_rate']) ? $settings['max_frame_rate'] : '',
    '#maxlength' => 15,
    '#size' => 15,
  );
  $form['video_codec'] = array(
    '#type' => 'select',
    '#title' => t('Video codec'),
    '#default_value' => isset($settings['video_codec']) ? $settings['video_codec'] : '',
    '#options' => array_combine($videocodecs, $videocodecs),
  );
  $form['audio_codec'] = array(
    '#type' => 'select',
    '#title' => t('Audio codec'),
    '#default_value' => isset($settings['audio_codec']) ? $settings['audio_codec'] : '',
    '#options' => array_combine($audiocodecs, $audiocodecs),
  );
  $form['video_bitrate'] = array(
    '#type' => 'textfield',
    '#title' => t('Video bit rate'),
    '#default_value' => isset($settings['video_bitrate']) ? $settings['video_bitrate'] : '',
    '#field_suffix' => t('kbps'),
    '#maxlength' => 15,
    '#size' => 15,
  );
  $form['audio_bitrate'] = array(
    '#type' => 'textfield',
    '#title' => t('Audio bit rate'),
    '#default_value' => isset($settings['audio_bitrate']) ? $settings['audio_bitrate'] : '',
    '#field_suffix' => t('kbps'),
    '#maxlength' => 15,
    '#size' => 15,
  );
  $form['audio_sample_rate'] = array(
    '#type' => 'textfield',
    '#title' => t('Audio sample rate'),
    '#default_value' => isset($settings['audio_sample_rate']) ? $settings['audio_sample_rate'] : '',
    '#field_suffix' => t('Hz'),
    '#maxlength' => 15,
    '#size' => 15,
  );
  $form['audio_channels'] = array(
    '#type' => 'select',
    '#title' => t('Number of audio channels'),
    '#default_value' => isset($settings['audio_channels']) ? $settings['audio_channels'] : '',
    '#options' => array_combine($audiochannels, $audiochannels),
  );
  $as = '';
  if (isset($settings['additional_settings']) && is_array($settings['additional_settings'])) {
    $as = $this
      ->settingsArrayToString($settings['additional_settings']);
  }
  $form['additional_settings'] = array(
    '#type' => 'textarea',
    '#title' => t('Additional settings'),
    '#default_value' => $as,
    '#rows' => 5,
    '#description' => '<p>' . t('Enter any other <a href="@zencoder-api">Zencoder encoding settings</a> in this text area. Enter each setting on a separate line and separate the setting name (case sensitive) and the value with a colon. To create a nested structure, use two spaces. Malformed settings will be removed.', array(
      '@zencoder-api' => 'https://app.zencoder.com/docs/api/encoding',
    )) . '</p>' . '<p>' . t('Example:') . '</p>' . '<blockquote><pre>clip_length: 00:00:10.0
watermarks:
  url: http://example.com/watermark.gif
  y: 10
  x: 10</pre></blockquote>',
    '#wysiwyg' => FALSE,
  );
  return $form;
}