ScratchAddons / ScratchAddons

All-in-one browser extension for Scratch.
https://scratchaddons.com
GNU General Public License v3.0
716 stars 367 forks source link

Upload any sound of any file format and try to convert it to a wav or mp3 file #6515

Open hueychen27 opened 1 year ago

hueychen27 commented 1 year ago

Why this would be helpful

Sometimes, the audio file I want to upload is not a .wav or .mp3 file so I have to use Audacity or an audio converter which takes a little while. People (especially those with school Chromebooks) who don't have access to audio converters and Audacity might find this to be a helpful addon.

How this addon works

Use ffmpeg to convert audio files that are not .mp3 or .wav files into them. Let the user choose the bitrate, audio type (.mp3 or .wav), and volume (100% default). If the file is too big or ffmpeg returns an error, abort.
If the user wants to upload a video, ffmpeg probably should extract the audio from it.

Possible alternatives

No response

Additional context

No response

DNin01 commented 1 year ago

Why not just use a browser extension dedicated to content conversion or conversion websites like CloudConvert? An addon can't really speed up the process other than reducing the number of steps, so this probably isn't a priority.

BroJac5246 commented 1 year ago

It is pretty fast to use CloudConvert. That's what I do on my Chromebook.

However, I still support this addon. It would be very useful.

I'm guessing this would require a third-party API?

WorldLanguages commented 1 year ago

I guess we could provide an addon that opens a CloudConvert tab on behalf of the user so that all steps need less clicks. But it should be transparent to the user that their file is being uploaded to a third party service.

We could also try doing the conversion locally, but that leaves all of that complexity for us to handle (and with a fast enough internet connection, uploading and downloading might be faster than processing locally)

penguinmoose commented 1 year ago

Since this is mostly just a convenience feature, the user should be able to simply drag-and-drop or upload any file type without having to stop and choose the audio format. Basically, it would simply allow more file formats to be used via conversion. The conversion settings can be stored in the addon.

Keep in mind that the cloudconvert API is paid, at $9 per 1000 files per month. Of course, the service itself can do 25 conversions a day (enough?) for free. It really depends on how many people actually use this addon.

Samq64 commented 1 year ago

Keep in mind that the cloudconvert API is paid, at $9 per 1000 files per month. Of course, the service itself can do 25 conversions a day (enough?) for free. It really depends on how many people actually use this addon.

Not if 10 users convert more than 2 files in a day.

WorldLanguages commented 1 year ago

We're a browser extension, we don't need to use the API. We can open tabs and click on buttons on behalf of the user.

Secret-chest commented 1 year ago

Why not do it locally?

apple502j commented 1 year ago

I'm pretty sure most file formats you want to process can be decoded into WAV without any external tools. (Such as FLAC, ogg, WebM)

The problem is not the conversion, but the file size limit, since converting them to WAV increases the size by a lot. And no, there is no browser API to encode a sound to MP3.

WorldLanguages commented 1 year ago

Why not do it locally?

We could, did anyone research that? How much complexity and which libraries do we need to support the most common formats?

GarboMuffin commented 1 year ago

You can decode any audio file using an AudioContext to get the raw samples (you can use the one scratch-audio already has), then use something like wav-encoder (what Scratch uses, 200 lines, no dependencies) to make a file Scratch will natively support

H-A-M-G-E-R commented 1 year ago

you can rename an .ogg to .ogg.wav and keep it at the original size

H-A-M-G-E-R commented 1 year ago

that's how i import an .ogg in vanilla scratch

Samq64 commented 1 year ago

you can rename an .ogg to .ogg.wav and keep it at the original size

Renaming the file extension doesn't convert the file.

that's how i import an .ogg in vanilla scratch

Scratch will let you upload it but I doubt it would play unless Scratch also already supports .ogg files.

GarboMuffin commented 1 year ago

The browser is what decodes the audio so it "accidentally" supporting ogg is likely

Will Scratch actually let you upload the ogg (disguised as wav) to their servers without editing it?

hueychen27 commented 1 year ago

Good ideas.

H-A-M-G-E-R commented 1 year ago

in the offline editor it also supports ogg disguised as wav

H-A-M-G-E-R commented 1 year ago

i don't convert ogg to mp3 or wav because for mp3, it makes audio quality worse because of lossy compression and for wav, it makes it bigger