2013-02-02 12:46
浏览 924


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

图片转代码服务由CSDN问答提供 功能建议

我已阅读 this 但没有太多帮助。

我有一个名为的文件夹 视频以及另一个名为缩略图的文件夹。 我在视频文件夹中有很多mp4视频,并希望使用ffmpeg和php在第4秒捕捉到缩略图文件夹中的缩略图。

  1. 我在windows whit php 5.3.8和Apache 2.2.21上使用Wamp服务器2.2
  2. 我从下载了ffmpeg ffmpeg下载页面的FFmpeg Windows Builds 部分和来自这个链接。
  3. 我将7z文件解压缩到我的网站root

      $ ffmpeg =“包括 /ffmpeg/bin/ffmpeg";nnachach(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“); 


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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条)

相关推荐 更多相似问题