Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop Capture Input and example (2) #88

Closed
wants to merge 2 commits into from

Conversation

vicnevicne
Copy link
Contributor

Followup to Issue #78.
This is new PR replaces #79 and is based on the new "develop" branch.

@kokorin
Copy link
Owner

kokorin commented Jun 29, 2020

Today I had time to checkout your branch. Unfortunatelly I wasn't happy with the final approach.

So I have checked ffmpeg documentation regarding all 4 supported capture inputs. And I noticed that they have some common parts. Namely: framerate, video_size and offsets (X11 and GDI grab). I created separate branch for reworked approach and squashed all the commits.

The work isn't completed yet. But this approach is more general and allows end-user to extend it.

Could you please check above mentioned branch and give your feedback.

@vicnevicne
Copy link
Contributor Author

Excellent. This is definitely more OO than my version.
I guess it's still a bit early to test, but having inner classes for each Platform is cleaner for sure.
Can't wait :-)

@vicnevicne
Copy link
Contributor Author

Hi,
I just tested the latest version and it works very well.
Unless I'm mistaken you dropped the idea of area capture. That's probably a good idea as it's only supported on half of the platforms and can be performed uniformly by an additional crop filter.

I also tried combining GracefulStop and desktop CaptureInput and it works like a champ !
Strangely enough, if you just replace the createTestFFmpeg() method in the Stop.java example by the version below, the stopWithException() and stopWithInterruption() start displaying a RuntimeException stacktrace on the console (but go on with the test), while stopForcefully() throws an uncaught ExecutionException (java.lang.RuntimeException: Process execution has ended with non-zero status: 1) that just exits the program,

Once enclosed in a try-catch block, the program goes on, and the stopGracefully() method works perfectly:

  • No exception
  • A meaningful returned FFmpegResult
  • And, more importantly, it's the only test that outputs a playable video file: -)

Thanks very much for your work. Jaffree clearly fits the bill for me !

Note: Here's my alternate createTestFFmpeg() method to capture the desktop. Note I'm also passing it a number parameter to create files named differently for each method.

public static FFmpeg createTestFFmpeg(int n) {
        return FFmpeg.atPath(Paths.get("c:/util/ffmpeg/bin"))
                .addInput(CaptureInput
                        .captureDesktop()
                        .setCaptureFrameRate(25)
                        .setCaptureCursor(true)
                )
                .addOutput(UrlOutput
                        .toPath(Paths.get("desktop" + n + ".mp4"))
                        .addArguments("-preset", "ultrafast")
                        .setDuration(10, TimeUnit.SECONDS)
                )
                .setOverwriteOutput(true);
    }

KR, Vicne

@kokorin
Copy link
Owner

kokorin commented Jul 7, 2020

Unless I'm mistaken you dropped the idea of area capture.

I didn't check CaptureInput.setCaptureVideoSize(width, height) please. It appeared that area capture is supported by all devices (GDI, DirectShow, X11 and Avfoundation) in the form -video_size {width}x{height}.

I also tried combining GracefulStop and desktop CaptureInput and it works like a champ !
Strangely enough, if you just replace the createTestFFmpeg() method in the Stop.java example by the version below, the stopWithException() and stopWithInterruption() start displaying a RuntimeException stacktrace on the console (but go on with the test), while stopForcefully() throws an uncaught ExecutionException (java.lang.RuntimeException: Process execution has ended with non-zero status: 1) that just exits the program,

Please, create an issue with code samples demonstrating exceptions been thrown.

Also, I would suggest to move further discussion regarding input capture to PR #90 (created from my branch).

P.S. It's always a pleasure when Jaffree project helps people to achieve their goals :-)

Best Regards

@vicnevicne
Copy link
Contributor Author

vicnevicne commented Jul 18, 2020

<off_topic>
Sorry for the delay. As I told you, my screen capture project was motivated by the end of life of Jing, but while users expected a "fade out", Jing stopped working abruptly on 14 July, pushing me to rush out a release of Ginj - Ginj Is Not Jing :-) the same day, and ironing out the first bugs. Still no video integration though.
It's much better now (on Windows at least), don't hesistate to give it a try.
</off_topic>
As discussed above, I've filed a new issue #91 regarding exceptions on stop and I've continued the Capture Input discussion in PR #90

@kokorin
Copy link
Owner

kokorin commented Jul 25, 2020

Merged another branhc, check 0.9.6 version

@kokorin kokorin closed this Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants