Skip to content

Instantly share code, notes, and snippets.

@rdp
Created September 25, 2012 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdp/3784971 to your computer and use it in GitHub Desktop.
Save rdp/3784971 to your computer and use it in GitHub Desktop.
C/java seem to run it reliably
#include <stdio.h>
void main(char **argv) {
int a = 0;
for(a = 0; a < 100; a++) {
FILE *lsofFile_p = popen("temp\\ffmpeg.exe -list_devices true -f dshow -i dummy 2>&1", "r");
if (!lsofFile_p)
{
printf("bad p");
return -1;
}
int b;
for(b = 0; b < 20; b++) {
char buffer[1024];
char *line_p = fgets(buffer, sizeof(buffer), lsofFile_p);
printf("got %s", buffer);
}
pclose(lsofFile_p);
printf("done file\n\n\n");
}
}
// also appears to run fine
class test {
public static void main(String... args) throws Exception {
Process process = Runtime.getRuntime().exec("temp\\ffmpeg.exe -list_devices true -f dshow -i dummy");
byte[] bytes = new byte[4000];
process.getErrorStream().read(bytes);
System.out.println("hellostderr" + new String(bytes));
bytes = new byte[2000];
process.getInputStream().read(bytes);
System.out.println("hellostdout" + new String(bytes));
process.getErrorStream().read(bytes);
System.out.println("hellostderr2" + new String(bytes));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment