A partire dal 14 settembre 2026, l'API Video Intelligence è ufficialmente ritirata e non sarà più supportata. Puoi continuare a utilizzare l'API Video Intelligence fino al 14 settembre 2027, data in cui verrà ritirata. Ti consigliamo di eseguire la migrazione alla famiglia di modelli Gemini.
Google utilizza la tecnologia AI per tradurre i contenuti nella tua lingua preferita. Le traduzioni generate dall'AI potrebbero contenere errori.
Contenuti espliciti
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
_Rilevamento di contenuti espliciti_
rileva contenuti per adulti all'interno di un video.
I contenuti per adulti sono contenuti generalmente inappropriati per le persone di età inferiore a 18 anni, inclusi, a titolo esemplificativo, nudità, attività sessuali
e pornografia. Vengono identificati anche i contenuti di questo tipo rilevati in cartoni animati o anime.
Il seguente esempio di codice mostra come rilevare la presenza di contenuti espliciti utilizzando la libreria client di streaming.
importcom.google.api.gax.rpc.BidiStream;importcom.google.cloud.videointelligence.v1p3beta1.ExplicitContentFrame;importcom.google.cloud.videointelligence.v1p3beta1.StreamingAnnotateVideoRequest;importcom.google.cloud.videointelligence.v1p3beta1.StreamingAnnotateVideoResponse;importcom.google.cloud.videointelligence.v1p3beta1.StreamingFeature;importcom.google.cloud.videointelligence.v1p3beta1.StreamingLabelDetectionConfig;importcom.google.cloud.videointelligence.v1p3beta1.StreamingVideoAnnotationResults;importcom.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;importcom.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;importcom.google.protobuf.ByteString;importio.grpc.StatusRuntimeException;importjava.io.IOException;importjava.nio.file.Files;importjava.nio.file.Path;importjava.nio.file.Paths;importjava.util.Arrays;importjava.util.concurrent.TimeoutException;classStreamingExplicitContentDetection{// Perform streaming video detection for explicit contentstaticvoidstreamingExplicitContentDetection(StringfilePath)throwsIOException,TimeoutException,StatusRuntimeException{// String filePath = "path_to_your_video_file";try(StreamingVideoIntelligenceServiceClientclient=StreamingVideoIntelligenceServiceClient.create()){Pathpath=Paths.get(filePath);byte[]data=Files.readAllBytes(path);// Set the chunk size to 5MB (recommended less than 10MB).intchunkSize=5*1024*1024;intnumChunks=(int)Math.ceil((double)data.length/chunkSize);StreamingLabelDetectionConfiglabelConfig=StreamingLabelDetectionConfig.newBuilder().setStationaryCamera(false).build();StreamingVideoConfigstreamingVideoConfig=StreamingVideoConfig.newBuilder().setFeature(StreamingFeature.STREAMING_EXPLICIT_CONTENT_DETECTION).setLabelDetectionConfig(labelConfig).build();<BidiStreamStreamingAnnotateVideoRequest,StreamingAnnotateVid>eoResponsecall=client.streamingAnnotateVideoCallable().call();// The first request must **only** contain the audio configuration:call.send(StreamingAnnotateVideoRequest.newBuilder().setVideoConfig(streamingVideoConfig).build());// Subsequent requests must **only** contain the audio data.// Send the requests in chunksfor(int<i=0;inumChunks;i++){call.send(StreamingAnnotateVideoRequest.newBuilder().setInputContent(ByteString.copyFrom(Arrays.copyOfRange(data,i*chunkSize,i*chunkSize+chunkSize))).build());}// Tell the service you are done sending datacall.closeSend();for(StreamingAnnotateVideoResponseresponse:call){StreamingVideoAnnotationResultsannotationResults=response.getAnnotationResults();for(ExplicitContentFrameframe:annotationResults.getExplicitAnnotation().getFramesList()){doubleoffset=frame.getTimeOffset().getSeconds()+frame.getTimeOffset().getNanos()/1e9;System.out.format("Offset: %f\n",offset);System.out.format("\tPornography: %s",frame.getPornographyLikelihood());}}}}}
/** * TODO(developer): Uncomment these variables before running the sample. */// const path = 'Local file to analyze, e.g. ./my-file.mp4';const{StreamingVideoIntelligenceServiceClient}=require('@google-cloud/video-intelligence').v1p3beta1;constfs=require('fs');// Instantiates a clientconstclient=newStreamingVideoIntelligenceServiceClient();// Streaming configurationconstconfigRequest={videoConfig:{feature:'STREAMING_EXPLICIT_CONTENT_DETECTION',},};constreadStream=fs.createReadStream(path,{highWaterMark:5*1024*1024,//chunk size set to 5MB (recommended less than 10MB)encoding:'base64',});//Load file contentconstchunk>s=[];readStream.on('data',chunk={constrequest={inputContent:chunk.toString(),}; > chunks.push(request);}).on('close',()={// configRequest should be the first in the stream of requests<
stream.write(configRequest);for(leti=0;ichunks.length;i++){stream.write(chunks[i]);}stream.end();});conststream>=client.streamingAnnotateVideo().on('data',response={//Gets annotations for videoconstannotations=response.annotationResults;constexplicitContentResults=annotations.expl>icitAnnotation.frames;explicitContentResults.forEach(result={console.log(`Time: ${result.timeOffset.seconds||0}`+`.${(result.timeOffset.nanos/1e6).toFixed(0)}s`);console.log(` Pornography likelihood: ${result.pornographyLikelihood}`);});});
fromgoogle.cloudimportvideointelligence_v1p3beta1asvideointelligence# path = 'path_to_file'client=videointelligence.StreamingVideoIntelligenceServiceClient()# Set streaming config.config=videointelligence.StreamingVideoConfig(feature=(videointelligence.StreamingFeature.STREAMING_EXPLICIT_CONTENT_DETECTION))# config_request should be the first in the stream of requests.config_request=videointelligence.StreamingAnnotateVideoRequest(video_config=config)# Set the chunk size to 5MB (recommended less than 10MB).chunk_size=5*1024*1024# Load file content.stream=[]withio.open(path,"rb")asvideo_file:whileTrue:data=video_file.read(chunk_size)ifnotdata:breakstream.append(data)defstream_generator():yieldconfig_requestforchunkinstream:yieldvideointelligence.StreamingAnnotateVideoRequest(input_content=chunk)requests=stream_generator()# streaming_annotate_video returns a generator.# The default timeout is about 300 seconds.# To process longer videos it should be set to# larger than the length (in seconds) of the stream.responses=client.streaming_annotate_video(requests,timeout=900)# Each response corresponds to about 1 second of video.forresponseinresponses:# Check for errors.ifresponse.error.message:print(response.error.message)breakforframeinresponse.annotation_results.explicit_annotation.frames:time_offset=(frame.time_offset.seconds+frame.time_offset.microseconds/1e6)pornography_likelihood=videointelligence.Likelihood(frame.pornography_likelihood)print("Time: {}s".format(time_offset))print("\tpornogaphy: {}".format(pornography_likelihood.name))
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2026-10-25 UTC."],[],[]]