FFMPEG not creating thumbnails - php

My ffmpeg command in php is
echo $cmd_thumbnail_create = ("\"$ffmpeg\" -i \"" . $dir.$videopath . "\" -an -ss $getFromSecond \"" . $dir.$thumbnailpath ."\"");
exec($cmd_thumbnail_create);
Output of which is
"C:\FFMPEG\bin\ffmpeg" -i "C:/xampp/htdocs/final/uploaded_videos/intro_en.mp4" -an -ss 6 "C:/xampp/htdocs/final/thumbnail/intro_en.jpg"
This when copied and executed on the command prompt creates the thumbnail at proper location with proper name.
Any suggestions?

This worked for me...
first.... locate your path to FFMPEG
mine is
$ffmpeg = "H:\\SERVr\\htdocs\\ffmpeg\\bin\\ffmpeg";
Then.. in your shell_exec...
shell_exec("$ffmpeg -i your-input.jpg -an -ss 30 -s 120x100 your-output.jpg 2>&1");
-i is your input file.
-ss is video time you want the clip pulled from.
-s is the size of the thumbnail you want
This works on my Windows machine with XAMPP, and works perfectly.

Related

FFMPEG - Palettegen for animations is not working

I have a script taken from the correct answer at https://superuser.com/questions/1002562/convert-multiple-images-to-a-gif-with-cross-dissolve, but I am getting no results.
Even copying the code word for word does not work for me.
However, if I run $ffmpeg = shell_exec("ffmpeg -i images/image001.jpg -vf palettegen palette_test.png"); on a single image, it works fine. But because I need it for an animation, I need to create a pallete for all images.
Unless of course, on each image in the GIF sequence I can load a new palette?
$q = "ffmpeg -f image2 -framerate 0.5 -i ../view/client/files/".$dir."/%*.jpg -i palettePro.png -lavfi paletteuse -y .." . $save_path . '/' . $filename . " -report";
Palettegen can analyze and generate a matching frame sequence with per-frame palette.
ffmpeg -i images/image%03d.jpg -vf palettegen=stats_mode=single palette_%03d.png
And then
ffmpeg -framerate 0.5 -i images/image%03d.jpg -framerate 0.5 -i palette_%03d.png -lavfi paletteuse=new=1 -y $filename

FFMPEG image resize not working

FFmpeg version 0.6.5 is installed on my web server.
In my website mp4 videos allowed to upload, that part is done.
Now i am working on create a thumbnail of the video and then resize it.
The following links are I referred.
https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg
This is the command i used to create a thumbnail from video, this command is working.
$cmd = "ffmpeg -i test.mp4 -ss 0 -vframes 1 out.png";
After creating the thumbnail, I tried the following the command to resize it, but this is not working.
$cmd = 'ffmpeg -i out.png -vf scale=210:-1 output_320x240.png';
And Some other commands i have tried
$cmd = "ffmpeg -ss 10 -i test.mp4 -vframes 1 -filter scale=-1:150,crop=200:150 output.jpg";
$cmd = "ffmpeg -itsoffset -1 -i test.mp4 -vframes 1 -filter:v scale=280:-1 output.jpg";
In my localhost I used the following command to create thumbnail and resize in a single command, but this is also not working in the server.
$ffmpeg = 'C:\\ffmpeg\\bin\\ffmpeg';
$video = 'test.mp4';
$cmd = "$ffmpeg -itsoffset -1 -i $video -vframes 1 -filter:v scale=\"210:-1\" thumbnail.png";
Thanks to all

swf action script convert into flv

this is a action script : symmetrydigital-labs.com/junior/kazim/portal/flv/Shahid_Kapoor_07.swf
image is call outside from server.
i want to convert this .swf file into .flv and generate thumbnail.
Problem :
1: .swf file converts only video not with image (call from outsource) .swf
2: code was not run in server run only in localhost.
and i am try to using this command
$ffmpeg = 'C:\FFmpeg\ffmpeg-20130614-git-6fe419b-win32-static\bin\ffmpeg';
$ffmpeg = '/usr/bin/ffmpeg';
$cmd = "$ffmpeg -i Shahid_Kapoor_07.swf Shahid_Kapoor_07.flv";
$image = "$ffmpeg -i Shahid_Kapoor_07.swf -an -ss 00:00:03 -an -r 1 -vframes 1 -y abc.jpg";
shell_exec($cmd);
shell_exec($image);

ffmpeg Getting image or thumbnail from video error

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.

Generate thumbnail for a bunch of mp4 video in a folder

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.
I am using Wamp server 2.2 on windows whit php 5.3.8 and Apache 2.2.21
I downloaded ffmpeg from FFmpeg Windows Builds section of ffmpeg download page and the static 32 build from this link.
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
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);
}
Try with absolute paths in commands instead of depending on PATH ENV variable:
Both exec() and system() works. Resolve the path definitions.
/* Using Absolute paths */
$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 $video_file){
$filename = basename($video_file, ".mp4");
$thumbnail = $ouput_path.$filename.'_tn.jpg';
$command = "$ffmpeg -i $video_file -an -y -f mjpeg -ss 00:00:04 -vframes 1 $thumbnail";
$status = system ($command);
/*or
$status = exec($command);
if ($status === false) {
var_dump("ERROR: Conversion Failed!!!!");
} else
var_dump($status);
*/
}
I´m not allowed to add a comment, so here (as a Post) is what I found out while dealing with this:
The white space in the file name prevents ffmpeg from finding the right file. So one way is to change the file name.

Categories