因此,我使用moviepy
库从位于googlecloud bucket上的视频文件中获取gif。到目前为止,我正在使用google-cloud-storage
包执行save&read操作。但我用的是包方法。现在moviepy需要一个filepath作为参数来运行它的write_gif
方法来生成gif。过了一段时间,我想我可以用gsutil
的解决方案。我遇到了^{
vfile = 'https://storage.googleapis.com/test.appspot.com/dir/sample.mp4'
tfile = 'https://storage.googleapis.com/test.appspot.com/dir/sample.gif' #non-existant-file
clip = VideoFileClip(vfile)
gifClip = clip.subclip(8, 10)
target_gc_thumb = bucket.blob('dir/sample.gif')
target_gc_thumb.upload_from_string('',content_type='image/gif') #blank-gif-file-saved
fs = gcsfs.GCSFileSystem(project='test')
with fs.open('test.appspot.com/dir/sample.gif', 'w', metadata={"Content-Type":"image/gif"}) as f:
gifClip.write_gif(f,fps=5) #raises-error-since-it-expects-a-local-file-path
clip.close()
由于未传递表示本地文件路径的字符串,因此出现此错误:
Could not find a format to write the specified file in mode '?'
**我使用的是谷歌应用引擎标准版。因此,不需要任何与写入本地存储相关的建议。你知道吗
你的fs.打开找不到您指定的路径。首先尝试列出该文件夹或路径下的文件,然后尝试使用该文件。你知道吗
创建文件,然后打开进行写入
https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/read-write-to-cloud-storage
相关问题 更多 >
编程相关推荐