Skip to content

Commit

Permalink
release 0.16.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Carroll committed Jul 24, 2022
1 parent 809fe4d commit fa0526c
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 97 deletions.
2 changes: 1 addition & 1 deletion docker-nginx-rtmp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<artifactId>docker-nginx-rtmp</artifactId>
<packaging>pom</packaging>
Expand Down
11 changes: 3 additions & 8 deletions lib-ffmpeg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<artifactId>lib-ffmpeg</artifactId>
<name>lib-ffmpeg (${project.version})</name>
Expand Down Expand Up @@ -55,13 +55,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.palantir.docker.compose</groupId>
<artifactId>docker-compose-rule-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.palantir.docker.compose</groupId>
<artifactId>docker-compose-rule-junit4</artifactId>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import com.palantir.docker.compose.DockerComposeRule;
import com.palantir.docker.compose.configuration.ShutdownStrategy;
import com.palantir.docker.compose.connection.waiting.SuccessOrFailure;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.dempsy.vfs.Vfs;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

import ai.kognition.pilecv4j.ffmpeg.Ffmpeg2.EncodingContext;
import ai.kognition.pilecv4j.ffmpeg.Ffmpeg2.EncodingContext.VideoEncoder;
Expand All @@ -34,34 +28,33 @@ public class TestFfmpegStreaming extends BaseTest {
private static final Logger LOGGER = LoggerFactory.getLogger(TestFfmpegStreaming.class);
final int numFrames = SHOW ? 1000 : 10;

@Rule public final TestRule docker = DockerComposeRule.builder()
.file(uncheck(() -> new Vfs().toFile(new URI("classpath:///pilecv4j-rtmp-docker-compose.yml"))).getAbsolutePath())
// .waitingForHostNetworkedPort(8080, p -> p.isHttpRespondingSuccessfully(port -> "http://localhost:" + port + "/", false))
.waitingForHostNetworkedPort(8080, p -> p.isListeningNow() ? SuccessOrFailure.success() : SuccessOrFailure.failure("not yet"))
.removeConflictingContainersOnStartup(true)
.shutdownStrategy(ShutdownStrategy.KILL_DOWN)
.build();
@Rule public GenericContainer<?> docker = new GenericContainer<>(DockerImageName.parse("pilecv4j/nginx-rtmp:latest"))
.withExposedPorts(8080, 1935);

@Rule public final TemporaryFolder tempDir = new TemporaryFolder();

@Test
public void testRemuxStreaming() throws Exception {
final int rtmpPort = docker.getMappedPort(1935);

Thread.sleep(100);

try(final StreamContext c = Ffmpeg2.createStreamContext();
final ImageDisplay id = SHOW ? new ImageDisplay.Builder().build() : null;) {

final AtomicBoolean checkerFailed = new AtomicBoolean(false);
final AtomicBoolean finishedSuccessfully = new AtomicBoolean(false);
final CountDownLatch checkerLatch = new CountDownLatch(1);

final Thread checker = startChecker(id, numFrames, checkerLatch, () -> c.stop(), finishedSuccessfully, checkerFailed);
final Thread checker = startChecker(id, rtmpPort, numFrames, checkerLatch, () -> c.stop(), finishedSuccessfully, checkerFailed);

c
.addOption("rtsp_flags", "prefer_tcp")
.createMediaDataSource(STREAM)
.peek(sc -> sc.load())
.peek(sc -> checkerLatch.countDown())
.openChain()
.createUriRemuxer("flv", "rtmp://localhost:1935/live/feedly-id")
.createUriRemuxer("flv", "rtmp://localhost:" + rtmpPort + "/live/feedly-id")
.streamContext()
.sync()
.play();
Expand All @@ -75,6 +68,9 @@ public void testRemuxStreaming() throws Exception {

@Test
public void testEncodingStream() throws Exception {
final int rtmpPort = docker.getMappedPort(1935);
Thread.sleep(100);

try(
final EncodingContext encoder = Ffmpeg2.createEncoder();
final StreamContext ctx = Ffmpeg2.createStreamContext();
Expand All @@ -87,10 +83,10 @@ public void testEncodingStream() throws Exception {
final CountDownLatch checkerLatch = new CountDownLatch(1);
final AtomicBoolean triggerWhenDone = new AtomicBoolean(false);

final Thread checker = startChecker(id, numFrames, checkerLatch, () -> triggerWhenDone.set(true), finishedSuccessfully, checkerFailed);
final Thread checker = startChecker(id, rtmpPort, numFrames, checkerLatch, () -> triggerWhenDone.set(true), finishedSuccessfully, checkerFailed);

encoder
.outputStream("flv", "rtmp://localhost:1935/live/feedly-id")
.outputStream("flv", "rtmp://localhost:" + rtmpPort + "/live/feedly-id")
.openVideoEncoder("libx264", "default")
.addCodecOptions("profile", "baseline")
.addCodecOptions("preset", "ultrafast")
Expand Down Expand Up @@ -142,8 +138,8 @@ public void testEncodingStream() throws Exception {

}

private static Thread startChecker(final ImageDisplay id, final int numFrames, final CountDownLatch checkerLatch, final Runnable triggerWhenDone,
final AtomicBoolean finishedSuccessfully, final AtomicBoolean checkerFailed) {
private static Thread startChecker(final ImageDisplay id, final int rtmpPort, final int numFrames, final CountDownLatch checkerLatch,
final Runnable triggerWhenDone, final AtomicBoolean finishedSuccessfully, final AtomicBoolean checkerFailed) {
final Thread checker = new Thread(() -> {
try {
uncheck(() -> checkerLatch.await());
Expand All @@ -157,7 +153,7 @@ private static Thread startChecker(final ImageDisplay id, final int numFrames, f
sc
.addOption("flags", "low_delay")
.addOption("fflags", "nobuffer")
.createMediaDataSource("rtmp://localhost:1935/live/feedly-id")
.createMediaDataSource("rtmp://localhost:" + rtmpPort + "/live/feedly-id")
.openChain()
.createFirstVideoStreamSelector()
.createVideoFrameProcessor(m -> {
Expand Down
2 changes: 1 addition & 1 deletion lib-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<artifactId>lib-image</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion lib-nr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<artifactId>lib-nr</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion lib-python/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>

<artifactId>lib-python</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion lib-tf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<artifactId>lib-tf</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion lib-tracking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion lib-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>
<artifactId>lib-util</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion native-ffmpeg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>ai.kognition.pilecv4j</groupId>
<artifactId>pilecv4j-parent</artifactId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>

<artifactId>native-ffmpeg</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion native-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>

<artifactId>native-image</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion native-nr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>

<artifactId>native-nr</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion native-python/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>pilecv4j-parent</artifactId>
<groupId>ai.kognition.pilecv4j</groupId>
<version>0.16-SNAPSHOT</version>
<version>0.16</version>
</parent>

<artifactId>native-python</artifactId>
Expand Down
Loading

0 comments on commit fa0526c

Please sign in to comment.