dreamwind1985 2014-03-24 02:29
浏览 362
已采纳

从视频中提取帧 - PHP-FFMpeg

I am using php ffmpeg in a laravel project, to do multiple things probe, extract frame and encode. I am having an issue when creating a frame from the uploaded video file. This is how the frame is created:

    $video = $ffmpeg->open($destinationPath.'/'.$filename);

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

This is sometimes working and creates the frame but other times is not. I noticed that this bug comes up when I am trying to open a .mov file.

  • 写回答

3条回答 默认 最新

  • douyangcheng4965 2014-03-24 04:02
    关注

    It's possible that your version of ffmpeg does not support the codec that is used in the source video file, and hence it is not able to decompress the video and extract an image.

    You could try processing the file from the command line to see if you can extract an image that way, and ffmpeg may give you some more information on the problem.

    An example command line to extract a png frame from a video file

    ffmpeg -y -ss 30 -i [source_file] -vframes 1 [target_file]
    

    Add -f image2 as an output option if your output name is a variable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?