This codebase is for a talk at Prairie Dev Con in June 2019. Slides can be found here. The demo will take an MP3 file and generate a waveform png via ffmpeg up on Google Cloud Platform.
prdc-generateUploadLink
- Generates a "signed URL" that a user will be able to POST an MP3 to. The MP3 is placed in a bucket called prdc19-audio-upload
.
prdc-generateWaveform
- Is triggered from MP3s being placed in the prdc19-audio-upload
bucket and will generate a waveform png into the prdc19-waveform
bucuket and will pass back a link to it.
- Install gcloud SDK for your chosen platform
- Google Cloud Platform Service account
- The service account must have the following IAM role:
Service Account Token Creator
- The service account must have the following IAM role:
- Google Cloud Function & Google Cloud Storage must be enabled
- Create two GCS buckets:
prdc19-audio-upload
&prdc19-waveform
- The
prdc-waveform
bucket should haveallUsers
read-access such that the pngs being generated are accessible publically
- The
git clone git@github.com:ctataryn/prdc19-gcf-waveform.git
gcloud functions deploy prdc-generateUploadLink --entry-point generateUploadLink --memory 128MB --runtime nodejs8 --timeout 10s --trigger-http
gcloud functions deploy prdc-generateWaveform --entry-point generateWaveform --memory 1024MB --runtime nodejs8 --timeout 540s --trigger-bucket prdc19-audio-upload
To generate an upload link for an MP3:
https://us-central1-crowdscriber.cloudfunctions.net/prdc-generateUploadLink?id=this-is-a-test-id
To upload the MP3 and generate a waveform png:
curl -X put -H 'Content-Type: audio/mpeg' --upload-file ./mp3s/test000.mp3 <upload link>
This will upload an MP3 to the prdc19-audio-upload
bucket. The prdc19-generateWaveform
function will
then be triggered, create the waveform png and then send a POST
request to the url specified in the lib/util.js
If you don't have the ability to receive the notification, then just refresh the bucket in the Google Cloud
Platform Web Console until the png appears.