开发者

how can i use ffmpeg in yii

开发者 https://www.devze.com 2023-02-26 15:13 出处:网络
i want to make thumbnails of videos and convert the videos to flv or mp开发者_JAVA技巧4. i m using windows7 64bit, wamp, yii 1.1.7

i want to make thumbnails of videos and convert the videos to flv or mp开发者_JAVA技巧4. i m using windows7 64bit, wamp, yii 1.1.7

i want to make the thumbnails when the files is uploaded and store them in the thumb dir to be used later

any help, suggestion or alternative


I have done something similar with yii and LAMP. I used the Yii uploadify extension to upload the files. Once upload is completed, I move the file to my desired location in the controller. The PHP controller execs an ffmpeg process to find the duration of the file. It then generates the thumbnail from the middle of the duration with an ffmpeg command. Lastly, I create the ts segmented stream with segmenter and ffmpeg commands to support iOS streaming. All these can be automated.


It's a minimum to run ffmpeg commands:

    public function execFFmpegCommand($command)
  {
    $sCommand = CEnvConfig::$FFmpegPath." ".$command;
    $buffer = CCommon::runExternal($sCommand);

    return $buffer;
  }



  public static function runExternal($cmd)
  {
    $cmd = "{$cmd} 2>&1";
    exec($cmd, $buffer);
    $buffer = implode("\r\n", $buffer);

    return $buffer;
  }

To get stills (thumbnails) from video you need to use FFMPlayer:

            $sCommand = $videoFileURI." -ss ".$pointerTimeCode." -frames ".$frames." -vo jpeg:quality=100:optimize=0:smooth=0:noprogressive:nobaseline";

or

            $sCommand = $videoFileURI." -ss ".$pointerTimeCode." -frames ".$frames." -vo png:z=0";

  public function execMPlayerCommand($command)
  {
    $sCommand = CEnvConfig::$MPlayerPath." -nosound ".$command;
    $buffer = CCommon::runExternal($sCommand);

    return $buffer;
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消