Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MongoDB configuration #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/components/LiveStreams.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default class Navbar extends React.Component {
}

getLiveStreams() {
axios.get('http://127.0.0.1:' + config.rtmp_server.http.port + '/api/streams')
let streamApi = 'http://' + config.server.host + ':' + config.rtmp_server.http.port + '/api/streams';
axios.get(streamApi)
.then(res => {
let streams = res.data;
if (typeof (streams['live'] !== 'undefined')) {
Expand Down
4 changes: 2 additions & 2 deletions client/components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class Navbar extends React.Component {
<nav className="navbar navbar-expand-lg navbar-dark bg-dark">
<div className="container">
<Link to={'/'} className={'navbar-brand'}>
NodeStream
Live Stream
</Link>
<button className="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarSupportedContent"
Expand All @@ -23,7 +23,7 @@ export default class Navbar extends React.Component {
</Link>
</li>
<li className="nav-item float-right">
<a className="nav-link" target="_blank" href="https://github.com/waleedahmad">Github</a>
<a className="nav-link" target="_blank" href="https://github.com/jundat95">Github</a>
</li>
<li className="nav-item float-right">
<a className="nav-link" href="/Logout">Logout</a>
Expand Down
2 changes: 1 addition & 1 deletion client/components/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class Navbar extends React.Component {
You can use <a target="_blank" href="https://obsproject.com/">OBS</a> or
<a target="_blank" href="https://www.xsplit.com/">XSplit</a> to Live stream. If you're
using OBS, go to Settings > Stream and select Custom from service dropdown.
Enter <b>rtmp://127.0.0.1:1935/live</b> in server input field. Also, add your stream key.
Enter <b>rtmp://[IP]:1935/live</b> in server input field. Also, add your stream key.
Click apply to save.
</p>
</div>
Expand Down
3 changes: 2 additions & 1 deletion client/components/VideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export default class VideoPlayer extends React.Component {
username: this.props.match.params.username
}
}).then(res => {
let streamURL = `http://${config.server.host}:` + config.rtmp_server.http.port + '/live/' + res.data.stream_key + '/index.m3u8';
this.setState({
stream: true,
videoJsOptions: {
autoplay: false,
controls: true,
sources: [{
src: 'http://127.0.0.1:' + config.rtmp_server.http.port + '/live/' + res.data.stream_key + '/index.m3u8',
src: streamURL,
type: 'application/x-mpegURL'
}],
fluid: true,
Expand Down
22 changes: 20 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ $ ffmpeg --version

[Mac](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/)

#### Setup mongodb with docker

```
docker run -d -it --name mongodb \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=admin \
mongo
```

#### Configuration
Change ffmpeg path in node media server configuration to your
own installed path.
Expand All @@ -40,7 +50,15 @@ cd nodeStream && nano /server/config/default.js
const config = {
server: {
secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc',
port : 3333
port: '3333',
host: 'localhost',
},
mongodb: {
host: 'localhost',
port: '27017',
userName: 'admin',
password: 'admin',

},
rtmp_server: {
rtmp: {
Expand Down Expand Up @@ -83,6 +101,6 @@ $ npm run start
```
#### Streaming with OBS

Go to Settings > Stream. Select Custom service and `rtmp://127.0.0.1:1935/live`
Go to Settings > Stream. Select Custom service and `rtmp://[IP]:1935/live`
in server input. Enter your streaming key issued by NodeStream and click Apply.
Click start streaming to broadcast your stream.
2 changes: 1 addition & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ app.get('*', middleware.ensureLoggedIn(), (req, res) => {
res.render('index');
});

app.listen(port, () => console.log(`App listening on ${port}!`));
app.listen(port, () => console.log(`App listening on ${config.server.host}:${port}!`));
node_media_server.run();
thumbnail_generator.start();
10 changes: 9 additions & 1 deletion server/config/default.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const config = {
server: {
secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc',
port : 3333
port: '3333',
host: '192.168.11.239',
},
mongodb: {
host: 'localhost',
port: '27017',
userName: 'admin',
password: 'admin',

},
rtmp_server: {
rtmp: {
Expand Down
3 changes: 2 additions & 1 deletion server/cron/thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const CronJob = require('cron').CronJob,
port = config.rtmp_server.http.port;

const job = new CronJob('*/5 * * * * *', function () {
let streamApi = 'http://' + config.server.host + ':' + config.rtmp_server.http.port + '/api/streams';
request
.get('http://127.0.0.1:' + port + '/api/streams', function (error, response, body) {
.get(streamApi, function (error, response, body) {
let streams = JSON.parse(body);
if (typeof (streams['live'] !== undefined)) {
let live_streams = streams['live'];
Expand Down
17 changes: 17 additions & 0 deletions server/database/Schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
let mongoose = require('mongoose');
const config = require('../config/default');

const connectMongoDB = () => {
mongoose.connect(
`mongodb://${config.mongodb.userName}:${config.mongodb.password}@${config.mongodb.host}:${config.mongodb.port}`,
{
useNewUrlParser: true,
useUnifiedTopology: true
}
).then(() => {
console.log("Connected to mongodb");
}).catch((err) => {
console.log(err);
});
}

connectMongoDB();

exports.User = mongoose.model('User', require('./UserSchema'));
2 changes: 1 addition & 1 deletion server/views/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>NodeStream</title>
<title>Live Stream</title>
<link rel="stylesheet" href="/style.css">
</head>
2 changes: 1 addition & 1 deletion server/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>NodeStream</title>
<title>Live Stream</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion server/views/navbar.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="/">NodeStream</a>
<a class="navbar-brand" href="/">Live Stream</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
Expand Down