Skip to content

Commit

Permalink
chore(example): add webm2mpe demo
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackHole1 committed Dec 4, 2019
1 parent a00a4ba commit 5a21450
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
README-zh.md
README.md
LICENSE
.all-contributorsrc
logs
src/node_modules
src/tsconfig.json
src/webpack.config.js
src/.eslintrc.js
examples
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ typings/

### Custom
.idea
/examples/*/rebirth_data/*
!/examples/*/rebirth_data/.gitkeep
7 changes: 7 additions & 0 deletions examples/webm2mp4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM rebirth:1.0.0

MAINTAINER Black-Hole<[email protected]>

RUN apt-get install -yq ffmpeg

RUN npm install fluent-ffmpeg
15 changes: 15 additions & 0 deletions examples/webm2mp4/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'
services:
webm2mp4:
build: .
container_name: webm2mp4-rebirth
ports:
- "9223"
- "5920"
volumes:
- ./hooks:/etc/www/hooks
- ./rebirth_data/video:/root/Downloads
- ./rebirth_data/logs:/etc/www/logs
environment:
MATERIAL_URL: "https://www.bugs.cc/self_page/github/rebirth/webm2mp4/"
START_VNC: "yes"
37 changes: 37 additions & 0 deletions examples/webm2mp4/hooks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { join } = require('path');
const { homedir } = require('os');
const ffmpeg = require('fluent-ffmpeg');
const { loggerHooks } = require('../lib/log');

module.exports = {
completeRecordAfter: (data) => {
const baseFile = join(homedir(), 'Downloads');
const inputFile = join(baseFile, `${data.fileName}.webm`);
const outputFile = join(baseFile, `${data.fileName}.mp4`)

return new Promise((resolve, reject) => {
ffmpeg(inputFile)
.on('start', commandLine => {
loggerHooks.info('ffmpeg start', {
commandLine
});
})
.on('error', err => {
loggerHooks.error('ffmpeg error', {
errMessage: err.message,
errStack: err.stack
});
reject(err);
})
.on('end', () => {
loggerHooks.info('ffmpeg complete', {
inputFile,
outputFile
});
resolve();
})
.outputOptions(['-fflags +genpts', '-max_muxing_queue_size 99999', '-r 30', '-crf 20'])
.save(outputFile);
});
}
};

0 comments on commit 5a21450

Please sign in to comment.