我想隐藏视频上的文字(在java中)。我从图像创建了视频,我得到了一个视频无损格式。现在,我想从这个视频中获取帧。我该怎么做?。这是我使用的代码:
public class SequenceMuxer {
private SeekableByteChannel ch;
private MuxerTrack outTrack;
private int frameNo;
private MP4Muxer muxer;
private Size size;
public SequenceMuxer(File out) throws IOException {
this.ch = NIOUtils.writableChannel(out);
// Muxer that will store the encoded frames
muxer = MP4Muxer.createMP4Muxer(ch, Brand.MP4);
}
public void encodeImage(File png) throws IOException {
if (size == null) {
BufferedImage read = ImageIO.read(png);
size = new Size(read.getWidth(), read.getHeight());
// Add video track to muxer
outTrack = muxer.addVideoTrack(Codec.PNG, VideoCodecMeta.createSimpleVideoCodecMeta(size, ColorSpace.RGB));
}
// Add packet to video track
outTrack.addFrame(MP4Packet.createMP4Packet(NIOUtils.fetchFromFile(png), frameNo, 25, 1, frameNo, FrameType.KEY, null,
frameNo, frameNo, 0));
frameNo++;
}
public void finish() throws IOException {
// Write MP4 header and finalize recording
muxer.finish();
NIOUtils.closeQuietly(ch);
}
}