-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Missing getVideoFrame method #281
Comments
yes, I'm not share what to return. If returning the original decoded frame, the frame can be a hardware frame not accessible by cpu, should I convert to a cpu accessible frame? btw, why do you need this function? |
I'm making a jni plugin for JavaFX. There's a WritableImage that can use ByteBuffer as a source.
I assumed that if I subscribe to the setRenderCallback in it, getVideoFrame will return an already converted size that can be set to setVideoSurfaceSize and without compression. |
getVideoFrame is the same
compressed formats is only used by Hap videos decoded by mdk's hap decoder.
you should report a bug about the crash
frame.to + ByteBuffer is not efficient. |
mp4 test file
When using decoders: |
I haven't found a better way. It seems that there is no way to specify in what format and in what sizes the video should be decoded.
It is important to use allocate rather than allocateDirect. On the native side, I take out this array and fill it directly:
It might be worth experimenting with the new FFI later. There is an option to directly allocate a Memory Segment as a ByteBuffer. But for now, this greatly limits the requirement to have Java 22+. |
As a result, I understood the reason for the fall. As always, the little things of rounding. frame.to () crashes if you request odd height or width dimensions and not exactly the same aspect ratio. I found the best option for myself to use only FFmpeg |
It would be nice to add a new Render API "Software". |
If you are interested by using mdk with compose multiplatform without effort, you can use
joggl = { group = "org.jogamp.jogl", name = "jogl-all-main", version = "2.5.0" }
gluegen = { group = "org.jogamp.gluegen", name = "gluegen-rt-main", version = "2.5.0" } System.setProperty("compose.swing.render.on.graphics", "true")
System.setProperty("compose.interop.blending", "true")
val profile = GLProfile.get(GLProfile.GL2)
val capabilities = GLCapabilities(profile)
val panel = GLJPanel(capabilities)
val animator = Animator(panel)
panel.addGLEventListener(listener)
private val glListener = object: GLEventListener {
override fun init(drawable: GLAutoDrawable) = Unit
override fun dispose(drawable: GLAutoDrawable) {
LibMdkJni.setVideoSurfaceSize(handle, -1, -1, 0L)
}
override fun display(drawable: GLAutoDrawable) {
LibMdkJni.renderVideo(handle, 0L)
}
override fun reshape(drawable: GLAutoDrawable, x: Int, y: Int, width: Int, height: Int) {
LibMdkJni.setVideoSurfaceSize(handle, width, height, 0L)
}
} This is enough to get video playback on all desktop platforms using opengl But javafx can be indeed better if you want to use Metal or other api |
Yes, thank you. I watched this project. It really works well. But my main goal is to keep the ability to build a completely independent native image using GraalVM. |
crash for what decoders? recently I don't have a windows device to test, but on macos no crash.
the renderer has to convert to rgb data in any size, so same implementation as frame.to() |
Can you try to run Thumbnail.exe in mdk-sdk package?
To test hw decoders, add then thumbnail.png is generate. the result is correct for me(tested FFmpeg and MFT software decoder). I guess the bug is from your code.
I can add a new api |
My apologies. The error was not mdk, but in the JavaFX graphics engine. The rowPitch of the buffer was not taken into account there. |
I can't reproduce the leak using 1 player 2 d3d11 renderers. What is the leak speed in MB/s? |
Sorry for the long time before responding. I needed time to reproduce the error accurately. |
It looks like the method is lost in mdk.lib v0.30.1
void getVideoFrame(VideoFrame* frame, void* vo_opaque = nullptr)
Use mingw 64 on windows 11:
g++ -c mylib.cpp mylib.o
Ok
g++ -shared -o mylib.dll mylib.o mdk.lib
undefined reference to `mdk::Player::getVideoFrame(mdk::VideoFrame*, void*)'
collect2.exe: error: ld returned 1 exit status
This is the only method that causes an error. Everything is going fine without it including callback processing.
Therefore, I assume that it is lost in mdk.lib.
The text was updated successfully, but these errors were encountered: