Converting any audio format to mp3
I use the cloudinary api to upload audio recordings from our app to cloudinary, these can arrive at the server in various formats (mp4, webm, ogg) but I want them all to be converted to mp3. I use upload_stream to upload the stream to cloudinary but I'm struggling to find documentation on how to convert the stream whilst uploading. I've tried changing the url that is used on the audio element on playback (adding f_mp3 as a transformation) but this results in the audio being cut to 1s. I'm struggling to come up with a working solution so any help would be appreciated.
-
Managed to find a workaround. For iOS devices I change the url to end in ".mp3" and for anything else I'm using ".mp4" and that seems to handle the playback issue. Need to do some more rigorous testing but that's OK for now.
However, I now have a problem with some backend processing. I use the url api to download the file from cloudinary as a wav file. This is OK for webm recordings sourced from Chrome but when I download recordings from cloudinary that were initially recorded on Safari (mp4 format), the resultant file is only 1s long.
This is a similar problem to the one I was experiencing earlier. Is this a bug?
0 -
Hi Gez,
It does sound like it could be a bug, what was the public id of the asset that you initially recorded on Safari and resulted in a similar issue? I want test it out on my end to confirm.
Regards,
Daniel0 -
Hi Daniel,
Thanks for looking into it for me. Here's the public id for one of the failing recordings: voice_recording-5c7ec281b96be5aad73b4887-613d93917dbaae9e764130a7.
Hopefully we can get to the bottom of what's going on.
Thanks
Gez
0 -
Hi Gez,
This is a bug and I have reported it to our team.
I do not have an ETA of when this will be resolved. I also see that you mentioned that you were getting a 1s clip of file voice_recording-5c7ec281b96be5aad73b4887-613d93917dbaae9e764130a7 when you set the format to mp4? Is that correct? I was able to download it as mp4 just fine, but only get 1s when downloading it to mp3.0 -
Hi Daniel,
Thanks for letting me know. I was getting the problem when downloading it as a .wav file. It's originally an mp4 file so that's why you probably don't see an error when downloading it in that format. I can do some further testing to see which file formats don't download as expected when converting the format if that helps? I don't think it's isolated to mp4 - > mp3/wav.
Thanks
Gez
0 -
Hi Gez,
Just to confirm, is the issue you observed with this specific voice_recording-5c7ec281b96be5aad73b4887-613d93917dbaae9e764130a7 converting it mp3/wav?
Do you also have similar issue with different audio? If yes, can you share that as well? In the mean time we are still checking why the above audio only generated 1s audio to mp3/wav.
0 -
Hi Gez,
This issue is happening for any transformations done to an audio file. So to confirm, it is not isolated to mp4->mp3 e.g if you do mp4 -> w_100/mp4, It won't work.
Unfortunately, there isn't a workaround for this. We will need to upgrade to a newer version of ffmpeg and this requires a lot of work. This is already in our roadmap and the team is looking at the best way to do it, however I don't have any ETA for now.
Hope that makes sense.
Best,
Loic
0 -
Yep, I was just about to send you a list of public_urls where the issue is present. For us, the main file conversions we're interested in are mp4/ogg/webm --> mp3/wav.
Yes, that makes sense. I'd looked into doing it ourselves with ffmpeg but opted for the cloudinary option as it seemed more straightforward. Guess I'll have to return to working on that solution for now.
Hope you can get something sorted for cloudinary as it is a powerful feature to offer. Any way I can track progress or be alerted once it has been implemented?
0 -
Hi Gez,
Sure, we will update here once we have any new information.
0
Post is closed for comments.
Comments
9 comments