private static function evaluateTargetVideoFramerate(KDLVideoData $source, KDLVideoData $target)
 {
     /*
      * Frame Rate - If the flavor fps is zero, evaluate it from the source and
      * the constants theshold.
      */
     if ($target->_frameRate == 0) {
         $target->_frameRate = $source->_frameRate;
         if ($target->_frameRate > KDLConstants::MaxFramerate) {
             $target->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TruncatingFramerate, KDLConstants::MaxFramerate, $target->_frameRate);
             $target->_frameRate = $target->_frameRate == 50 ? 25 : KDLConstants::MaxFramerate;
         } else {
             if ($target->_frameRate == 0 && $source->IsFormatOf(array("h.263"))) {
                 $target->_frameRate = 24;
             }
         }
         /*
          * For frame rates to comply w/HLS (relevant for low br 110 and 200 kfps)
          * 
          * 110 - either 10 (for ~30fps) or 8 (for 24/25fps)
          * 200 - for 24 to 30fps, take half of the original targetFR
          * otherwise - keep the targetFR (the targetFR<24)
          */
         if ($target->_isFrameRateForLowBrAppleHls) {
             if ($target->_bitRate <= 110) {
                 $target->_frameRate = $target->_frameRate >= 29.97 ? 10 : 8;
             } else {
                 if ($target->_bitRate <= 200 && round($target->_frameRate) >= 24) {
                     $target->_frameRate = round($target->_frameRate / 2, 2);
                 }
             }
         }
     }
     /*
      * MPEG2 constraint - target fps should be at least 20
      */
     if ($target->_id == KDLVideoTarget::MPEG2) {
         $target->_frameRate = max(20, $target->_frameRate);
     }
     return $target->_frameRate;
 }
Пример #2
0
 private static function evaluateTargetVideoFramerate(KDLVideoData $source, KDLVideoData $target)
 {
     /*
      * Frame Rate - If the flavor fps is zero, evaluate it from the source and
      * the constants theshold.
      */
     if ($target->_frameRate == 0) {
         $target->_frameRate = $source->_frameRate;
         if (isset($target->_maxFrameRate) && $target->_maxFrameRate > 0) {
             $maxFR = $target->_maxFrameRate;
         } else {
             $maxFR = KDLConstants::MaxFramerate;
         }
         if ($target->_frameRate > $maxFR) {
             $target->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TruncatingFramerate, $maxFR, $target->_frameRate);
             $target->_frameRate = $target->_frameRate == 50 ? 25 : $maxFR;
         } else {
             if ($target->_frameRate == 0 && $source->IsFormatOf(array("h.263", "h263", "sorenson spark", "vp6"))) {
                 $target->_frameRate = 24;
             }
         }
         /*
          * For frame rates to comply w/HLS (relevant for low br 110 and 200 kfps)
          * 
          * 110 - either 10 (for ~30fps) or 8 (for 24/25fps)
          * 200 - for 24 to 30fps, take half of the original targetFR
          * otherwise - keep the targetFR (the targetFR<24)
          */
         if ($target->_isFrameRateForLowBrAppleHls) {
             if ($target->_bitRate <= 110) {
                 $target->_frameRate = $target->_frameRate >= 29.97 ? 10 : 8;
             } else {
                 if ($target->_bitRate <= 200 && round($target->_frameRate) >= 24) {
                     $target->_frameRate = round($target->_frameRate / 2, 2);
                 }
             }
         }
     }
     /*
      * MPEG2 constraint - target fps should be at least 20
      */
     if ($target->_id == KDLVideoTarget::MPEG2) {
         $target->_frameRate = max(20, $target->_frameRate);
     }
     //Frame rate smaller than 1 causes Memory Fatal Error so in this case set it to 1
     //Changed the setting to force the frame rate from 1 to 5 since we noticed in some cases this causes mp4 h264 assets to played unusually like in a fast forward mode
     if ($target->_frameRate > 0 && $target->_frameRate < 1) {
         $target->_frameRate = 5;
     }
     return $target->_frameRate;
 }