diff --git a/README.md b/README.md
index f2fb488..7947c46 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,9 @@ _Recording voice calls without prior consent violates privacy. Do not use this b
- [Installation and Usage](#installation-and-usage)
- - [Setting Up the Local Environment](#setting-up-the-local-environment)
- - [Running the Script](#running-the-script)
+ - [Run Locally](#run-locally)
+ - [Run as Docker Container](#run-as-docker-container)
+ - [Bot Commands](#bot-commands)
- [Managing the Output](#managing-the-output)
- [Merge Recording](#merge-recording)
- [Convert the Merged File to MP3](#convert-the-merged-file-to-mp3)
@@ -23,13 +24,9 @@ Clone the repository :
git clone https://github.com/chebro/discord-voice-recorder/
```
-Run `npm i` to download necessary `node_modules`. Then, head over to the [FFmpeg.org](https://ffmpeg.org/download.html), and download executables for your OS; If you're on Windows, double-check if the FFmpeg bin is on your path.
+[Make a discord bot](https://discordpy.readthedocs.io/en/latest/discord.html) if you don't have one already and invite the bot to your server, then:
-### Setting Up the Local Environment
-
-To run this script locally, [create a discord bot](https://discordpy.readthedocs.io/en/latest/discord.html) first. Invite the bot to your server, then:
-
-1. Create a `config.json` file and a `recordings` folder at the root folder.
+1. Create `config.json` file and a `/recordings` directory at the root folder.
2. Paste the bot token (from [developer window](https://discord.com/developers/applications)) and any bot prefix into `config.json`, like so:
```yaml
@@ -39,50 +36,62 @@ To run this script locally, [create a discord bot](https://discordpy.readthedocs
}
```
-### Running the Script
+You can now run the script in one of the following two ways:
-Run `npm start`, the bot should be online.
+### Run Locally
-#### Start Recording
+Run `npm i` to download necessary `node_modules`, then run `npm start`, the bot should be online.
+
+### Run as a Docker Container
+
+1. Build the docker image:
```
-enter
+docker build -t dvr .
```
-**Note:** You should hear a 'drop' sound after running this. If you don't, there's a problem with your FFmpeg installation.
-
-#### Stop Recording
+2. Bind `/recordings` directory on host to container and start the container with a custom name:
```
-exit
+docker run \
+ --name \
+ --mount type=bind,source="$(pwd)"/recordings,target=/usr/src/bot/recordings \
+ dvr
```
+The bot should be online.
+
+3. To stop the container, run `docker stop `, you can restart it using `docker start `.
+
+### Bot Commands
+
+1. Start Recording : `enter `
+
+2. Stop Recording : `exit`
+
## Managing the Output
-The audio will be recorded in [PCM format](https://en.wikipedia.org/wiki/Pulse-code_modulation) and saved to the `/recordings` directory.
-
-_To work with PCM audio, you could use software such as [Audacity](https://www.audacityteam.org/). To import the audio into Audacity, open File > Import Raw Data... and then select your audio file. You should select Signed 16-bit PCM as the encoding, a Little-endian byte order, 2 Channels (Stereo) and a sample rate of 48000Hz._
+The output for each piece of audio stream is written to a unique file in [PCM format](https://en.wikipedia.org/wiki/Pulse-code_modulation) (48000 Hz, signed 16-bit little-endian, 2 channel [stereo]) and saved to the `/recordings` directory.
### Merge Recording
-The output for each piece of audio stream is written to a unique file. To merge all output files, run:
+To merge all output files to `/recordings/merge.pcm`, run:
```
-node ./bin/merge.js
+node /bin/merge.js
```
-This creates a `merge.pcm` in the `/recordings` directory.
-
-**Note:** Do not forget to empty your `recordings` folder after each session. Running `./bin/merge.js` otherwise, will dump large merge files.
+**Note:** Empty your `recordings` folder (and remove `merge.pcm`) after each session. Running `./bin/merge.js` otherwise, will dump large merge files.
### Convert the Merged File to MP3
-As mentioned in issue [#3](https://github.com/chebro/discord-voice-recorder/issues/3), to convert pcm to mp3, run:
+Head over to [FFmpeg.org](https://ffmpeg.org/download.html), and download executables for your OS; If you're on Windows, double-check if the FFmpeg bin is on your path. As discussed in issue [#3](https://github.com/chebro/discord-voice-recorder/issues/3), to convert pcm to mp3, run:
```
-ffmpeg -f s16le -ar 44.1k -ac 2 -i merge.pcm output.mp3
+ffmpeg -f s16le -ar 48000 -ac 2 -i merge.pcm output.mp3
```
## Thanks
Special thanks to [@eslachance](https://github.com/eslachance) for the [gist](https://gist.github.com/eslachance/fb70fc036183b7974d3b9191601846ba). It is what inspired me to make this repo.
+
diff --git a/bin/merge.js b/bin/merge.js
index a2aea56..d84c395 100644
--- a/bin/merge.js
+++ b/bin/merge.js
@@ -1,8 +1,8 @@
var fs = require('fs'),
- chunks = fs.readdirSync('../recordings'),
+ chunks = fs.readdirSync(__dirname + '/../recordings'),
inputStream,
currentfile,
- outputStream = fs.createWriteStream('../recordings/merge.pcm');
+ outputStream = fs.createWriteStream(__dirname + '/../recordings/merge.pcm');
chunks.sort((a, b) => { return a - b; });
@@ -12,7 +12,7 @@ function appendFiles() {
return;
}
- currentfile = '../recordings/' + chunks.shift();
+ currentfile = `${__dirname}/../recordings/` + chunks.shift();
inputStream = fs.createReadStream(currentfile);
inputStream.pipe(outputStream, { end: false });
@@ -23,4 +23,5 @@ function appendFiles() {
});
}
-appendFiles();
\ No newline at end of file
+appendFiles();
+