-2

I want to execute a cmd command using java program

ffmpeg -i input.mp4 output.mp3

I want the above command to be executed in cmd using java language. and in above code I have directly given the input file name to execute but can I write a code so that user can manually give an input file?

  • Have you thoroughly done any research before posting this question? Please visit [ask] and read through it. Thanks. – slhck Mar 21 '13 at 10:38
  • this is a huuuuuuuge duplication. A huge one. When you ask, check out the related links. It happens that you can't find the answer in the first place, but when you start asking question, the stackoverflow gives the similar questions. You have good chance to find answer if you ask basic things. – CsBalazsHungary Mar 21 '13 at 10:40

2 Answers2

0

Here you go -

Runtime.getRuntime().exec("ffmpeg -i input.mp4 output.mp3");
Sudhanshu Umalkar
  • 4,174
  • 1
  • 23
  • 33
0

You can use ProcessBuilder do do this. The JavaDoc has some code examples that should prove useful.

NilsH
  • 13,705
  • 4
  • 41
  • 59