473,382 Members | 1,204 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 9561
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

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

Similar topics

by: tom | last post by:
Problem: In PHP, need to execute a program in (freebsd terms) /usr/local/bin in meta-terms: int i; i = (arguments); There seems to be quite a few execution methods in PHP (sorry in advance...
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater...
by: Kartik | last post by:
Hi, I have an ASP.NET application using VB.NET.I am sending a DOS command to a machine on the network to print a file. This is achieved using xp_cmdshell Dim str As String = "xp_cmdshell...
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service...
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
I have a .NET VC++ program, I want to execute some dos command from the program, e.g. copy some file, and etc. How do I do that?
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
by: neha_chhatre | last post by:
please let me know if am using command line arguments, how to send arguments to a C program if i am working on ubuntu say for example suppose name of my program is prog.c if argc=3 then how...
by: sayeo87 | last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got: <%@...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.