I have an App Engine app that is handling videos with MoviePy, I have a step where I am supposed to cut the client's video and saving the parts into the bucket, but, I am facing an issue. The file uploaded to the bucket is only 262 bytes, thus not containing the contents it supposed to contain.
My code:
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
from google.cloud import storage
from flask import Flask
app = Flask(__name__)
@app.route('/circle', methods=['GET', 'POST'])
def circle():
gcs_client = storage.Client.from_service_account_json(key_file_path)
bucket = gcs_client.get_bucket("mybucket")
blob = bucket.blob("test.mp4")
url = blob.generate_signed_url(datetime.timedelta(seconds=3000), method='GET')
ffmpeg_extract_subclip(url, 10, 5, targetname="/tmp/xy1.mp4")
ffmpeg_extract_subclip(url, 25, 8, targetname="/tmp/yz1.mp4")
blob = bucket.blob("xy1.mp4")
blob.upload_from_filename("/tmp/xy1.mp4", if_generation_match=None, if_metageneration_match=None, content_type='video/mp4')
blob.cache_control = "public, max-age=0"
blob.patch()
blob = bucket.blob("yz1.mp4")
blob.upload_from_filename("/tmp/yz1.mp4", if_generation_match=None, if_metageneration_match=None, content_type='video/mp4')
blob.cache_control = "public, max-age=0"
blob.patch()
The problem is that when the file is sent to the GCS Bucket, it shows this:
It suppose to be an playable video file, neither empty nor corrupted.
While I was testing it over and over again, one time it managed to work, the playable video was successfully uploaded to the bucket. After that, I tested it again and again, and it never worked again. Not sure why...
Any help appreciated.
