ffmpeg从视频错误中获取图像或缩略图 [英] ffmpeg Getting image or thumbnail from video error

查看:791
本文介绍了ffmpeg从视频错误中获取图像或缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的网站,人们上传视频,所以我想从上传的视频生成一个简单的缩略图。我已经尝试了从一些网站,但我没有使命令运行没有问题的每一个技巧和方法。

  $ video = $ _FILES ['vpopupdropin'] [tmp_name]; 
$ ffmpeg =C:\\Ffmpeg\\ffmpeg-20130605-git-3289670-win64-static\\bin;
$ image =manu.jpg;
$ second = 12;
$ size =150x90;
$ command =$ ffmpeg -i $ video -an -ss $ second -s $ size -vcodec mjpeg $ image;
echo $ command;
shell_exec($ command);

if(shell_exec($ command)){
echo'okay';
echo'< img src ='。$ image。'/>';
}

else {
echo'Problem';
}

我回显了PHP的命令,这是我得到的:
C:\Ffmpeg\ffmpeg-20130605-git-3289670-win64-static\bin -i C:\xampp\tmp\php27F1.tmp -an -ss 12 -s 150x90 -vcodec mjpeg manu .jpg问题



所以我把上面的命令输入Cmd并得到了这个错误



[image2 @ 00000000000000003d87580]无法打开文件:manu.jpg
av_interleaved_write_frame():输入/输出错误。上传的文件很好地传输到iam保存它,并在网站上播放,意味着文件没有损坏。但缩略图命令似乎失败,我甚至检查了本网站上的其他问题,但我似乎无法得到正确的解决方案。在命令中的路径是正确的,我已经验证,至少

解决方案

你没有给ffmpeg一个名字:-)所以您尝试执行 \\bin 文件夹!

  $ ffmpeg =C:\\Ffmpeg\\ffmpeg-20130605-git-3289670-win64-static\\bin; 

您忘记了ffmpeg.exe

  $ ffmpeg =C:\\Ffmpeg\\ffmpeg-20130605-git-3289670-win64-static\\bin\\ffmpeg; 

我使用以下命令执行.avi

  ffmpeg -i Echo2012.avi -r 1 -s 1024x576 -f image2 -vframes 1 foo-001.jpg 

不要执行命令两次!

  $ command = $ ffmpeg -i $ video -an -ss $ second -s $ size -vcodec mjpeg $ image; 
echo $ command;
shell_exec($ command);

if(shell_exec($ command)){

p>

您的命令字符串:

  ffmpeg -i upload.tmp- ss 12 -s 150x90 -vcodec mjpeg manu.jpg 




  • -vcodec编解码器(输出):设置视频输出编解码器。它是一个输出视频的开关。您希望输出图片。

  • -an:您可以禁用音频流。

  • -ss:position(input / output)当用作输入选项(<-strong> before -i )之前,寻找在此输入文件中的位置。






我的命令字符串:

  ffmpeg -i Echo2012.avi -r 1 -s 1024x576 -f image2 -vframes 1 foo-001.jpg 




  • -r:fps(每个流的输入/输出)。设置帧速率(Hz值,分数或缩写)。

    作为输入选项,忽略存储在文件中的任何时间戳,而是生成假设帧速率为fps的时间戳。

  • -f image2:强制输出文件格式 image2

  • -vframes number(output):设置要记录的视频帧数。


i have a simple site on which people upload videos, so i want to generate a simple thumbnail from an uploaded video. i have tried every trick and way to do this from a number of websites but i am failing to make the command run without problems.

$video = $_FILES['vpopupdropin']["tmp_name"];
    $ffmpeg = "C:\\Ffmpeg\\ffmpeg-20130605-git-3289670-win64-static\\bin";
    $image = "manu.jpg";
    $second = 12;
    $size = "150x90";
$command = "$ffmpeg -i $video -an -ss $second -s $size -vcodec mjpeg      $image";
echo $command;
    shell_exec($command);

    if(shell_exec($command)){
        echo 'okay';
        echo '<img src="'.$image.'"/ >';
        }

    else{
        echo ' Problem';
        }

i Echoed the the command from PHP and this is what i got: C:\Ffmpeg\ffmpeg-20130605-git-3289670-win64-static\bin -i C:\xampp\tmp\php27F1.tmp -an -ss 12 -s 150x90 -vcodec mjpeg manu.jpg Problem

so i took the Command above and entered it in Cmd and got this error

[image2 @ 00000000000000003d87580] Could not open file : manu.jpg av_interleaved_write_frame(): Input/output error. the uploaded file transfers well to where iam saving it and plays well on the site meaning the file is not corrupt. but the thumbnail command seems to fail, i have even checked the other questions on this site but i seem to fail to get the right solution. the paths in the Command are correct and i have verified that at least

解决方案

You did not give ffmpeg a name :-) So you tried to execute a \\bin folder !

$ffmpeg = "C:\\Ffmpeg\\ffmpeg-20130605-git-3289670-win64-static\\bin";

you forget ffmpeg.exe

$ffmpeg = "C:\\Ffmpeg\\ffmpeg-20130605-git-3289670-win64-static\\bin\\ffmpeg";

I do it for a .avi with following command

ffmpeg -i Echo2012.avi -r 1 -s 1024x576 -f image2 -vframes 1 foo-001.jpg

Don't execute your command twice !

$command = "$ffmpeg -i $video -an -ss $second -s $size -vcodec mjpeg      $image";
echo $command;
shell_exec($command);

    if(shell_exec($command)){

EDIT :

your command string :

ffmpeg -i upload.tmp -an -ss 12 -s 150x90 -vcodec mjpeg     manu.jpg

  • -vcodec codec (output) : Set the video output codec. It's a switch for a output video. You want as output an image.
  • -an : You can disable Audio stream. You don't need Audio for an image.
  • -ss : position (input/output) When used as an input option (before -i), seeks in this input file to position.

my command string :

ffmpeg -i Echo2012.avi -r 1 -s 1024x576 -f image2 -vframes 1 foo-001.jpg

  • -r : fps (input/output,per-stream) . Set frame rate (Hz value, fraction or abbreviation).
    As an input option, ignore any timestamps stored in the file and instead generate timestamps assuming constant frame rate fps.
  • -f image2 : Force output file format image2. The format is normally auto detected guessed from the file extension for output files.
  • -vframes number (output) : Set the number of video frames to record.

这篇关于ffmpeg从视频错误中获取图像或缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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