0
I am currently using the Google Cloud Platform for a project, in this project I will use a media link from google Storage, with this mp4 media I will transform it into mp3 and "re-uple" for Storage to be used later. I’m using:
cloud_file = "gs://videos_to_transform/teste.mp4" #delete after finish
parser = argparse.ArgumentParser()
parser.add_argument(
"--storage_uri",
type=str,
default= cloud_file,
)
args = parser.parse_args()
clip = args.storage_uri
conv = Converter().convert(clip, 'audio.mp3', {'format':'mp3','audio':{'codec': 'mp3','bitrate':'22050','channels':1}})
To generate the audio file. And:
storage_client = storage.Client()
#creating if the bucket does not exist
try:
# The name for the new bucket
bucket_name = "test_bucket_creation"
# Creates the new bucket
new_bucket = storage_client.create_bucket(bucket_name)
print("Bucket {} created.".format(new_bucke.name))
except:
print("Bucket already exist ")
bucket = storage_client.get_bucket("videos_to_transform")#MUDAR ESSE BUCKET
filename = "%s/%s" % ('folder_name', "audio.mp3")
blob = bucket.blob( filename )
blob.upload_from_filename("audio.mp3")
To upload the generated file to Storage again.
The problem is that no matter how I try to get to that file, it is never found by the function. I have tried ". /audio.mp3", I have tried using the function os.path.dirname(os.path.realpath("audio.mp3"))
to find the path to the file, but none of it works. I’m not sure how Google Cloud Platform works internally, but I believe it’s a linux-based system, and what the code creates stays in the folder where the code is. Anyway, without this functionality the system will not work, and I know it is possible to do this type of upload, because after all no one would use this system if it was so limited.
If anyone has any kind of information to help me upload this file, or just find it, I appreciate it. Thanks in advance!