视频上传时如何创建缩略图? [php / codeigniter] [英] how to create a thumbnail, at the time of video upload ? [php / codeigniter]

查看:121
本文介绍了视频上传时如何创建缩略图? [php / codeigniter]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为上传的视频创建缩略图。在视频本身上传时搜索最简单的生成缩略图的方法。我认为,如果有人提供代码而不使用ffmpeg将会为我省命。因为我在Windows Wamp或其他任何替代程序上运行我的代码,也谢谢您。

I am trying to create a thumbnail for my uploading video. searching for easiest way to generate thumbnail at the time of video upload itself. i think if some provide the code without using ffmpeg will be life saving for me. because i'm running my code on windows wamp or any other alternative welcomed too thank you.

我的真实代码在CodeIgniter中,无法弄清楚该怎么做

my real code is in CodeIgniter, not able to figure out how to do it.

$postname = $this->input->post('post-name');

            $configVideo['upload_path'] = './video';
            $configVideo['max_size'] = '1000000024';
            $configVideo['allowed_types'] = 'avi|flv|wmv|mp4';
            $configVideo['overwrite'] = TRUE;
            $configVideo['remove_spaces'] = TRUE;
            $ext = get_mime_by_extension($_FILES['video']['name']);
            $video_name = str_replace(' ', '_', $postname);
            $configVideo['file_name'] = $video_name;

            $this->load->library('upload', $configVideo);
            $this->upload->initialize($configVideo);

            if (!$this->upload->do_upload('video')) {

                $msg = $this->upload->display_errors();
                $this->session->set_flashdata('error', $msg);


            } else {
                $videoDetails = $this->upload->data(); 


推荐答案

我认为您将很难找到解决方案用于在开源世界中不使用ffmpeg的视频操作。即使您可以找到一些专门用于缩略图的内容,您将来也可能会想要做其他事情,例如压缩,添加音轨等,而ffpmeg将会很有用。

I think you will find it hard to get a solution for video manipulation that does not use ffmpeg in the open source world. Even if you can find something specifically for thumbnails, you may find in future you want to do other things like compression, add audio tracks etc for which ffpmeg will be useful.

好消息是,在Windows服务器上并使用PHP的ffmpeg是常见的解决方案,并且有一个使用良好且受支持的PHP ffmpeg库,您可以使用:

The good news is that ffmpeg on a windows server and using PHP is a common solution, and there is a well used and supported PHP ffmpeg library you can use:

  • https://github.com/PHP-FFMpeg/PHP-FFMpeg

这包括指向一组ffmpeg构建的链接,您可以将其下载到Windows服务器上,因此无需

This includes a link to a set of ffmpeg builds that you can download onto your windows server, so you don't need to build ffmpeg yourself.

看看帧方法来捕获在视频的特定时间用作缩略图的静止图像:

Take a look at the 'frame' method to capture a still to use as a thumbnail at a particular time in the video:

$video
    ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
    ->save('frame.jpg');

这篇关于视频上传时如何创建缩略图? [php / codeigniter]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆