0

On providing a local path to the Google Cloud Video Intelligence Api for a Video file to be processed for labels (CODE),it gave a syntax error.All relevant files are stored in the same folder.Which other possible syntax can be used or does one have to upload video files to the Cloud for processing?

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       25-07-2019     18:45                other
-a----       25-07-2019     17:20           2315 NykyVideoApi-5504e860576e.json
-a----       25-07-2019     17:24       47906730 sampleVid.m4v
-a----       25-07-2019     18:48           1808 VideoLabels.py  

SYNTAX 1

   PS D:\Script\GCloud> d:\Script\GCloud\VideoLabels.py
  File "D:\Script\GCloud\VideoLabels.py", line 7
    def analyze_labels('sampleVid.m4v'):
                                     ^
SyntaxError: invalid syntax  

SYNTAX 2

PS D:\Script\GCloud> d:\Script\GCloud\VideoLabels.py
  File "D:\Script\GCloud\VideoLabels.py", line 7
    def analyze_labels('D:\Script\GCloud\sampleVid.m4v'):
                                                      ^
SyntaxError: invalid syntax
srt111
  • 1,079
  • 11
  • 20

2 Answers2

0

When you are passing values to a function it literally expects you to use them inside (or there is no point of passing the values) so you cannot use the values if you don't assign it to a variable.

Just do this and you are good to go

def analyze_labels(a = 'sampleVid.m4v'):
  # use the variable 'a' 
   print(a)  #should work.

def analyze_labels(a = 'D:\Script\GCloud\sampleVid.m4v'):
    return a #should work.
Sundeep Pidugu
  • 2,377
  • 2
  • 21
  • 43
  • Make sure you approve the answer if answered – Sundeep Pidugu Jul 25 '19 at 13:53
  • 1
    Google Vision Api has a similar function to detect image labels and on providing local filename (as provided in the above question- without a variable assigned ) it processes and provides the label output.Anyways,,on further inquiry the VideoApi does not accept local files as input so any more time spent on the code would be a waste. – srt111 Jul 25 '19 at 15:43
0

In the documentation you referenced it says which means your file needs to be in Cloud Storage and not your local directory:

Takes a video file stored in Google Cloud Storage URI as an argument and passes it to the main() function

You need to upload your file to Google Cloud Storage and use the GCS URI (e.g. "gs://[bucket_name]/[path to file]/[filename]", "gs://yourbucket/sampleVid.m4v")

Christopher
  • 895
  • 6
  • 15
  • Yeah, the VideoIntelligence Api no longer accepts local files(there is code which lets video uploads from the local files in the documentation referenced ,but on checking with Google they recommend cloud upload)... , but now there is a new issue .On uploading ,mp4 files to the Cloud storage bucket , it shuts down abruptly (~1%) after the upload begins.Not sure how to get these .mp4 files for VideoIntelligence Api processing. – srt111 Jul 26 '19 at 11:56
  • You may want to create a new SO post for your new issue and include relevant details such as how are you uploading the file/s to GCS, etc. – Christopher Jul 26 '19 at 12:54