protected function getExecutionCommandAndConversionString(kConversionCommand $conv_cmd, $params_index)
 {
     /*		
     		$frame_rate = 25 ; // frames / second
     		$audio_bitrate = "56k";  //  kbit/s
     		$audio_sampling_rate = 22050; // in Hz
     		$audio_channels = 2; // sterio
     */
     // assume there always will be this index
     $conv_params = @$conv_cmd->conversion_params_list[$params_index];
     /*
       * for now - irrelevant in case of commercial encoder
     		if ( ! $conv_params->video )				$video_audio_str = " -vn "; 			// video none
     		elseif  ( ! $conv_params->audio )		$video_audio_str = " -an ";		// audio node
     		else $video_audio_str = " ";
     */
     /*		
     Usage: cli_encode [OPTION...]
       -i, --in=input file                      infile
       -o, --out=output file                    outfile
       -w, --width=output width                 width
       -h, --height=output height               height
       -d, --deinterlace=deinterlace method     deinterlace
       -k, --kffreq=keyframe frequency          kffreq
       -b, --bitrate=bitrate                    bitrate
     */
     $size_arg = $conv_params->width == -1 ? "" : " -w " . $conv_params->width . " -h " . $conv_params->height;
     $conversion_string = self::ne(" -r ", $conv_params->framerate) . self::ne(" -b ", $conv_params->bitrate) . self::ne(" -k ", $conv_params->gop_size) . self::ne(" -a ", $conv_params->audio_bitrate) . $size_arg . " " . $conv_params->flix_params . " ";
     // I have commented out the audio parameters so we don't decrease the quality - it stays as-is
     $exec_cmd = self::getCmd() . " -i " . $conv_cmd->source_file . " -o " . $conv_cmd->getTargetFileWithSuffix($params_index) . $conversion_string . "  2>&1 >>" . "\"{$conv_cmd->getLogFileWithSuffix($params_index)}\"";
     return array($exec_cmd, $conversion_string);
 }
 private function convertAllFilesInQueue($write_to_log = true)
 {
     @(list($cmd_file, $file_name, $in_proc) = $this->getConversionCommand($write_to_log));
     if ($cmd_file) {
         $conv_cmd = kConversionCommand::fromFile($cmd_file);
         $conv_res = kConversionEngineMgr::convert($conv_cmd, $this->commercial);
         $this->setConversionResult($file_name, $conv_cmd, $conv_res);
         $this->removeConversionCommand($cmd_file);
     }
     $this->removeInProc($in_proc);
 }
 protected function saveConversionCommand()
 {
     if (!$this->conv_cmd) {
         throw new kConversionException("ConversionCommand not yet created");
     }
     // depending on the transcoder - decide on the server's path
     $server_path = $this->server_cmd_path;
     if ($this->conv_cmd->commercial_transcoder && $this->commercial_server_cmd_path) {
         $server_path = $this->commercial_server_cmd_path;
     }
     $cmd_file = $server_path . "/" . basename($this->conv_cmd->source_file);
     $this->conv_cmd->toFile($cmd_file, true);
     return $cmd_file;
 }
 protected function getExecutionCommandAndConversionString(kConversionCommand $conv_cmd, $params_index)
 {
     /*		
     		$frame_rate = 25 ; // frames / second
     		$audio_bitrate = "56";  //  kbit/s
     		$audio_sampling_rate = 22050; // in Hz
     		$audio_channels = 2; // sterio
     */
     // assume there always will be this index
     $conv_params = @$conv_cmd->conversion_params_list[$params_index];
     $size_arg = $conv_params->width == -1 ? " -vf harddup" : " -vf scale={$conv_params->width}:{$conv_params->height},harddup";
     $conversion_string = "" . " -of lavf " . self::ne(" -ofps ", $conv_params->framerate) . " -oac mp3lame " . self::ne(" -lameopts abr:br=", $conv_params->audio_bitrate) . self::ne(" -srate ", $conv_params->audio_sampling_rate);
     if ($conv_params->audio) {
         $conversion_string .= " -ovc lavc " . " -lavcopts vcodec=flv" . self::ne(":vbitrate=", $conv_params->bitrate) . ":mbd=2:mv0:trell:v4mv:cbp:last_pred=3" . self::ne(":keyint=", $conv_params->gop_size) . self::ne(":vqscale=", $conv_params->qscale) . $size_arg;
     } else {
         $conversion_string .= " -ovc frameno ";
     }
     $conversion_string .= $conv_params->mencoder_params;
     // from the new version of mencoder and onwards - no need to use this flag
     //		$conversion_string .= " -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames " ;
     $exec_cmd = self::getCmd() . " \"{$conv_cmd->source_file}\"" . $conversion_string . " -o " . "\"{$conv_cmd->getTargetFileWithSuffix($params_index)}\"" . " 2>>" . "\"{$conv_cmd->getLogFileWithSuffix($params_index)}\"";
     return array($exec_cmd, $conversion_string);
 }
 protected function getExecutionCommandAndConversionString(kConversionCommand $conv_cmd, $params_index)
 {
     /*		
     		$frame_rate = 25 ; // frames / second
     		$audio_bitrate = "56k";  //  kbit/s
     		$audio_sampling_rate = 22050; // in Hz
     		$audio_channels = 2; // sterio
     */
     // assume there always will be this index
     $conv_params = @$conv_cmd->conversion_params_list[$params_index];
     if (!$conv_params->video) {
         $video_audio_str = " -vn ";
     } elseif (!$conv_params->audio) {
         $video_audio_str = " -an ";
     } else {
         $video_audio_str = " ";
     }
     $size_arg = $conv_params->width == -1 ? "" : " -s " . $conv_params->width . "x" . $conv_params->height;
     $conversion_string = self::ne(" -r ", $conv_params->framerate) . self::ne(" -b ", $conv_params->bitrate) . ($conv_params->bitrate ? "k" : "") . self::ne(" -qscale ", $conv_params->qscale) . self::ne(" -g ", $conv_params->gop_size) . $size_arg . self::ne(" -ab ", $conv_params->audio_bitrate) . ($conv_params->audio_bitrate ? "k" : "") . self::ne(" -ar ", $conv_params->audio_sampling_rate) . self::ne(" -ac ", $conv_params->audio_channels) . $video_audio_str . " " . $conv_params->ffmpeg_params . " " . " -y ";
     // I have commented out the audio parameters so we don't decrease the quality - it stays as-is
     $exec_cmd = self::getCmd() . " -i \"" . $conv_cmd->source_file . "\"" . $conversion_string . " \"" . $conv_cmd->getTargetFileWithSuffix($params_index) . "\"  2" . ">>" . "\"{$conv_cmd->getLogFileWithSuffix($params_index)}\"";
     return array($exec_cmd, $conversion_string);
 }