2017-07-12 12 views
0

ffmpegを使ってビデオからサムネイルを取得しました。今すぐサムネイルがルートフォルダのプロジェクトディレクトリに保存されていますが、そのフォルダを特定のフォルダに移動します。どうやってするか?私は、次を使用してサムネイルを得ました...サムネイルを移動してcodeigniterのフォルダを指定する方法

<!DOCTYPE html> 
<html> 
    <body> 
    <form action="upld.php" method="post" enctype="multipart/form-data"> 
     Select image to upload: 
     <input type="file" name="fileToUpload" id="fileToUpload"> 
     <input type="submit" value="Upload" name="submit"> 
    </form> 

    <?php 
     if(isset($_POST['submit'])){ 
     $ffmpeg = "C:\\ffmpeg\\bin\\ffmpeg"; 
     $videoFile = $_FILES["fileToUpload"]["tmp_name"]; 
     $imageFile = "4.jpg"; 
     $size = "120*90"; 
     $getFromSecond = 5; 
     $cmd = "$ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile"; 
     if(!shell_exec($cmd)){ 
      echo "Thumbnail created"; 
     } else { 
      echo "error while Thumbnail creating"; 
     } 
     } 
    ?> 
</body> 
</html> 

答えて

0

ユーザーCodeIgniterの画像操作クラス。ここでドキュメントを見つけることができます。 https://www.codeigniter.com/userguide3/libraries/image_lib.html

$filename = $this->input->post('fileToUpload'); 
$source_path = FCPATH . '/uploads/source/tmp/' . $filename; 
$target_path = FCPATH. '/uploads/thumb/'; 
$config_manip = array(
    'image_library' => 'gd2', 
    'source_image' => $source_path, 
    'new_image' => $target_path, 
    'maintain_ratio' => TRUE, 
    'create_thumb' => TRUE, 
    'thumb_marker' => '_thumb', 
    'width' => 150, 
    'height' => 150 
); 
$this->load->library('image_lib', $config_manip); 
if (!$this->image_lib->resize()) { 
    echo $this->image_lib->display_errors(); 
} 
// clear // 
$this->image_lib->clear(); 

これは役に立ちます。

関連する問題