You can upload any file type to your Cloudinary account, including audio files.
By default, Cloudinary expects uploaded resources to be images, therefore when uploading any other file type Cloudinary returns an 'Invalid image file' error message. In order to upload non-image resources, you should also set the resource_type
parameter to video
(or raw
).
For uploading an audio file via the Media library, you should first click on the "Videos and Audio" button on the upper-right side of the Media library, and then you should be able to upload it.
You can even perform transformations on your audios. For example:
https://res.cloudinary.com/demo/video/upload/so_3,eo_6/dog-audio.mp3
For more information:
https://cloudinary.com/documentation/audio_transformations#audio_transformation_and_streaming
Comments
9 comments
I tried uploading but seems it doesnt accept audio files in the free tier
When resource_type is set to 'video' for uploaded audio file (mp3) the duration returned is wrong (in my case 22:50 returned insted of 05:42), also audio is transcoded to wav format.
I am trying to work in React and running into issues. I just want to upload audio files via the video resource type from a React front end / node back end and then add the meta data to the database????
So far all documentation has been limited. Any help?
@lori bannon
Exact implementation varies depending on what you're trying to accomplish but in general, you'd want to use some kind of upload on the React end (probably a form?) which sends the file to the node server. The server then sends the file to cloudinary. You can use the cloudinary node module for that part. You'll have to read up on how file processing works when using forms. You'll most likely need the multer module in node as well.
Thanks Adam,
But I am way past that already. I was able to figure out how to upload the audio files and take the response url that is sent from Cloudinary and put it in my users collection in mongo. From there I just grab that url to play.
Where I am at now is I am trying to stream a video playlist. The demo works on my site, I can bring down one url by using the transformations and overlays but it stops after the first video is done and can't find the next. Arggg. So, troubleshooting that currently.
Would you be able to point me in the direction of anymore information as to where they are at with the Live features?
@Lori
Glad to hear it :) I figured that you were probably past it given the date on your comment but that someone might need that info in the future. It sounds like your solution (storing the remote id or url in mongo) is almost identical to my own solution.
I'm not using video streaming, only images (with transforms) and audio, so I can't help you with that.
Hello! I hope you are well. Where do I set the resource_type when using Rails active storage to upload directly to Cloudinary? I am receiving the Invalid image file error when trying to upload audio, however I do not get this error when I upload video or gltf zip files.
I am uploading media to cloudinary using simple_form. I am not using the Cloudinary Uploader (unless it is secretly being configured and used in the background without me knowing)
This is how I retrieve audio files for my rails app. I am using the free tier.
Please sign in to leave a comment.