ffmpeg-cli-wrapper icon indicating copy to clipboard operation
ffmpeg-cli-wrapper copied to clipboard

Non thread blocking?

Open MAXOUXAX opened this issue 4 years ago • 3 comments
trafficstars

The question I'm trying to use this library to encode something when an events happens. However, the library isn't thread-blocking, so when I return the file, it has not been written yet, and therefore my program throws an error.

Example ffmpeg command Not relevant, I tested the same piece of code in a test program and it's working great (as there is a new thread created, the programs outputs when the job is done)

Is there any way to listen for the job to finish, or make the code thread-blocking?

MAXOUXAX avatar Mar 04 '21 13:03 MAXOUXAX

The FFmpegExecutor is blocking. For example:

FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);

// Run a one-pass encode
executor.createJob(builder).run();

That won't return until either a error happens, or it is difficult. If it is returning quickly, then I suspect a error is occurring.

Would you be able up provide an example of what's not working?

bramp avatar Mar 04 '21 16:03 bramp

When my code is executed in a Runnable (because it's in a Task), I get no error, and my output file (an mp4) just contains the first frame of the video. When I run the same code (except that the input and output are hardcoded) in a Java program created to test the library (so absolutely no extra code, just the part with the library in a psvm), the output is correct.

MAXOUXAX avatar Mar 04 '21 17:03 MAXOUXAX

I think you'll need to provide a short code sample, that demonstrates the problem.

bramp avatar Mar 07 '21 18:03 bramp