Re: Looking for a method to provide a 5+ second waveform preview as a user plays a <video>

On Tue, Sep 23, 2014 at 6:06 AM, Eric Wescott <wescotte@gmail.com> wrote:

>  I'm creating a subtitle creation tool
> <https://sourceforge.net/projects/quicksubtitles/> that allows the user
> to enter subtitles and sync them to video as it plays. I would like to add
> a feature that displays the next 5 or so seconds of audio data as a
> waveform to the user to help them fine tune the syncing process as well as
> anticipate when to set an in point.
>
> I've tried using an  analyzer but it seems to be limited to 2048 samples
> which is about 120x too small. If I use an audioScript and listen for
> "audioprocess" events I can increase this to 16k but again it's way too
> small a buffer to be useful for my case.
>

Why not have the ScriptProcessor gather up about 20 of these 16k buffers
and then plot them all at once? Or just plot each 16k at the appropriate
point in your graph?


>
> I've also experimented with creating the entire waveform up front
> <http://jsfiddle.net/daofw1g3/8/> which works but unfortunately has
> issues with large files or longer audio clips.  I found if the video file
> is > 1GB the FIle API dispatches an "error" event when I
> readAsArrayBuffer(). So I thought perhaps I have to have the user isolate
> the audio from the but that has it's own issues as well.  I tested it with
> a 80minute 35mb mp3 and while ArrayBuffer is created but then
> decodeAudioData() never runs it's callback function. I assume both cases
> involve a memory limit?
>

Well, 80 min of audio at 44.1 is like 800 MB of data. decodeAudioData
should work, but it may take some time to decode it into memory. Assuming
you have enough memory and process space.

If you don't want to do that, perhaps using a MediaElementAudioSource will
work for you. It will stream the data into the audio graph where you can
process it without having it all in memory.

--
Ray


>
> Can anybody point me in the right direction on how I can access a large
> buffer of samples to provide the user with a 5 second or so  waveform
> preview?
>
> Thanks
> Eric
>
>
>
>

Received on Tuesday, 23 September 2014 20:23:28 UTC