Note: You MUST always manually create a directory and name it "uploads".
=
npm install recordrtc
// to run it!
cd ./node_modules/recordrtc/ && node index.js
Make sure that directory names MUST NOT have spaces; e.g.
// invalid directory
C:\Hello Sir\Another\RecordRTC
// valid
C:\Hello-Sir\Another\RecordRTC
// invalid directory
C:\First\Second Dir\Third\RecordRTC
// valid
C:\\First\Second-Dir\Third\RecordRTC
This experiment:
- Records audio/video separately as wav/webm
- POST both files in single HttpPost-Request to Node.js (FormData)
- Node.js code saves both files into disk
- Node.js code invokes ffmpeg to merge wav/webm in single "webm" file
- The merged webm file's URL is returned using same HTTP-callback for playback!
=
Windows Batch File (merger.bat
)
merger.bat
file is executed to invoke ffmpeg functionalities on windows:
@echo off
ffmpeg -i audio-file.wav -i video-file.webm 0:0 -map 1:0 output-file-name.webm
It is assumed that you already have installed ffmpeg on your system. Though, EXE file is hard-coded to "C:\ffmpeg\bin\ffmpeg.exe" however you can easily edit it according to your own installations.
=
.sh
file
merger.sh
file is executed to invoke ffmpeg functionalities on Mac/Linux/etc.
ffmpeg -i audio-file.wav -i video-file.webm -map 0:0 -map 1:0 output-file-name.webm
Using Linux; ffmpeg installation is super-easy! You can install DEVEL packages as well.
=
Ubuntu, Debian, or Linux Mint?
You're suggested to install ffmpeg and libvpx from following URL:
Another useful resource is:
Read following comments:
Actually it is very easy to install FFmpeg under Ubuntu with the apt-get command.
Unfortunately, the default FFmpeg installation doesn't let you include the latest codecs
which are needed to merge WAV/WebM into vp8 encoded video i.e. WebM!
Thus you have to compile FFmpeg yourself!
For example, you can check libvpx installation using following command:
dpkg -s libvpx | grep Status
This doesn't mean that you enabled libvpx for ffmpeg; you need to verify vp8 encoders in ffmpeg using following commands:
ffmpeg -codecs # to check list of all decoders
ffmpeg -encoders # to check list of all encoders
Usually latest ffmpeg can decode WebM i.e. vp8 codecs; however it can't encode back into vp8 until you manually install libvpx.
There is another useful resource!
This provides a good command to check list of encoders in ffmpeg:
ffmpeg -encoders|grep -E "mp3|xvid|aac|gsm|amr|x264|theora|vorbis"
Sometimes you mistakenly install multiple ffmpeg instances. Find-out ffmpeg instance that has included libvpx; then include that instance's full path in the ffmpeg-command. E.g.
ffmpeg -itsoffset -00:00:00 -i audioFile -itsoffset -00:00:00 -i videoFile -map 0:0 -map 1:0 outputFile
=
How to install ffmpeg on windows?
- Download ffmpeg and extract ZIP file
- Rename extracted directory to "ffmpeg"
- Right click over "My Computer" icon and select "Properties" context-menu option
- Select "Advance system settings" from top-left section
- Click "Environment Variables..." button from "Advanced" tab
- Click "New..." button and in the "Variable name" box, enter "Path".
- In the "Variable value" box, enter extracted directory full URI e.g. "C:\ffmpeg"
- Click "OK" and done!
http://www.wikihow.com/Install-FFmpeg-on-Windows
=
How to install ffmpeg on Mac OSX?
Make sure you have homebrew installed. Then run following command:
brew install ffmpeg --with-libvpx --with-theora --with-libogg --with-libvorbis
More info here:
How to test?
In the node.js command prompt window; type node index
; then open http://localhost:8000/
.
=
How to fix audio/video sync issues on chrome?
recordAudio = RecordRTC( stream, {
onAudioProcessStarted: function( ) {
recordVideo.startRecording();
}
});
recordVideo = RecordRTC(stream, {
type: 'video'
});
recordAudio.startRecording();
onAudioProcessStarted
fixes shared/exclusive audio gap (a little bit). Because shared audio sometimes causes 100ms delay...
sometime about 400-to-500 ms delay.
Delay depends upon number of applications concurrently requesting same audio devices and CPU/Memory available.
Shared mode is the only mode currently available on 90% of windows systems especially on windows 7.
=
Want to recording only audio?
// line 91:
// Firefox can record both audio/video in single webm container
// Don't need to create multiple instances of the RecordRTC for Firefox
// You can even use below property to force recording only audio blob on chrome
var isRecordOnlyAudio = true;
=
- RecordRTC to Node.js
- RecordRTC to PHP
- RecordRTC to ASP.NET MVC
- RecordRTC & HTML-2-Canvas i.e. Canvas/HTML Recording!
- MRecordRTC i.e. Multi-RecordRTC!
- RecordRTC on Ruby!
- RecordRTC over Socket.io
=
License
RecordRTC-to-Nodejs is released under MIT licence . Copyright (c) Muaz Khan.