duanjianlu0506 2013-02-02 12:46
浏览 949
已采纳

为文件夹中的一堆mp4视频生成缩略图

I have read this but didnt help too much.

I have a folder called videos and another folder called thumbnails. I have many mp4 videos in video folder and want to catch thumbnails at 4th second to the thumbnails folder using ffmpeg and php.

  1. I am using Wamp server 2.2 on windows whit php 5.3.8 and Apache 2.2.21
  2. I downloaded ffmpeg from FFmpeg Windows Builds section of ffmpeg download page and the static 32 build from this link.
  3. I extracted the 7z file to my website root
    here is my php code:

    $ffmpeg = "includes/ffmpeg/bin/ffmpeg";
    foreach(glob('files/videos/*.mp4') as $pathname){
      $filename = substr($pathname,13,strripos($pathname,'.mp4')-13);
      $thumbnail = 'files/thumbnails/'.$filename.'.jpg';
      exec("ffmpeg -i $pathname -an -y -f mjpeg -ss 00:00:04 -vframes 1 $thumbnail");
    }
    

but nothing happens and the thumbnails folder is always empty!
- How can I find out is ffmpeg installed on my server or not?
- How can I get my script to work?
Please help

  • 写回答

3条回答 默认 最新

  • dpw63348 2014-06-04 11:05
    关注

    try this:

    $ffmpeg = "c:/wamp/www/includes/ffmpeg/bin/ffmpeg";
    $videos = "c:/wamp/www/files/videos/*.mp4";
    $ouput_path = "c:/wamp/www/files/thumbnails/";
    foreach(glob($videos) as $v_file){
        $fname = basename($v_file, ".mp4");
        $thmb = $ouput_path.$fname.'_tn.jpg';
        $cmd = "$ffmpeg -i $v_file -an -y -f mjpeg -ss 00:00:04 -vframes 1 $thmb";
        $stat = system ($cmd);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误