[英]Is there any way to play h264 video in a java applet?
有没有办法在Java applet中播放h264视频? 不是Java FX,而是一个普通的老式Java applet? 我看过Xuggler,但这些人目前不支持applet。
谢谢
您可以在Java applet中播放视频,但这需要您实现自己的播放器。
要解码视频你可以使用JCodec( http://jcodec.org ),它有一个方便的类叫做FrameGrab,你可以像这样使用它:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.