返回视频信息 Video Intelligence API

Returning video information Video Intelligence API

我无法显示本地视频的信息,当我用视频示例做测试时是returning,但是当我用本机的文件尝试时不return任何东西。

public String consultar() throws Throwable {
        requisicaoVideo("C:\Users\Web Designer\Desktop\Placas de Carros\cat.mp4");
        return "analiseForenseVideos.xhtml";
    }
    public void requisicaoVideo(String filePath) throws Exception {
        try (VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.create()) {
            // Read file and encode into Base64
            Path path = Paths.get(filePath);
            byte[] data = Files.readAllBytes(path);
            byte[] encodedBytes = Base64.encodeBase64(data);
            System.out.println(encodedBytes + "Linha 74");
            AnnotateVideoRequest request = AnnotateVideoRequest.newBuilder()
                    .setInputContent(ByteString.copyFrom(encodedBytes)).addFeatures(Feature.LABEL_DETECTION).build();
            // Create an operation that will contain the response when the operation
            // completes.
            OperationFuture<AnnotateVideoResponse, AnnotateVideoProgress> response = client.annotateVideoAsync(request);
            System.out.println("Waiting for operation to complete...");
            System.out.println(response.get().getAnnotationResultsList() + "Linha 83");
            for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) {
                // process video / segment level label annotations
                System.out.println("Locations: ");
                for (LabelAnnotation labelAnnotation : results.getSegmentLabelAnnotationsList()) {
                    System.out.println("Video label: " + labelAnnotation.getEntity().getDescription());
                    // categories
                    for (Entity categoryEntity : labelAnnotation.getCategoryEntitiesList()) {
                        System.out.println("Video label category: " + categoryEntity.getDescription());
                    }
                    // segments
                    for (LabelSegment segment : labelAnnotation.getSegmentsList()) {
                        double startTime = segment.getSegment().getStartTimeOffset().getSeconds()
                                + segment.getSegment().getStartTimeOffset().getNanos() / 1e9;
                        double endTime = segment.getSegment().getEndTimeOffset().getSeconds()
                                + segment.getSegment().getEndTimeOffset().getNanos() / 1e9;
                        System.out.printf("Segment location: %.3f:%.2f\n", startTime, endTime);
                        System.out.println("Confidence: " + segment.getConfidence());
                    }
                }

我有 Google 云支持。 感谢您 报告此问题。我一直在做一些测试,并在 Detect.java 文件的 analyzeLabelsFile 函数中发现了某种错误。

如果你让工作 运行 很长时间,它可能会完成(对我来说,从 Google 云存储导入文件需要 30 秒,使用本地文件需要 16 分钟),但是无论如何不提供信息,只是 "Locations: " 最后的消息。

我已将与此相关的所有信息(如何重现问题、可能的原因等)发送给 Google Video Intelligence API 团队,以便他们查看。

我还没有找到本地文件的解决方法,但您可以通过其 URL 和 analyzeLabels 函数在 GCS 中处理该文件。