471,896 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,896 software developers and data experts.

Execute the command line arguments in java Program

118 100+

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
  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.  %>
error messages:
Expand|Select|Wrap|Line Numbers
  1. org.apache.jasper.JasperException: Exception in JSP: /upload4.jsp:29
  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:  %>
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)
  8. root cause
  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)
please tell the solution whats the Problem in my code.
Dec 16 '08 #1
7 9391
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,

Dec 16 '08 #2
118 100+

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

Expand|Select|Wrap|Line Numbers
  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");
Dec 16 '08 #3
11,448 Expert 8TB
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,

Dec 16 '08 #4
118 100+

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. %>
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
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
118 100+

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
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 YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.