-
Notifications
You must be signed in to change notification settings - Fork 1k
Record Live Stream
This tutorial will guide you how to record your live stream and send it to the encoder.
For this tutorial you will need
- The plugin SendRecordedToEncoder
- Streamer and nginx Live Stream Server need to be on the same server
- If Streamer and nginx are separated make sure you configure the getRecordedFile.php
Make sure you update your streamer and encoder. if you are not sure how to do this, check this tutorial
create a directory to store your recorded lives, and gives permission to Apache and Nginx to write on it. Make sure this path match with the record_path parameter on Nginx conf
For example:
sudo mkdir /var/www/tmp && sudo chmod 777 /var/www/tmp
Change your nginx.conf file
sudo nano /usr/local/nginx/conf/nginx.conf
and then add those lines on your file
recorder video{
record all;
record_path /var/www/tmp;
record_notify on;
record_max_size 2048M;
#will produce files of the form yourUserKey-24-Apr-13-18:23:38.flv
record_suffix -%d-%b-%y-%T.flv;
}
your rtmp section should look like this.
rtmp {
server {
listen 1935;
allow play all;
#creates our "live" full-resolution HLS videostream from our incoming encoder stream and $
application live {
allow play all;
live on;
#record all;
#record_path /video_recordings;
#record_unique on;
hls on;
hls_nested on;
hls_path /HLS/live;
#hls_playlist_length 4s;
#hls_fragment 1s;
hls_fragment 10s;
on_publish http://192.168.25.16/YouPHPTube/plugin/Live/on_publish.php;
on_play http://192.168.25.16/YouPHPTube/plugin/Live/on_play.php;
on_record_done http://192.168.25.16/YouPHPTube/plugin/Live/on_record_done.php;
recorder video{
record all;
record_path /var/www/tmp;
record_notify on;
record_max_size 2048M;
#will produce files of the form yourUserKey-24-Apr-13-18:23:38.flv
record_suffix -%d-%b-%y-%T.flv;
}
}
}
}
Check your on_record_done directive, it needs to be pointing to the live stream plugin, on_record_done.php file
Restart your nginx server
sudo /usr/local/nginx/sbin/nginx -s stop && sudo /usr/local/nginx/sbin/nginx
Go to your plugin menu and enable SendRecordedToEncoder plugin
The code to get the recorded file remotely should be something like this
<?php
if(empty($_REQUEST['file'])){
die('file not found');
}
$file = preg_replace("/[^0-9a-z_-:]/i", "", $_REQUEST['file']);
$record_path = "/var/www/tmp/";
$filename = $record_path.$file.".flv";
header('Content-Type: video/x-flv');
echo file_get_contents($filename);
The Open Source Video Platform Solution
| Service | Description | Link |
|---|---|---|
| 🎯 | Professional Support - Direct assistance from core developers | Contact |
| ☁️ | AVideo CDN - High-performance video delivery network | Pricing |
AVideo Platform © 2024 - Self-hosted video streaming platform
Made with ❤️ by WWBN and the open source community