B4J Question Screen Recording Tool

tufanv

Expert
Licensed User
Longtime User
Hello,

is it possible to make a screen capture with b4j app ? For example we will adjust the position of boundaries to record a part of mac screen and the app will record the screen and export it as video at the end ? if yes , is there a sample or tutorial available as I couldnt find any with search. thanks

TY
 

moster67

Expert
Licensed User
Longtime User
I am pretty sure you can do it by using either ffmpeg (with jShell) or Vlc (adding some methods to my B4JVlcj-wrapper). In both cases, the end user must install ffmpeg or Vlc on their computers so the solution is not the best.
Probably there are some java-libs out there and perhaps they can be wrapped...
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
I am working on a B4J library that will allow you to decode/encode video but it is probably months away from release. This, coupled with the jAWTRobot's screen shot capabilities, will allow you to do screen recording. If you need this functionality sooner, I could be persuaded to prioritize this project for a price.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@tufanv
I am interested in this too. When you say you want to adjust the position of boundaries to record a part of mac screen, will this part of the screen be your app (your forms) or do you intend other parts of the screen/desktop which are not showing your app?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Found a native JavaFX source that might be of help.
I already wrapped that one but I am not pleased with how it works. It is slow in saving and then it uses Animation to play the "video" (= to show the frames - there is no encoding taking place). Also the cursor is not being saved and there are some other shortcomings. Many aspects can be configured though.

That said, it is usable. If someone is interested, I can post later the wrapper and the java-sources.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
@tufanv
I am interested in this too. When you say you want to adjust the position of boundaries to record a part of mac screen, will this part of the screen be your app (your forms) or do you intend other parts of the screen/desktop which are not showing your app?
What I want is the boundaries outside of the app which you can place it anywhere ( outside of the app )
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
You can contact the guy who wrote that native JavaFX code I found him on Facebook. He might have found a way to improve his own code. His name is Eudy Contreras :)

Eudy.JPG
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@tufanv
Do you mean that if your app is covering the left part of the screen, you would like to be able record another app perhaps shown on the right side of the desktop?
It might be possible with the one I wrapped if you use a transparent form with no borders (possible in B4J?) and you position it over the area you wish to record. No idea though if it will work. I will post the wrapper this evening and you can try.

I saw other projects as well which seem better, including the Robot one, but since @Roycefer is already planning to add it, I will pass.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
You can contact the guy who wrote that native JavaFX code
No need - there is open source code which lets you save the frames(images) into the MOV-format and which I could add and which might improve things but I am not really that interested since I don't need it now. Still, I believe a solution using native libs such as ffmpeg/vlc would give the best results although the solution @Roycefer is mentioning might be OK too.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
The library I am working on wraps this project: https://github.com/artclarke/humble-video which is a Java binding for ffmpeg. With it, you will be able extract frames and audio from a video file and take Images and audio files and encode them into a video file. The Images can come from anywhere, including the jAWTRobot's screenshot methods which allow you to take screenshots of arbitrary rectangles on the system's monitors.

Moster67, do you know of a better audio-video Java library to wrap? Of all the ones I researched and experimented with, humble-video seems the best but it's still a real pain in the ass to use and the developer hasn't touched it in over a year or answered any issues in that time.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@Roycefer
Honestly, for B4J I haven't had any needs yet so I don't know much what is available. For Android instead, I have wrapped an ffmpegencoder which works fine (using command line api).

However, that said, I have already used ffmpeg with B4J/jShell for streaming and encoding but not for image/audio manipulation. It works fine so it ought to be fine for other purposes as well. You could of course write a wrapper around the ffmpeg command line tool and then expose to the users various predefined custom methods of different nature. This would also make the library very flexible.

I had a look around and indeed the "humble-video" project seems to be very rich and promising although, as you say, it looks rather complicated.
I saw some other (javafx) projects, based on ffmpeg, which look interesting as well such as :
- https://github.com/TheTrio/SlickConvert
- https://github.com/marcelluiz96/Aljava-Portable

Maybe you have already tried them?

Sorry I can't be much of help in this moment but if I come across a project which looks promising, I will let you know.
 
Last edited:
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Sorry tufanv for hijacking your thread.

Moster67, my intention is to be able to edit video in B4J. Wrapping the ffmpeg command line tool imposes (in my opinion, intolerable) limitations on the programmer. For example, all your frames have to be written to disk. You need to have all your frames completed before calling ffmpeg. I don't think streaming is supported. With humble-video, ffmpeg C/C++ code is access via JNI so you can take frames that are in memory and encode them in real time. No need to write them to disk. There is much more flexibility and support for streaming. Those projects to which you linked just wrap the ffmpeg command line tools and use them for conversion and compression. No video editing.

I have a working Java project that uses humble-video and does what I need. But getting it to work with B4J is turning out to be a bigger pain than I thought.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Sorry tufanv for hijacking your thread.

Moster67, my intention is to be able to edit video in B4J. Wrapping the ffmpeg command line tool imposes (in my opinion, intolerable) limitations on the programmer. For example, all your frames have to be written to disk. You need to have all your frames completed before calling ffmpeg. I don't think streaming is supported. With humble-video, ffmpeg C/C++ code is access via JNI so you can take frames that are in memory and encode them in real time. No need to write them to disk. There is much more flexibility and support for streaming. Those projects to which you linked just wrap the ffmpeg command line tools and use them for conversion and compression. No video editing.

I have a working Java project that uses humble-video and does what I need. But getting it to work with B4J is turning out to be a bigger pain than I thought.
Go ahead , this is why the forum exists :) following an interesting discussion which is perfect :)
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@Roycefer - I was not aware that you had video editing in mind.
Yes, I agree with you for editing videos it is important to be able manipulate the frames in memory and avoid writing to disk although ffmpeg is still needed to get the frames and then to do the final encoding. I am not aware of any other projects which fulfill your requirements. There used to be Xuggler but I don't think it is being developed anymore. There are some other projects but which probably are a bit limited for your purposes, for instance jCodec.
There was (is) another promising project, made by VideoLAN i.e. VLMC (VideoLAN Movie Creator) but I am not aware of any Java interface for it.

Anyway, good luck with your project and I for sure look forward to trying it if you decide to publish it, even against a fee.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Yes, I looked at Xuggler and jCodec, as well. Xuggler seemed more promising but it is deprecated and the GitHub page sends you to humble-video. That's one of the reasons why I went with humble-video. Anyhow, when I have something worth sharing, I'll post it in the B4J libraries forum.
 
Upvote 0
Top