开发者

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

Is there any way to play h264 video in a Java applet? Not Java FX, but a plain old-school Java applet? I had a look at X开发者_StackOverflow社区uggler but these guys do not support applets at the moment.

Thanks


Check out http://code.google.com/p/gstreamer-java/


You can play video in Java applet but that would require you to implement your own player.

To decode video you can use JCodec ( http://jcodec.org ), it has a handy class called FrameGrab, 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);
}

If you are also planning to play audio you can use: JAAD ( http://jaadec.sourceforge.net/ ) and do something like this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜