트랜스 코딩 (정확한 원본 이미지 보존)없이 PNG 시퀀스를 MP4 파일로 다중화 할 수 있습니다. 순수 자바 사용 JCodec (http://jcodec.org를) 이렇게하려면 :
public class SequenceMuxer {
private SeekableByteChannel ch;
private CompressedTrack outTrack;
private int frameNo;
private MP4Muxer muxer;
private Size size;
public SequenceMuxer(File out) throws IOException {
this.ch = NIOUtils.writableFileChannel(out);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrackForCompressed(TrackType.VIDEO, 25);
}
public void encodeImage(File png) throws IOException {
if (size == null) {
BufferedImage read = ImageIO.read(png);
size = new Size(read.getWidth(), read.getHeight());
}
// Add packet to video track
outTrack.addFrame(new MP4Packet(NIOUtils.fetchFrom(png), frameNo, 25, 1, frameNo, true, null, frameNo, 0));
frameNo++;
}
public void finish() throws IOException {
// Push saved SPS/PPS to a special storage in MP4
outTrack.addSampleEntry(MP4Muxer.videoSampleEntry("png ", size, "JCodec"));
// Write MP4 header and finalize recording
muxer.writeHeader();
NIOUtils.closeQuietly(ch);
}
}
는이 같은 이동 사용하려면
public static void main(String[] args) throws IOException {
SequenceMuxer encoder = new SequenceMuxer(new File("video_png.mp4"));
for (int i = 1; i < 100; i++) {
encoder.encodeImage(new File(String.format("img%08d.png", i)));
}
encoder.finish();
}
당신이 stegged 것 같은 것을 영화에 넣을 수 있습니까? – Lizz