Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have seen questions like this being asked in the past but they all seem to point to using ffmpeg, however I am currently using 000Webhost for hosting my website before I make it live and it appears that they do not support it. So I am wondering is there any other way of generating a thumbnail without using ffmpeg? For clarification this is how videos are uploaded currently:

    <form action='videoUpload.php' method='post' enctype="multipart/form-data"> 

<input type='hidden' name='id' value='<?php echo $row['videoID'];?>'>
<p><label>Title</label><br />

<input type='text' name='videoTitle' required value='<?php if(isset($error)){ echo $_POST['videoTitle'];}?>'></p>

<p><label>Video</label><br />

<input type="file" name='video' id="video" required value='<?php if(isset($error)){ echo $_POST['video'];}?>'></p>

<input type="hidden" name='videoDuration' id="videoDuration" required value='<?php if(isset($error)){ echo $_POST['videoDuration'];}?>'></p>

        <div id="duration" name="duration">Please choose a video</div>
          <script src="duration.js"></script>

<p><input type='submit' name='submit' id='submit' value='Submit'></p>

videoUpload.php -

  if(isset($_POST["submit"])) {


    //collect form data

    extract($_POST);


    $allowedExts = array("ogg", "mp4", "wma");
    $extension = pathinfo($_FILES['video']['name'], PATHINFO_EXTENSION);

    if ((($_FILES["video"]["type"] == "video/mp4")
        || ($_FILES["video"]["type"] == "video/ogg")
        || ($_FILES["video"]["type"] == "video/wma")

        && ($_FILES["video"]["size"] < 16000000 )
        && in_array($extension, $allowedExts))){ //comma missing


        if ($_FILES["video"]["error"] > 0)
        {
            echo "Return Code: " . $_FILES["video"]["error"] . "<br />";
        }


        else
        {
            echo "Upload: " . $_FILES["video"]["name"] . "<br />";
            echo "Type: " . $_FILES["video"]["type"] . "<br />";
            echo "Size: " . ($_FILES["video"]["size"] / 1024) . " Kb<br />";
            echo "Temp file: " . $_FILES["video"]["tmp_name"] . "<br />";
           $upload =  $_FILES["video"]["name"];

            if (file_exists("../videos/" . $_FILES["video"]["name"]))
            {
                echo $_FILES["video"]["name"] . " already exists. ";
            }
            else
            {
                move_uploaded_file($_FILES["video"]["tmp_name"],
                    "../videos/" . $_FILES["video"]["name"]);
                echo "Stored in: " . "../videos/" . $_FILES["video"]["name"];
            }
        }

    }else{
        echo "Invalid file";
    }

            try {



                //insert into database

                $stmt = $dbconn->prepare('INSERT INTO videos (videotitle,video,editedBy,duration) VALUES (:videoTitle, :video, :editedBy, :duration)') ;

                $stmt->execute(array(

                    ':videoTitle' => $videoTitle,

                    ':video' => $upload,

                                       ':editedBy' => "admin",
                    
                                          ':duration' => $videoDuration
                

                ));



                //redirect to videos page

                header('Location: index.php');

                exit;



            } catch(PDOException $e) {

                echo $e->getMessage();

            }

}
?>

Now I am aware that using extract is considered unsafe and I will be changing that but is there anyway I can expand on what I have here to generate a thumbnail of the video that is being uploaded without ffmpeg? I will also be adding a thumbnail category to the database.

Thanks in advance


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...