diff --git a/video/src/main/java/beta/video/StreamingShotChangeDetection.java b/video/src/main/java/beta/video/StreamingShotChangeDetection.java index e1f98ed07c6..82193071e59 100644 --- a/video/src/main/java/beta/video/StreamingShotChangeDetection.java +++ b/video/src/main/java/beta/video/StreamingShotChangeDetection.java @@ -28,16 +28,19 @@ import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient; import com.google.cloud.videointelligence.v1p3beta1.VideoSegment; import com.google.protobuf.ByteString; +import io.grpc.StatusRuntimeException; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import java.util.concurrent.TimeoutException; class StreamingShotChangeDetection { // Perform streaming video detection for shot changes - static void streamingShotChangeDetection(String filePath) { + static void streamingShotChangeDetection(String filePath) + throws IOException, TimeoutException, StatusRuntimeException { // String filePath = "path_to_your_video_file"; try (StreamingVideoIntelligenceServiceClient client = @@ -92,8 +95,6 @@ static void streamingShotChangeDetection(String filePath) { System.out.format("Shot: %fs to %fs\n", startTimeOffset, endTimeOffset); } } - } catch (IOException e) { - e.printStackTrace(); } } } diff --git a/video/src/test/java/beta/video/StreamingShotChangeDetectionIT.java b/video/src/test/java/beta/video/StreamingShotChangeDetectionIT.java index bcee3698012..a9f669f63e8 100644 --- a/video/src/test/java/beta/video/StreamingShotChangeDetectionIT.java +++ b/video/src/test/java/beta/video/StreamingShotChangeDetectionIT.java @@ -18,18 +18,24 @@ import static com.google.common.truth.Truth.assertThat; +import io.grpc.StatusRuntimeException; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.PrintStream; +import java.util.concurrent.TimeoutException; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Integration (system) tests for {@link StreamingShotChangeDetection}. */ +/** + * Integration (system) tests for {@link StreamingShotChangeDetection}. + */ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class StreamingShotChangeDetectionIT { + private ByteArrayOutputStream bout; private PrintStream out; private PrintStream originalPrintStream; @@ -50,7 +56,8 @@ public void tearDown() { } @Test - public void testStreamingShotChangeDetection() { + public void testStreamingShotChangeDetection() + throws IOException, TimeoutException, StatusRuntimeException { StreamingShotChangeDetection.streamingShotChangeDetection("resources/cat.mp4"); String got = bout.toString();