示例#1
0
 /**
  * actionUpdate
  *
  * POST, PATCH /resource/{id} -> actionUpdate -> Update the resource
  * (convert video from flv to mp4)
  *
  * @param $id
  * @return bool|String
  */
 public function actionUpdate($id)
 {
     try {
         $video = Video::findVideo($id, $this->currentUserId());
         if (!$video) {
             throw new ActionUpdateException("Video not found");
         }
         if (Video::isConverted($id)) {
             throw new ActionUpdateException("Video already converted");
         }
         if (!Video::canProcess()) {
             throw new ActionUpdateException("Simultaneous processing files limit exceeded");
         }
         Video::beforeConvertation($id);
         Yii::$app->ffmpeg->convert($video->fileName, $video->newName);
         Video::afterConvertation($id);
     } catch (ActionCreateException $e) {
         return $e->getMessage();
     }
     return true;
 }