WWBN / AVideo-Encoder

Encoder Server for AVideo Platform Open-Source
https://platform.avideo.com
GNU Affero General Public License v3.0
151 stars 187 forks source link

rtmp not sending stream recording to encoder #119

Open datasurgeservers opened 5 years ago

datasurgeservers commented 5 years ago

I have set up the RTMP in nginx as described in the instructions. I also have the encoder running on nginx instead of apache. For some reason the encoder software doesn't seem to see the .htaccess file and implement the rules.

The encoder works for uploads, but not for live streams. Below is my nginx block for rtmp

    rtmp {
            server {
                    listen 146.71.109.43:1935;
                    allow play all;
                    #creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
                    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://streaming.datasurgeservers.com/plugin/Live/on_publish.php;
                            on_play http://streaming.datasurgeservers.com/plugin/Live/on_play.php;
                            on_record_done http://streaming.datasurgeservers.com:443/plugin/Live/on_record_done.php;
                            recorder video{
                              record all;
                              record_path /usr/local/apache2/htdocs/encoder/tmp;
                              record_notify on;
                              #will produce files of the form yourUserKey-24-Apr-13-18:23:38.flv
                              record_suffix -%d-%b-%y-%T.flv;
                        }
                    }
            }
    }
datasurgeservers commented 5 years ago

I also did purchase the plugin to send the recording to the encoder, and it is enabled.

DanielnetoDotCom commented 5 years ago

I see...

I always setup encoder on apache.

Does this directory exists /usr/local/apache2/htdocs/encoder/tmp

there is something on your error log?

datasurgeservers commented 5 years ago

I tried to set it up on Apache , but the .htaccess file wasn't being read. I don't know why.What error logs should I check?On Feb 19, 2019 7:04 AM, YouPHPTube notifications@github.com wrote:I see... I always setup encoder on apache. Does this directory exists /usr/local/apache2/htdocs/encoder/tmp there is something on your error log?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

datasurgeservers commented 5 years ago

Also, the directory exists. Forgot to answer that question. And it is writable.On Feb 19, 2019 9:17 AM, Steve Duckfield steve@datasurgeservers.com wrote:I tried to set it up on Apache , but the .htaccess file wasn't being read. I don't know why.What error logs should I check?On Feb 19, 2019 7:04 AM, YouPHPTube notifications@github.com wrote:I see... I always setup encoder on apache. Does this directory exists /usr/local/apache2/htdocs/encoder/tmp there is something on your error log?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

datasurgeservers commented 5 years ago

Ok, the recording is showing up in my tmp directory now (i had the wrong permissions set on the folder). However, it is not getting to the encoder so that it gets posted on my site.

DanielnetoDotCom commented 5 years ago

check the streamer and encoder log file for some clue

datasurgeservers commented 5 years ago

I checked both logs and nothing shows any errors for sending it to the encoder. I see the .flv file in my temp directory, but nothing happens after that. In the source of the plugin, is there anything that is hard coded such as addresses, paths, etc??

datasurgeservers commented 5 years ago

What permissions would the user need in order for the plugin to work properly? So far, I only have streaming and encode video active.

DanielnetoDotCom commented 5 years ago

I think I found the problem

in your configuration you have this: on_record_done http://streaming.datasurgeservers.com:443/plugin/Live/on_record_done.php;

try to remove the port on_record_done http://streaming.datasurgeservers.com/plugin/Live/on_record_done.php;

also, make sure the on_record_done is accessible

datasurgeservers commented 5 years ago

I will try this asapOn Feb 20, 2019 9:42 AM, YouPHPTube notifications@github.com wrote:I think I found the problem in your configuration you have this: on_record_done http://streaming.datasurgeservers.com:443/plugin/Live/on_record_done.php; try to remove the port on_record_done http://streaming.datasurgeservers.com/plugin/Live/on_record_done.php; also, make sure the on_record_done is accessible

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

datasurgeservers commented 5 years ago

I removed the port and still have the same issue.

datasurgeservers commented 5 years ago

This is from my webserver log...

104.148.197.25 - - [20/Feb/2019:07:09:13 -0800] "GET /plugin/Live/on_record_done.php HTTP/1.1" 200 20 "-" "Mozilla/5.0 (Linux; Android 8.0.0; LM-G710VM) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36" 104.148.197.25 - - [20/Feb/2019:07:09:14 -0800] "GET /favicon.ico HTTP/1.1" 404 16 "http://streaming.datasurgeservers.com/plugin/Live/on_record_done.php" "Mozilla/5.0 (Linux; Android 8.0.0; LM-G710VM) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36"

I see a http 200 and and a http 404 there. Don't know if that helps.

datasurgeservers commented 5 years ago

Using a different version of OBS Studio...

179.181.14.96 - - [20/Feb/2019:15:46:09 -0800] "GET /plugin/Live/on_record_done.php HTTP/1.1" 200 20 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36" 146.71.109.42 - - [20/Feb/2019:15:48:28 -0800] "POST /plugin/Live/on_publish.php HTTP/1.0" 200 - "-" "-" 146.71.109.42 - - [20/Feb/2019:15:49:22 -0800] "POST /plugin/Live/on_record_done.php HTTP/1.0" 200 - "-" "-" 217.182.175.162 - - [20/Feb/2019:15:49:33 -0800] "HEAD /plugin/Live/on_record_done.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"

DanielnetoDotCom commented 5 years ago

I don't think the problem is the OBS version.

you placed to me the access log, you must look on the apache error log.

also, try the Nginx error log to get some clue

datasurgeservers commented 5 years ago

I am not getting any errors in either of those log files. Is there a way to enable a debug log besides the Audit module?

datasurgeservers commented 5 years ago

THe .flv files are being placed in my temp directory, but they're not showing up on my site.

5c64b43d45591-20-Feb-19-15:44:03.flv 5c64b43d45591-20-Feb-19-15:50:20.flv 5c64b43d45591-20-Feb-19-16:25:34.flv

DanielnetoDotCom commented 5 years ago

should have some clue!

do you have streamer and encoder on the same server?

datasurgeservers commented 5 years ago

The nginx rtmp and the encoder are on the same server.

DanielnetoDotCom commented 5 years ago

streamer in a separated server?

If yes, I guess that is why

image

Streamer and nginx Live Stream Server need to be on the same server

datasurgeservers commented 5 years ago

Ah, that's the confusing part. In the plugin store, it just says the nginx rtmp and encoder need to be on the same server.

datasurgeservers commented 5 years ago

Is there a work-around for this? It's not really feasible for me to put both the streamer and nginx live on the same server.

DanielnetoDotCom commented 5 years ago

Sorry, it really needs to be on the same server. that is the only way to submit the files to the encoder And I am really sorry you right, the information on the store is wrong, I will fix it now

datasurgeservers commented 5 years ago

Ok, I was able to get nginx rtmp on the same server as the streaming server. It seems to have submitted it to the encoder now. Waiting to see final result!

DanielnetoDotCom commented 5 years ago

I am glad you did, let me know the results.

datasurgeservers commented 5 years ago

Ok, it seems to have submitted to the encoder, but it just hangs there... image

It stays gray, no red or green bar.

DanielnetoDotCom commented 5 years ago

look the log file from streamer and encoder

datasurgeservers commented 5 years ago

How can I clear it out of the encoder page?

DanielnetoDotCom commented 5 years ago

on the queue log, you will find a delete button

datasurgeservers commented 5 years ago

Nothing shows up in queue log

datasurgeservers commented 5 years ago

Nothing in queue log tab.. image

Queue tab

image

datasurgeservers commented 5 years ago

Ok, fixed that via SQL queries. Anyway, I think I found the problem:

ffmpeg version 3.4-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.4.0 (Debian 6.4.0-7) 20170920 configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 /usr/local/apache2/htdocs/encoder/videos/2_tmpFile.mp4: No such file or directory

That is from the encoder's videos directory. Looks like the video file is never being created even though the download progress says 100%

DanielnetoDotCom commented 5 years ago

Yeah, that may be the problem. so is it working now?

datasurgeservers commented 5 years ago

No, its not sending the file overOn Feb 21, 2019 4:36 AM, YouPHPTube notifications@github.com wrote:Yeah, that may be the problem. so is it working now?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

DanielnetoDotCom commented 5 years ago

as I can see in your screenshots the download never happened.

should really have something on the log file. that is the only way to detect the problem

datasurgeservers commented 5 years ago

Found the problem: it doesn't like my site's ssl certificate. [21-Feb-2019 06:53:49 UTC] downloadFile: start queue_id = 2 [21-Feb-2019 06:53:49 UTC] downloadFile: url = https://streaming.datasurgeservers.com/videos/original_OrderToChaosTESTINGRECORDINGon20Feb19225130_YPTuniqid_5c6e4a8ca256e6.03860604 [21-Feb-2019 06:53:49 UTC] downloadFile:strpos global['webSiteRootURL'] = http://source.datasurgeservers.com/ [21-Feb-2019 06:53:49 UTC] downloadFile: keep the same URL [21-Feb-2019 06:53:49 UTC] downloadFile: downloadedFile = https://streaming.datasurgeservers.com/videos/original_OrderToChaosTESTINGRECORDINGon20Feb19225130_YPTuniqid_5c6e4a8ca256e6.03860604 | url = https://streaming.datasurgeservers.com/videos/original_OrderToChaosTESTINGRECORDINGon20Feb19225130_YPTuniqid_5c6e4a8ca256e6.03860604 [21-Feb-2019 06:53:49 UTC] PHP Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /usr/local/apache2/htdocs/encoder/objects/Encoder.php on line 343

datasurgeservers commented 5 years ago

Well, after some looking on the php manul, I was able to add some code to make it work. Below is the snippet:

$destFile = file_get_contents($videoURL,false,$ctx); // sd - let's see if this works file_put_contents($global['systemRootPath'] . 'videos/' . $global['queue_id'] . '_tmpFile.mp4',$destFile);

This is under the getVideoFile in Encoder.php .

I commented out the copy statement, and used the above.

DanielnetoDotCom commented 5 years ago

so it was because of the SSL certificate?? would you live so send a pull request with your code?

datasurgeservers commented 5 years ago

Yes, it was the SSL certificate. I am not sure how to do the pull request, but I can attach the encoder.php file i modified.

datasurgeservers commented 5 years ago

Also, perhaps this is a good way around needing to have the streamer and the rtmp on the same server. (using file_get_contents and file_put_contents)

datasurgeservers commented 5 years ago

Encoder.php.txt

datasurgeservers commented 5 years ago

Also, for the streaming plugin, once the video has been copied / downloaded to the encoder, it should be deleted from the temporary directory stated in the nginx.conf file.

datasurgeservers commented 5 years ago

I'd like to add that what i provided is not a good idea. You can run out of memory real easy. Instead, use the copy($videoURL,$destFile,$ctx); That bypasses the SSL issue, and prevents memory issues