Giter VIP home page Giter VIP logo

libvorbis.js's Introduction

libvorbis.js

Build Status

What?

libvorbis.js is an ASM.JS distribution of C libraries libogg, libvorbis, and libvorbisenc. It also includes a library wrapper that implements the W3C MediaRecorder interface**.

Ultimately, libvorbis.js allows you to encode PCM data to Ogg Vorbis in the browser. Ogg Vorbis is a free and open-source codec for lossy audio compression.

libvorbis.js is 216KB big (minified, gzipped) and runs about 3x slower in V8, compared to native. (2.5x in Firefox).

** Full compliance under development.

Why?

Yes, Firefox already supports the MediaRecorder API, which renders this library useless.

Unfortunately, Chromium (Chrome) does not yet ship a public, audio-capable implementation of MediaRecorder. (It should arrive with Chromium 49.)

libvorbis.js aims to fill this void for the time being.

Besides this, encoding audio in the browser is beneficial in the following ways:

  • Reduces server load; all the hard work is done in the client's browser

  • Reduces browser storage usage (IndexedDB / Web Storage)

  • Reduces upload time and data transfer; encoded audio files are a fraction of the size of raw WAV files

OK, cool. What now?

Demo it.

Bare bones recorder

Voice Memos fork (original by: Paul Lewis)

Install it.

You can use bower to install libvorbis.js as a dependency:

bower install libvorbis.js

Download it.

Download from the distribution repo.

Build it.

Requirements

  • emscripten compiler
  • node.js & npm

Preparations

npm install --dev

That should install (locally):

  • TypeScript 1.8+ compiler
  • TypeScript Definition Manager
  • UglifyJS

Instructions

git submodule init
git submodule update
make -j

Then, look for build/libvorbis.js or build/libvorbis.min.js.

Credits

Ogg License (BSD)

Copyright (c) 2002, Xiph.org Foundation

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Vorbis License (BSD)

Copyright (c) 2002-2015 Xiph.org Foundation

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

libvorbis.js's People

Contributors

garciat avatar devongovett avatar itsjoesullivan avatar shovon avatar danielbanfield avatar

Stargazers

Alexander-Lee Couchy avatar Tim Daubenschütz avatar Hajime Hoshi avatar jero07 avatar Khaled Monsoor avatar Khaled Monsoor avatar Martin Dahlgren avatar Ryan avatar  avatar Stephen Eisenhauer avatar  avatar Jason Moran avatar Thijs Triemstra avatar Yuji Miyane avatar Phyo Arkar Lwin avatar

Watchers

 avatar James Cloos avatar Khaled Monsoor avatar

libvorbis.js's Issues

Problem during encoding

Compatibility with IE11

I get an error when the libvorbis.js script is included in IE11. I am using a virtual machine that I got from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/#downloads to test the website that I am developing in IE11.

IE
Version: v11.0.9600.17420
Update Versions: 11.0.14 (KB3003057)

Error message:
libvorbis.js: 71: var script = document.currentScript;
libvorbis.js: 72: var scriptSrc = script.getAttribute('src'); Unable to get property 'getAttribute' of undefined or null reference.

Typescript code:
libvorbis.head.ts: 103: const script = <HTMLScriptElement>(<any> document).currentScript;
libvorbis.head.ts: 104: const scriptSrc = script.getAttribute('src');

Add `version` to `package.json`

It would be great to have a version field in package.json, so that this package could actually be installed with npm.
Currently, if I try the following dependency:

"dependencies": {
"package": "git://github.com/Garciat/libvorbis.js"
}

npm install fails with No version provided in package.json

NPM module

Hello! Just trying to use this in a little Node script I have to pack some content, and probably just missing something about the use of this module.

I ran the following to list the exported functions:

const vorbis = require("libvorbis.js")
console.log((Object.keys(vorbis).filter(k => vorbis[k] instanceof Function)).join("\n"))

This gave me a large list, which seems to all be internal implementation details.

print
printErr
read
readBinary
load
inspect
ccall
cwrap
setValue
getValue
allocate
getMemory
Pointer_stringify
AsciiToString
stringToAscii
UTF8ArrayToString
UTF8ToString
stringToUTF8Array
stringToUTF8
lengthBytesUTF8
UTF16ToString
stringToUTF16
lengthBytesUTF16
UTF32ToString
stringToUTF32
lengthBytesUTF32
stackTrace
addOnPreRun
addOnInit
addOnPreMain
addOnExit
addOnPostRun
intArrayFromString
intArrayToString
writeStringToMemory
writeArrayToMemory
writeAsciiToMemory
addRunDependency
removeRunDependency
_memset
_bitshift64Shl
_i64Add
_bitshift64Lshr
_memcpy
_memmove
_llvm_bswap_i32
_vorbis_analysis
_oggpack_write
_oggpack_writeinit
_encoder_encode
_encoder_prepare_analysis_buffers
_encoder_get_data_len
_vorbis_comment_init
_vorbis_info_clear
_encoder_finish
_vorbis_analysis_headerout
_encoder_get_data
_encoder_write_headers
_oggpack_bytes
_oggpack_look
_vorbis_info_init
_ogg_stream_flush
_oggpack_writeclear
_ogg_stream_init
_vorbis_encode_init_vbr
_encoder_get_analysis_buffer
_vorbis_analysis_buffer
_encoder_clear_data
_ogg_stream_clear
_oggpack_read
_oggpack_get_buffer
_ogg_stream_pageout
_vorbis_comment_clear
_vorbis_comment_add_tag
_oggpack_adv
_free
runPostSets
_ogg_stream_packetin
_encoder_create_vbr
_malloc
_encoder_destroy
_oggpack_writetrunc
dynCall_iiiiii
dynCall_vi
dynCall_vii
dynCall_iiiii
dynCall_iiiiiiiii
dynCall_iii
callMain
run
exit
abort

Is this module intended to be used from Node scripts, and if so, which functions should I be calling?

Thanks.

Encoded file is longer than original

Hi,
Thanks for the great lib.
I've read that lossless encoding can add time to a file but wondering if there is something else going on. I took code pretty much straight from the example. I've tried a range of input files (although all from the same wav file pack) and get changes like
Input: 5.33 secs
Output: 5.97 secs

Just want to confirm if that kind of additional length is expected - i need precise length of original as use case is music looping.
Thanks
Dan

config options to pass to `VorbisMediaRecorder` ?

hello,

i am using your demo project to apply it on one of mine. While the recording is working, but the output file too small. e.g. 45KB for a 7-min recording.
i've tried both passing and not passing audioBitsPerSecond option while init VorbisMediaRecorder.

i am wondering what else the options could be. As the libvorbis.min.js is already minified, i am being unable to look it up myself.

would you please give me some pointers ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.