Is there a way to play h264 video in a java applet?

Is there a way to play h264 video in a Java applet? Not Java FX, but a plain old school Java applet? I looked at Xuggler, but these guys do not support applets right now.

thank

+3
source share
2 answers

You can play the video in a Java applet, but you will need to implement your own player.

You can use JCodec ( http://jcodec.org ) to decode the video , it has the convenient FrameGrab class, and you can use it like this:

int frameNumber = 10000;
FileChannelWrapper ch = null;
try {
    ch = NIOUtils.readableFileChannel(new File("path to file name"));
    FrameGrab frameGrab = new FrameGrab(ch);

    frameGrab.seek(frameNumber);
    BufferedImage frame;
    for (int i = 0; (frame = frameGrab.getFrame()) != null && i < 200; i++) {
        ImageIO.write(frame, "jpg", new File(String.format("img%08d.png", i)));
    }
} finally {
    NIOUtils.closeQuietly(ch);
}

, : JAAD (http://jaadec.sourceforge.net/) - :

Decoder dec = new Decoder(decoderSpecificinfo);
SampleBuffer buf = new SampleBuffer();
dec.decodeFrame(aacFrame, buf);
//the aacFrame array contains the AAC frame to decode
byte[] audio = buf.getData(); //this array contains the raw PCM audio data
0

Source: https://habr.com/ru/post/1793577/


All Articles