www in docker support

This commit is contained in:
MaddoScientisto 2026-04-22 18:41:37 +02:00
commit c227fce036
2145 changed files with 399596 additions and 58 deletions

View file

@ -0,0 +1,117 @@
package org.jcodec.containers.imgseq;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jcodec.common.Codec;
import org.jcodec.common.Demuxer;
import org.jcodec.common.DemuxerTrack;
import org.jcodec.common.DemuxerTrackMeta;
import org.jcodec.common.TrackType;
import org.jcodec.common.io.NIOUtils;
import org.jcodec.common.logging.Logger;
import org.jcodec.common.model.Packet;
public class ImageSequenceDemuxer implements Demuxer, DemuxerTrack {
private static final int VIDEO_FPS = 25;
private String namePattern;
private int frameNo;
private Packet curFrame;
private Codec codec;
private int maxAvailableFrame;
private int maxFrames;
private String prevName;
private static final int MAX_MAX = 5184000;
public ImageSequenceDemuxer(String namePattern, int maxFrames) throws IOException {
this.namePattern = namePattern;
this.maxFrames = maxFrames;
this.maxAvailableFrame = -1;
this.curFrame = loadFrame();
String lowerCase = namePattern.toLowerCase();
if (lowerCase.endsWith(".png")) {
this.codec = Codec.PNG;
} else if (lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg")) {
this.codec = Codec.JPEG;
}
}
public void close() throws IOException {}
public List<? extends DemuxerTrack> getTracks() {
ArrayList<DemuxerTrack> tracks = new ArrayList<>();
tracks.add(this);
return tracks;
}
public List<? extends DemuxerTrack> getVideoTracks() {
return getTracks();
}
public List<? extends DemuxerTrack> getAudioTracks() {
return new ArrayList<>();
}
public Packet nextFrame() throws IOException {
try {
return this.curFrame;
} finally {
this.curFrame = loadFrame();
}
}
private Packet loadFrame() throws IOException {
if (this.frameNo > this.maxFrames)
return null;
File file = null;
do {
String name = String.format(this.namePattern, this.frameNo);
if (name.equals(this.prevName))
return null;
this.prevName = name;
file = new File(name);
if (file.exists() || this.frameNo > 0)
break;
this.frameNo++;
} while (this.frameNo < 2);
if (file == null || !file.exists())
return null;
Packet ret = new Packet(NIOUtils.fetchFromFile(file), (long)this.frameNo, 25, 1L, (long)this.frameNo, Packet.FrameType.KEY, null, this.frameNo);
this.frameNo++;
return ret;
}
public int getMaxAvailableFrame() {
if (this.maxAvailableFrame == -1) {
int firstPoint = 0;
for (int i = 5184000; i > 0; i /= 2) {
if (new File(String.format(this.namePattern, i)).exists()) {
firstPoint = i;
break;
}
}
int pos = firstPoint;
for (int interv = firstPoint / 2; interv > 1; interv /= 2) {
if (new File(String.format(this.namePattern, pos + interv)).exists())
pos += interv;
}
this.maxAvailableFrame = pos;
Logger.info("Max frame found: " + this.maxAvailableFrame);
}
return Math.min(this.maxAvailableFrame, this.maxFrames);
}
public DemuxerTrackMeta getMeta() {
int durationFrames = getMaxAvailableFrame();
return new DemuxerTrackMeta(TrackType.VIDEO, this.codec, (double)((durationFrames + 1) * 25), null, durationFrames + 1, null, null, null);
}
}

View file

@ -0,0 +1,37 @@
package org.jcodec.containers.imgseq;
import java.io.IOException;
import org.jcodec.common.AudioCodecMeta;
import org.jcodec.common.Codec;
import org.jcodec.common.Muxer;
import org.jcodec.common.MuxerTrack;
import org.jcodec.common.VideoCodecMeta;
import org.jcodec.common.io.NIOUtils;
import org.jcodec.common.logging.Logger;
import org.jcodec.common.model.Packet;
import org.jcodec.common.tools.MainUtils;
public class ImageSequenceMuxer implements Muxer, MuxerTrack {
private String fileNamePattern;
private int frameNo;
public ImageSequenceMuxer(String fileNamePattern) {
this.fileNamePattern = fileNamePattern;
}
public void addFrame(Packet packet) throws IOException {
NIOUtils.writeTo(packet.getData(), MainUtils.tildeExpand(String.format(this.fileNamePattern, this.frameNo++)));
}
public MuxerTrack addVideoTrack(Codec codec, VideoCodecMeta meta) {
return this;
}
public MuxerTrack addAudioTrack(Codec codec, AudioCodecMeta meta) {
Logger.warn("Audio is not supported for image sequence muxer.");
return null;
}
public void finish() throws IOException {}
}