diff --git a/video/cloud-client/resources/cat.mp4 b/video/cloud-client/resources/cat.mp4 new file mode 100644 index 00000000000..0e071b9ec67 Binary files /dev/null and b/video/cloud-client/resources/cat.mp4 differ diff --git a/video/cloud-client/src/main/java/com/example/video/Detect.java b/video/cloud-client/src/main/java/com/example/video/Detect.java index 7befe4104a8..e31f4414998 100644 --- a/video/cloud-client/src/main/java/com/example/video/Detect.java +++ b/video/cloud-client/src/main/java/com/example/video/Detect.java @@ -179,13 +179,11 @@ public static void analyzeLabelsFile(String filePath) throws Exception { // Read file and encode into Base64 Path path = Paths.get(filePath); byte[] data = Files.readAllBytes(path); - byte[] encodedBytes = Base64.encodeBase64(data); AnnotateVideoRequest request = AnnotateVideoRequest.newBuilder() - .setInputContent(ByteString.copyFrom(encodedBytes)) + .setInputContent(ByteString.copyFrom(data)) .addFeatures(Feature.LABEL_DETECTION) .build(); - // Create an operation that will contain the response when the operation completes. OperationFuture response = client.annotateVideoAsync(request); diff --git a/video/cloud-client/src/test/java/com/example/video/DetectIT.java b/video/cloud-client/src/test/java/com/example/video/DetectIT.java index a86e119fbf3..fcc7a50cb85 100644 --- a/video/cloud-client/src/test/java/com/example/video/DetectIT.java +++ b/video/cloud-client/src/test/java/com/example/video/DetectIT.java @@ -33,7 +33,8 @@ public class DetectIT { private ByteArrayOutputStream bout; private PrintStream out; - static final String LABEL_FILE_LOCATION = "gs://demomaker/cat.mp4"; + static final String LABEL_GCS_LOCATION = "gs://demomaker/cat.mp4"; + static final String LABEL_FILE_LOCATION = "./resources/cat.mp4"; static final String SHOTS_FILE_LOCATION = "gs://demomaker/gbikes_dinosaur.mp4"; static final String EXPLICIT_CONTENT_LOCATION = "gs://demomaker/cat.mp4"; @@ -51,7 +52,16 @@ public void tearDown() { @Test public void testLabels() throws Exception { - String[] args = {"labels", LABEL_FILE_LOCATION}; + String[] args = {"labels", LABEL_GCS_LOCATION}; + Detect.argsHelper(args); + String got = bout.toString(); + // Test that the video with a cat has the whiskers label (may change). + assertThat(got.toUpperCase()).contains("WHISKERS"); + } + + @Test + public void testLabelsFile() throws Exception { + String[] args = {"labels-file", LABEL_FILE_LOCATION}; Detect.argsHelper(args); String got = bout.toString(); // Test that the video with a cat has the whiskers label (may change).