8 Replies - 866 Views - Last Post: 21 May 2013 - 03:59 PM Rate Topic: -----

#1 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

thumbnail code doesnt work !

Posted 21 May 2013 - 08:59 AM

Hi

I tried this code to take preview picture from the video

I did break point to find out is it working or not ?? and it was working well but when I go to the folder there is no picture, am I miss something here ??

 //Create Thumbs
                        string thumbpath, thumbname;
                        string thumbargs;
                        string thumbre;
                        string withoutext, SavePath;

                        //Get the file name without Extension
                        withoutext = Path.GetFileNameWithoutExtension(FUV.FileName);
                        SavePath = AppDomain.CurrentDomain.BaseDirectory + "Videos\\";
                        thumbpath = AppDomain.CurrentDomain.BaseDirectory + "Videos\\img\\";

                        thumbname = thumbpath + withoutext + "%d" + ".jpg";
                        Session["thumbname"] = withoutext + "1" + ".jpg";
                        thumbname = thumbpath + withoutext + ".jpg";
                        thumbargs = "-i \"" + FUV.FileName + "\" -f image2 -vframes 1 -ss 3 -s 150x130 \"" + thumbname + "\"";
                        Process thumbproc = new Process();
                        thumbproc = new Process();
                        thumbproc.StartInfo.FileName = "\\ffmpeg\\ffmpeg.exe";
                        thumbproc.StartInfo.Arguments = thumbargs;
                        thumbproc.StartInfo.UseShellExecute = false;
                        thumbproc.StartInfo.CreateNoWindow = false;
                        thumbproc.StartInfo.RedirectStandardOutput = false;
                        try
                        {
                            thumbproc.Start();
                        }
                        catch (Exception ex)
                        {
                            Response.Write(ex.Message);
                        }
                        thumbproc.WaitForExit();
                        thumbproc.Close();


Is This A Good Question/Topic? 0
  • +

Replies To: thumbnail code doesnt work !

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3184
  • View blog
  • Posts: 10,667
  • Joined: 12-December 12

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 10:20 AM

Are your thumbargs correct? Particularly the last back-slash.
Was This Post Helpful? 0
  • +
  • -

#3 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 11:22 AM

View Postandrewsw, on 21 May 2013 - 10:20 AM, said:

Are your thumbargs correct? Particularly the last back-slash.


I think that too and I change it like in this post My link


thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 " + thumbname;


but still did not change
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3184
  • View blog
  • Posts: 10,667
  • Joined: 12-December 12

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 11:40 AM

The %d in this line:

thumbname = thumbpath + withoutext + "%d" + ".jpg";

is over-written two lines further down in your code. (I don't know what it is for or whether it needs to be there.)

You should print out the final version of your printargs and, together with \\ffmpeg\\ffmpeg.exe, try and execute this from the command-line. Actually, your code lacks spath in comparison to the page you linked to.
Was This Post Helpful? 0
  • +
  • -

#5 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 12:38 PM

I fix it as you told me


 //Create Thumbs
                        string thumbpath, thumbname;
                        string thumbargs;
                        string thumbre;
                        string withoutext, SavePath;
                        string inputfile;
                        string NewFName=FUV.PostedFile.FileName;
                        string spath;
                        spath = Server.MapPath(".");
                        NewFName = NewFName.Substring(NewFName.LastIndexOf("\\") + 1, NewFName.Length - NewFName.LastIndexOf(".")) + "." + NewFName.Substring(NewFName.LastIndexOf(".") + 1);
                         
                        //Get the file name without Extension
                        withoutext = Path.GetFileNameWithoutExtension(FUV.FileName);
                        SavePath = AppDomain.CurrentDomain.BaseDirectory + "Videos\\";
                        thumbpath = AppDomain.CurrentDomain.BaseDirectory + "Videos\\img\\";
                        inputfile = SavePath + NewFName;
                        thumbname = thumbpath + withoutext + ".jpg";
                        thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 " + 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;
                        try
                        {
                            thumbproc.Start();
                        }
                        catch (Exception ex)
                        {
                            Response.Write(ex.Message);
                        }
                        thumbproc.WaitForExit();
                        thumbproc.Close()


here is the result after break point

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3184
  • View blog
  • Posts: 10,667
  • Joined: 12-December 12

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 12:50 PM

Does it work :dontgetit:

If not, is ffmpeg.exe at the location you specified? (I assume it is, otherwise you would probably have received an error.) Did you get it to work from the command-line? You should have done this first anyway ;).

It might require embedded quotes (around the filenames); but get it to work from the command-line, then you can compare this to your coded version.

BTW I know nothing about the specifics of your code, I'm only providing suggestions based on the typical problems we encounter from the command-line.

This post has been edited by andrewsw: 21 May 2013 - 12:51 PM

Was This Post Helpful? 0
  • +
  • -

#7 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 03:30 PM

I'm still beginner so I'm not use to command line

I tried what you said I dont know what to write on it but I gust is this line

"-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 " + thumbname;


I did it and its not working that mean we know now where is the problem

correct me if I'm wrong and thanks for your effort trying to help me :cry2: :cry2:

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3184
  • View blog
  • Posts: 10,667
  • Joined: 12-December 12

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 03:39 PM

You start the command-line with the equivalent of this: spath + "\\ffmpeg\\ffmpeg.exe".
Then a space, and then the other stuff: the filenames and parameters.

I think you should take the time to learn how to run an application, and open a file, from the command-line. Without this knowledge it will be difficult for you to understand and fix your attempt to do this in code.

This post has been edited by andrewsw: 21 May 2013 - 03:40 PM

Was This Post Helpful? 0
  • +
  • -

#9 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: thumbnail code doesnt work !

Posted 21 May 2013 - 03:59 PM

aha thanks for your help I'm working on it now and doing my research

I did what you said and did not work
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1