469,286 Members | 2,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Execute the command line arguments in java Program

118 100+
Hi,

i have a command to convert the video file into image

ffmpeg -i sample.wmv -f image2 -t 0.001 -ss 3 ss.jpg

i run that one in command prompt it converted the video file into image.


But i executed that command in jsp Program .It didn't work.It shows error.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <% 
  3. Runtime rt = Runtime.getRuntime();
  4.  Process p = rt.exec("ffmpeg  -i  sample.wmv  -f image2 -t 0.001 -ss 3 ss.jpg");
  5.  %>
  6.  
  7.  
error messages:
Expand|Select|Wrap|Line Numbers
  1. org.apache.jasper.JasperException: Exception in JSP: /upload4.jsp:29
  2.  
  3. 26: 
  4. 27: <% 
  5. 28: Runtime rt = Runtime.getRuntime();
  6. 29:  Process p = rt.exec("ffmpeg  -i  sample.wmv  -f image2 -t 0.001 -ss 3 ss.jpg");
  7. 30:  %>
  8.  
Expand|Select|Wrap|Line Numbers
  1. Stacktrace:
  2.     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
  3.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:381)
  4.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  5.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  6.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  7.  
  8. root cause
  9.  
  10. java.io.IOException: CreateProcess: ffmpeg -i sample.wmv -f image2 -t 0.001 -ss 3 ss.jpg error=2
  11.     java.lang.ProcessImpl.create(Native Method)
  12.     java.lang.ProcessImpl.<init>(Unknown Source)
  13.     java.lang.ProcessImpl.start(Unknown Source)
  14.     java.lang.ProcessBuilder.start(Unknown Source)
  15.     java.lang.Runtime.exec(Unknown Source)
  16.     java.lang.Runtime.exec(Unknown Source)
  17.     java.lang.Runtime.exec(Unknown Source)
  18.     org.apache.jsp.upload4_jsp._jspService(upload4_jsp.java:97)
  19.     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  20.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  21.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
  22.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  23.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  24.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  25.  
  26.  
please tell the solution whats the Problem in my code.
Dec 16 '08 #1
7 9187
JosAH
11,448 Expert 8TB
Look at the root cause: the process couldn't be created; most likely that ffmpeg command is not in the PATH of your web application; either supply the full path of the command or adjust your PATH variable.

kind regards,

Jos
Dec 16 '08 #2
swethak
118 100+
Hi,

Thank you to Reply. I give the full path .But it shows the same error.Please tell that Problem.

Expand|Select|Wrap|Line Numbers
  1.  
  2. File workDir = new File("C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/test/");
  3. Process p = Runtime.getRuntime().exec("ffmpeg  -i  sample.wmv  -f image2 -t 0.001 -ss 3 ss.jpg",null,"workDir");
  4.  
  5.  
Dec 16 '08 #3
JosAH
11,448 Expert 8TB
@swethak
No, you're still passing 'ffmpeg' as the command (in the String). Pass the absolute path in your String where your ffmpeg command is stored.

kind regards,

Jos
Dec 16 '08 #4
swethak
118 100+
hi,

i gave the full path of ffmpeg as

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Process p = Runtime.getRuntime().exec("C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/test/ffmpeg  -i  sample.wmv  -f image2 -t 0.001 -ss 3 sssssss.jpg");
  3. %>
  4.  
Those errors are resolved and also that command didn't work(That means video file didn't convert into an image.) .please help that what is the Problem in that
Dec 17 '08 #5
r035198x
13,262 8TB
What happened when you ran it this time? Where (in which folder) are you expecting the image to be saved to?
Dec 17 '08 #6
swethak
118 100+
Hi,

When i run the code a blank page will appear.Nothing will happen.And i want to give the video file from my working directory.And also i want the image in my working directory

Main thing is i run the command in command prompt

"ffmpeg -i sample.wmv -f image2 -t 0.001 -ss 3 ss.jpg"

It works fine and sample.wmv video converted into ss.jpg in my working directory.

I want to execute the same command in jsp program .Please tell that solution
Dec 17 '08 #7
r035198x
13,262 8TB
The JSP is blank because you haven't output anything with it. Better do all this in a servlet and output the relevant messages to the JSP. That way you can tell if the conversion was successful or not. You probably also need to give an absolute path for the file output to a directory you can easily check.
Dec 17 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by tom | last post: by
13 posts views Thread by BlackHawke | last post: by
4 posts views Thread by Chris | last post: by
3 posts views Thread by =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post: by
4 posts views Thread by neha_chhatre | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.