In my project I am saving videos, converting formats to .swf using ffmpeg. Converting and saving the videos is working fine, but I have a problem with creating the thumbnails. It saves a "picture.jpg" but there is no image. looking at the thumbnail its only got the normal photoviewer sign which is fine, but when I try to open the image it gives a message of
Windows photo viewer: Windows photo viewer cant open this picture because the file appears to be damaged, corrupted, or is too large. (this image is 2.7MB) - Photos taken from my camera is about 5MB and that opens.
PictureViewer: couldn't display "image.jpg" because a suitable graphics importer could not be found.
Paint: Paint cannot read this file. This is not a valid bitmap file or its format is currently not supported.
The images won't open in any I done to save the image:
tring thumbpath, thumbname;
thumbpath = Server.MapPath("~\\uploads\\" + dtYear + "\\" + dtMonth + "\\Thumb\\");
pathToCheck = thumbpath;
tempfileName = "";
int counter = 2;
tempfileName = thumbpath + counter.ToString() + withoutext + ".jpg";
pathToCheck = tempfileName;
outputfile = tempfileName;
lblMsg.Text = "A file with the same name already exists." +
"<br />Your file was saved as " + counter.ToString() + withoutext + ".jpg";
thumbname = thumbpath + withoutext + "%d" + ".jpg";
Session["thumbname"] = withoutext + "1" + ".jpg";
thumbargs = "-i " + inputfile + "-f image2 -ss 1.000 -vframes 1 " + thumbName;
Process thumbproc = new Process();
thumbproc = new Process();
thumbproc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
thumbproc.StartInfo.Arguments = thumbargs;
thumbproc.StartInfo.UseShellExecute = false;
thumbproc.StartInfo.CreateNoWindow = false;
thumbproc.StartInfo.RedirectStandardOutput = false;
catch (Exception ex)
I've tried these arguments as well, still can't get the image to work...
It saves, just can't open it...
thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:10 -s 150x150 " + thumbName;
I tried adding the argument to the command prompt to see if it works there but it gave me a message of : [NULL @ 000000000025f7a0] Unable to find a suitable output format for 'vframes' vframes: invalid argument The line I used:
ffmpeg -i VID2012.3GP vframes 1 VID2012.jpg
I changed a bit of my code. Debugging through my code there is no exception that is thrown, but if I point the mouse over the process (after it started) it "shows an exception of type System.InvalidOperationException"
thumbargs = "-i " + postedfilename + " vframes 1" + thumbName;
ProcessStartInfo thumbProcstartIfo = new ProcessStartInfo();
thumbProcstartIfo.FileName = @"\ffmpeg\ffmpeg.exe";
thumbProcstartIfo.Arguments = thumbargs;
thumbProcstartIfo.UseShellExecute = false;
thumbProcstartIfo.CreateNoWindow = true;
thumbProcstartIfo.RedirectStandardOutput = false;
using (var process = new Process())
process.StartInfo = thumbProcstartIfo;
catch (InvalidOperationException ex)
lblMsg.Text = ex.ToString();