Arrrrgh! Nope, it's definitely the same file. I've checked, double checked, rechecked, deleted everything, tried again, and still the same results
Then I tried copying and pasting from here and making the text file from scratch, and it works fine... which doesn't help me at all. So I guess there's some weird characters in my file or something.
Here's the whole story: ffmpeg is called with execl, and the output is sent to a text file, as you can see here:
Code:
pid_t my_pid, parent_pid, child_pid;
int fd; /*file descriptor to the file we will redirect ls's output*/
/* print error message if fork() fails */
if((child_pid = fork()) < 0 )
{
perror("fork failure");
exit(1);
}
if(child_pid == 0)
{
if((fd = open("output.log", O_RDWR | O_CREAT))==-1) /*open the file */
{
perror("opening the file");
return 1;
}
dup2(fd,STDOUT_FILENO); /*copy the file descriptor fd into standard output*/
dup2(fd,STDERR_FILENO); /* same, for the standard error */
close(fd); /* close the file descriptor as we don't need it more */
execl("/usr/bin/ffmpeg", "ffmpeg", "-i", infile_value, "-s", "320x240", "-r", "24", "-acodec", "libmp3lame", "-vcodec", "libxvid", "-vtag", "XVID", "-f", "avi", "-qscale", "3", "-g", "300", "-deinterlace", "-ab", "56k", "-ar", "24000", "-aspect", "4:3", "-async", "1", outfile_value, (char *) 0);
exit(1);
}
else
{
wait(NULL);
}
I couldn't just do system("ffmpeg blah blah > output.txt); because I end up with a blank file.
I'm just trying to get the length of the file, so I can use system() with grep now to grab the line with the number I need:
Code:
system("cat output.log|grep time= > out.txt");
Which brings me to where I am now. I know I'm probably doing things in a weird way, but I don't know anyone personally who knows a thing about programming, so it's hard to ask how to go about doing things. Basically I need to get the duration of the video in seconds, so basically I just need to retrieve the "162.50" from the text file.
If there's a better way to get the output of ffmpeg, or do anything I'm trying to do here, I'd love to know that as well.