1

it´s possible I´m asking a nonsense but I´m a bit noob... I´m trying to write native code in Android to change the resolution of a video using a FFmpeg. I compiled the library of FFmpeg and I added it to my project correctly after used the NDK. But now I want to execute this FFmpeg command shell:

ffmpeg -i input.mp4 -s 480x320 output.mp4

I need to execute it in a C file using the JNI but I don´t know how to call the equivalent methods of the command...

I think I´m having a similar problem than here

Thanks for help!!

Community
  • 1
  • 1
Gonzalo Solera
  • 1,182
  • 12
  • 26

1 Answers1

0

Use like this

system("ffmpeg -i input.mp4 -s 480x320 output.mp4");

or

char str[]="ffmpeg -i input.mp4 -s 480x320 output.mp4";
system(str); 

INFO

int system (const char* command);

Execute system command.

EXAMPLE

#include <stdio.h>
#include <string.h>

int main ()
{
   char command[50];

   strcpy( command, "ls -l" );
   system(command);

   return(0);
} 
Gangadhar
  • 10,248
  • 3
  • 31
  • 50
  • `ffmpeg -i input.mp4 -s 480x320 output.mp4` is this gives expected output when you run from the terminal? – Gangadhar Sep 21 '13 at 11:14
  • well, I´m really using another path. I´m doing it on Android, so I can´t try the command from the terminal... – Gonzalo Solera Sep 21 '13 at 11:28
  • Which path are you using ? How did know that this command is working As expected.see this http://shreyagarwal.blog.com/2011/04/20/executing-shell-commands-in-android-applications/ and http://stackoverflow.com/questions/15741221/how-to-executing-shell-commands-through-android-app – Gangadhar Sep 21 '13 at 11:56
  • Okey!! I´m trying it but I don´t know how to write it: Runtime rt = Runtime.getRuntime(); rt.exec(new String[]{"ffmpeg", "-i", I DON´T KNOW HOW TO WIRTE IT HERE}); – Gonzalo Solera Sep 21 '13 at 13:00
  • I did search for you. please ask about the above issue here only http://stackoverflow.com/questions/15741221/how-to-executing-shell-commands-through-android-app – Gangadhar Sep 21 '13 at 14:18
  • Hi, did it work for you ? Can a command line be used in code ? – ransh Apr 15 '15 at 17:45
  • @ransh Yes we can execute commands using **system** function. – Gangadhar Apr 17 '15 at 13:46