FFmpegVideoTexture

class FFmpegVideoTexture(val mediaUrl: String, width: Int, height: Int, tryHardwareDecode: Boolean = true) : CallbackVideoTexture, VideoPlayback

JVM video texture driven by direct javacpp-presets FFmpeg — no JavaCV wrapper. A worker thread runs the demux→decode→scale loop by hand:

  1. av_read_frame → AVPacket

  2. avcodec_send_packet / avcodec_receive_frame → AVFrame in source pixel format

  3. (optional) av_hwframe_transfer_data → AVFrame in CPU-accessible format

  4. sws_scale → AVFrame in packed BGRA

  5. Copy BGRA bytes into a heap ByteArray and push to the CallbackVideoTexture base.

Compare with JavaCvVideoTexture which does the same in ~50 lines via org.bytedeco.javacv.FFmpegFrameGrabber. The raw path exists for pedagogy and as a starting point for hardware acceleration / custom codec selection / frame seeking.

Runtime requirement: org.bytedeco:javacv-platform (or org.bytedeco:ffmpeg with the host classifier) on the classpath.

Constructors

Link copied to clipboard
constructor(mediaUrl: String, width: Int, height: Int, tryHardwareDecode: Boolean = true)

Properties

Link copied to clipboard
Link copied to clipboard
val coordTransform: Matrix3
Link copied to clipboard

Caller opt-out for mipmap generation.

Link copied to clipboard

True after play if FFmpeg picked a hardware decoder for the source codec.

Link copied to clipboard
val height: Int
Link copied to clipboard

Filesystem path or URL to the media.

Link copied to clipboard
val target: Int
Link copied to clipboard
open override val timeMs: Long

Current playback time in milliseconds since playback started.

Link copied to clipboard
val width: Int

Functions

Link copied to clipboard
open override fun bindTexture(dc: DrawContext): Boolean
Link copied to clipboard
fun getTexParameter(name: Int): Int
Link copied to clipboard
fun getTextureName(dc: DrawContext): KglTexture
Link copied to clipboard
open override fun pause()

Pause playback. The current frame stays on the texture; resumable via play.

Link copied to clipboard
open override fun play()

Start (or resume) playback. Re-entrant — calling on an already-running player is a no-op.

Link copied to clipboard
open override fun release(dc: DrawContext)

Frees any resources associated with this instance. After this method returns the rendering resource is invalid, and any associated GL object is deleted.

open override fun release()

Free decoder + native resources. After release the texture is unusable.

Link copied to clipboard
fun setTexParameter(name: Int, param: Int)
Link copied to clipboard
open override fun stop()

Stop playback and rewind to the start.