Convert wav to ogg on app engine (or in javascript?) - javascript

I've built a little app engine app that lets users upload short recordings. Some of the recordings are done in-browser with https://github.com/mattdiamond/Recorderjs, which creates wav files. To save space, I'd like to convert those to ogg before writing them to the app engine datastore, so that I use less of my outgoing bandwidth when I play the audio recordings back to users.
How can I do this? I googled around, and apparently there's a command line tool called oggenc that encodes to ogg -- but I'm pretty sure I can't install that (or, even if I could install it, make calls to it) on app engine.
I found a similar question at Encode audio from getUserMedia() to a .OGG in JavaScript -- this links to https://github.com/jpemartins/speex.js, a project that looks like it might eventually be able to convert from wav to ogg in javascript (which would be great), but, as far as I can tell, does not do so at the moment. At https://github.com/jpemartins/speex.js/issues/4 the authors mentions that WAV -> ... -> OGG is not yet possible.
What else should I try?
Edit: My app engine code is written in Python, so another possibility would be to do the conversion there, with a python module that can convert wav to ogg. I think http://pymedia.org/ can do this, but I'd have to somehow install it on app engine -- is that possible?

Pymedia isn't pure python so you won't be able to use it on app engine.
You probably want to build something on Compute Engine to do this.

Provided it's possible to replace Matt Diamond's recorderjs with its fork, chris-rudmin/Recorderjs (demo page) in AppEngine, this should be feasible. Or first encode to WAV and use opusenc.js (demo page), which is an Emscripten port of the Opusenc tool, to convert a temporary WAV file to Ogg-Opus client side.

Related

is it possible to change the resolucion of a video file with javascript from the front end?

I have saved an MP4 video in a File type variable, is it possible to change the resolution of the video from the frontend?, without using other sources, just manipulating a single file.
try to use dashjs library but i think it works only with mpd videos.
You can transcode a video file on the frontend, i.e. in the browser, using a ffmpeg Javascript implementation.
The one below is well supported and includes examples of transcoding:
https://github.com/ffmpegwasm/ffmpeg.wasm
This will be slower than doing it server side or than using a program on your computer but it is much faster than this type of task used to be in the browser thanks to leveraging Web Assembly language.
You do need to be aware of the need for SharedArrayBuffer support:
Only browsers with SharedArrayBuffer support can use ffmpeg.wasm, you can check HERE for the complete list.
The link referred to above is here:
https://caniuse.com/sharedarraybuffer

How to generate a downloadable video file in front-end Javascript?

I have a purely front-end app (running locally without a proper back-end), and I would like to programmatically generate a downloadable video file (for instance a .mp4). No audio, each frame of the video will be generated from a canvas (or I guess an OffscreenCanvas) using PIXI, and I would like the video to be generated as fast as possible. I’m using Chrome, and I don’t really need to support any other browser.
I've investigated a bit my options and here is what I found:
MediaRecorder, it can directly generate an mp4 file, but the problem is that it only seems to support real-time encoding, which is too slow for me.
VideoEncoder (Chrome only, but that’s not a problem), it can encode frames as fast as the hardware/software permits, but it seems to only create raw video data, which then needs to be containerized in order to make a proper video file.
Assuming the second option is the most promising, I found a few npm packages for manipulating mp4 files:
mp4box, which does not have many downloads (I would prefer not to rely on possibly unmaintained libraries), and there is no clear example of generating an mp4 from scratch anyway, so I’m not sure it supports it.
mux.js, which has more downloads but seems very technical to use, and again I don’t see any simple example of containerizing raw video data.
Is there a way to combine those approaches, or any other way that I have missed?

How to play MP3 in GUI using PyQT

I wanted to create a simple GUI app which selects one of the MP3 files and plays it. Can't seem to find the best library for doing that with PyQT. Therefore need some recommendation on it. Don't mind switch to JavaFX or something if it has more options.
I know GUI is probably outdated nowadays when everything is web. Would Javascript be a better choice?
try vlc module for python to play all types of audio and videos in case needed later. You should make use of the Qt example seen in examples folder when you unzip the downloaded tar file

Is it possible to record sound playing in browser or speaker in javascript or by any scripting language?

I have used html audio tags for playing multiple mp3 file in browser. I want to know if it is possible to record these mp3's into a single mp3 file in javascript(specifically)?. Or even if any module which can help me record these playing mp3's.
Generally, no.
It is possible to work with audio in JS but probably not in the way you want. See this question for more info.
I don't know what exactly you're trying to do but it seems like you would need to do it server-side, and even that would take effort to achieve (Since you would need to find a library that could merge multiple MP3s into a single file and then serve that as a download to the user. This would also require you to know how to install such software and make it available to your server-side code).

Is it possible to convert a mp3 file to m4r with Javascript or jQuery?

Is it possible with Javascript or jQuery to convert mp3, wav, etc. to m4r format?
Let's assume you had a library that can change the format of files.
Let's also assume you only need the application to work on current browsers that implement FileAPI or FileReference so you can have access to uploaded files (you can't have access to them without FileAPI or FileReference unless you use Flash or Java Applets or equivalent technologies).
You wouldn't be able to write the output file back to the user because JavaScript is not allowed to access the local filesystem.
Your only solution would become sending the converted file to the server and the server sending it back to you with a force download directive so that the user will be prompted to download the results.
Now back to if there were a library that can the conversion (or even native JavaScript)... I haven't heard of any. It's not impossible to build one but it is impractical and wouldn't run very fast.
Edit:
Let's not forget Node.js!
It's a backend server that uses Google Chrome's V8 JavaScript interpretor/compiler. And it runs JavaScript as a backend scripting engine.
You have access to filesystem, databases and everything if you use that (or any other backend system for that matter) and still be using JavaScript. You can use libraries too. Either written in JavaScript or libraries written in other languages that have been linked to interface with Node.js.
Edit 2:
There is a PC emulator written entirely in JavaScript. It runs binary executables if you want it to. It's called JSLinux.
If you're feeling particularly rambunctious you can grab the ffmpeg binary executable (compiled with static linking). And embed it into your application code as an uuencoded string then use JSLinux to execute the commands and grab the results.
Indeed, it is possible doing this on the client using the latest js technologies. A web-worker thread can do the work in the background. At least in Firefox and Chrome it is also possible to read ("upload in memory") and write ("download from memory") files using the new W3C File API, see here.
I managed to read files via drag&drop from and within the client using google's GWT which in the end is plain javascript, so it must also be possible to do it "natively".
Besides that, the conversation algorithm of course has to be implemented in a javascript web worker to avoid blocking the gui. This should be the hardest part, but not impossible, though.
You would need a backend to do this. You may want to look into the PHPExtension of FFmpeg

Categories