473,405 Members | 2,176 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,405 software developers and data experts.

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 9564
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

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

Similar topics

4
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...
13
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...
4
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...
7
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...
4
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...
3
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?
7
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...
4
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...
5
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: <%@...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.