I’m a complete newbie to C. I’m from PHP background, but it so happens that the code that I wrote in PHP needs to be converted to C. It was Java at first, but now the requirement is C.
After going through some tutorials, I got the basics of C and coded the following to run ffmpeg.exe from within a c program
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *app = "D:\\ffmpeg\\bin\\ffmpeg.exe -i";
char *input = " D:\\video.mpg";
char *output = " D:\\frames\\image%d.jpg";
char *param = " -r 10";
char str[300];
snprintf(str, sizeof str, "%s%s%s%s", app, input, param, output);
// str contains "D:\ffmpeg\bin\ffmpeg.exe -i D:\video.mpg -r 10 D:\frames"\image%d.jpg
system(str); // <-- working fine, frames are being extracted
/*
do something here to store each extracted frame in an array
so that the array contains image1.jpg, image2.jpg, image3.jpg...and so on
*/
getch();
return 0;
}
On compiling and running the program, I’m getting the frames in the output folder as expected. The issue is I want to store each frame name inside an array as it gets extracted. So far, I haven’t been able to come across a similar issue and so I decided to create a new thread for it. I’m hoping this is possible and would appreciate a nudge in the right direction.
Now since the filenames are not displayed as output to system command using popen or fork will not work. I would recoomend you to perform a nftw on the output directory(D:\frames). It will list down all the files in the folder.
Sample code:
http://linux.die.net/man/3/nftw