forked from j62/ctbrec
Remove dependency to jcodec library
This commit is contained in:
parent
bb95575897
commit
b458b4096e
|
@ -42,10 +42,6 @@
|
||||||
<groupId>com.iheartradio.m3u8</groupId>
|
<groupId>com.iheartradio.m3u8</groupId>
|
||||||
<artifactId>open-m3u8</artifactId>
|
<artifactId>open-m3u8</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jcodec</groupId>
|
|
||||||
<artifactId>jcodec</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
package ctbrec;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.channels.ReadableByteChannel;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jcodec.common.Demuxer;
|
|
||||||
import org.jcodec.common.DemuxerTrack;
|
|
||||||
import org.jcodec.common.TrackType;
|
|
||||||
import org.jcodec.common.Tuple;
|
|
||||||
import org.jcodec.common.Tuple._2;
|
|
||||||
import org.jcodec.common.io.FileChannelWrapper;
|
|
||||||
import org.jcodec.common.io.NIOUtils;
|
|
||||||
import org.jcodec.common.model.Packet;
|
|
||||||
import org.jcodec.containers.mps.MPSDemuxer;
|
|
||||||
import org.jcodec.containers.mps.MTSDemuxer;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class MpegUtil {
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MpegUtil.class);
|
|
||||||
|
|
||||||
private MpegUtil() {}
|
|
||||||
|
|
||||||
public static double getFileDurationInSecs(File file) throws IOException {
|
|
||||||
try(FileChannelWrapper ch = NIOUtils.readableChannel(file)) {
|
|
||||||
_2<Integer,Demuxer> m2tsDemuxer = createM2TSDemuxer(ch, TrackType.VIDEO);
|
|
||||||
Demuxer demuxer = m2tsDemuxer.v1;
|
|
||||||
DemuxerTrack videoDemux = demuxer.getTracks().get(0);
|
|
||||||
Packet videoFrame = null;
|
|
||||||
double totalDuration = 0;
|
|
||||||
while( (videoFrame = videoDemux.nextFrame()) != null) {
|
|
||||||
totalDuration += videoFrame.getDurationD();
|
|
||||||
}
|
|
||||||
return totalDuration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static _2<Integer, Demuxer> createM2TSDemuxer(FileChannelWrapper ch, TrackType targetTrack) throws IOException {
|
|
||||||
MTSDemuxer mts = new MTSDemuxer(ch);
|
|
||||||
Set<Integer> programs = mts.getPrograms();
|
|
||||||
if (programs.isEmpty()) {
|
|
||||||
LOG.error("The MPEG TS stream contains no programs");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Tuple._2<Integer, Demuxer> found = null;
|
|
||||||
for (Integer pid : programs) {
|
|
||||||
ReadableByteChannel program = mts.getProgram(pid);
|
|
||||||
if (found != null) {
|
|
||||||
program.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MPSDemuxer demuxer = new MPSDemuxer(program);
|
|
||||||
if (targetTrack == TrackType.AUDIO && !demuxer.getAudioTracks().isEmpty()
|
|
||||||
|| targetTrack == TrackType.VIDEO && !demuxer.getVideoTracks().isEmpty()) {
|
|
||||||
found = org.jcodec.common.Tuple._2(pid, (Demuxer) demuxer);
|
|
||||||
} else {
|
|
||||||
program.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,8 +12,6 @@ import java.text.NumberFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.annotation.concurrent.ThreadSafe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -24,7 +22,6 @@ import ctbrec.io.IoUtils;
|
||||||
import ctbrec.recorder.FFmpeg;
|
import ctbrec.recorder.FFmpeg;
|
||||||
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
||||||
|
|
||||||
@ThreadSafe
|
|
||||||
public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
|
public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CreateContactSheet.class);
|
private static final Logger LOG = LoggerFactory.getLogger(CreateContactSheet.class);
|
||||||
|
|
|
@ -91,11 +91,6 @@
|
||||||
<artifactId>open-m3u8</artifactId>
|
<artifactId>open-m3u8</artifactId>
|
||||||
<version>0.2.7-CTBREC</version>
|
<version>0.2.7-CTBREC</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jcodec</groupId>
|
|
||||||
<artifactId>jcodec</artifactId>
|
|
||||||
<version>0.2.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjfx</groupId>
|
<groupId>org.openjfx</groupId>
|
||||||
<artifactId>javafx-controls</artifactId>
|
<artifactId>javafx-controls</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue