开发者

video uploading using PHP

开发者 https://www.devze.com 2023-04-12 02:50 出处:网络
I am using the following code for uploading videos $img1 = $_FILES[\'video\'][\'name\']; if (!empty($img1)) {

I am using the following code for uploading videos

    $img1 = $_FILES['video']['name'];

    if (!empty($img1)) {

        $fname = $_FILES['video']['name'];

        $img_name1 = "video/" . $fname;

        if(move_uploaded_file($_FILES['video']['tmp_name'], $img_name1)){
            $new_name = ShowFileName($fname);

             $output = 'video/'.$new_name.'.flv';

             $command = "$ffmpegpath  -i $img_name1  -s 486x368 -b 400kb  -ac 1 -ar 44100 -r 25 -s 320x240 -f flv $output";
             $command = $ffmpegpath.' -i'.$img_name1.' -s 486x368 -b 400kb  -ac 1 -ar 44100 -r 25 -qmin 3 -qmax 5 -y '.$output;
             exec($command);

             $thumb_dir = 'video_thumbs/';

             $thumb = $new_name.'jpg';

             exec($ffmpegpath .' -i '.$img_name1.' -an -y -f mjpeg -ss 0.05 -vframes 1 '.$thumb_dir.$img_name1);
             unlink($img_name1);
        }
     }

It is working properly.ie Successfully moving video into videos folder and insering video name to database table. But the problem is related to the thumb image of this video. Thumb name was开发者_如何学编程 insert into database but the image wasn't uploding to the video_thumb folder....... please help me....


The only problem I see is with the file name in the ffmpeg command line. If it contains special chars you should use escapeshellarg(). php function escapeshellarg

0

精彩评论

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

关注公众号