RTMP Streaming problems

#1
I'm having some issues with streaming to my nginx rtmp server. I've been searching threads here and playing with it for quite a while, but can't get it to work.

Here are my system specs, which I thought were enough;
GIGABYTE GV-N770OC-4GD GeForce GTX 770 4GB 256-Bit GDDR5 PCI Express 3.0
ASRock X99 Extreme4 Motherboard
Intel Core i7-5820K Haswell-E 6-Core 3.3 GHz
16GB DDR4 Ram
Windows 7

When running my program, videos and everything plays as expected, with no problems.
Image
When I run the following command:

Code: Select all

ADD 1 STREAM rtmp://[ip]/[stream/key] -vcodec libx264 -preset fast -crf 18 -vf scale=1280x720,format=pix_fmts=yuv420p -x264opts bitrate=1808:vbv-maxrate=1808:vbv-bufsize=61 -strict -2 -acodec aac -b:a 192k -af aresample=44100 -f flv
I get the response from Caspar;

Code: Select all

[2017-08-07 18:20:32.397] [1816]  [info]    Received message from 127.0.0.1: ADD 1 STREAM rtmp://[ip]/[stream/key] -vcodec libx264 -preset fast -crf 18 -vf scale=1280x720,format=pix_fmts=yuv420p -x264opts bitrate=1808:vbv-maxrate=1808:vbv-bufsize=61 -strict -2 -acodec aac -b:a 192k -af aresamp
le=44100 -f flv\r\n
[2017-08-07 18:20:32.408] [9084]  [info]
+------------------------+
| ffmpeg_consumer_buffer |default--[1280x720 1:1 bgra]--Parsed_scale_0:default
|        (buffer)        |
+------------------------+

                                                        +----------------------------+
Parsed_format_1:default--[1280x720 1:1 yuv420p]--default| ffmpeg_consumer_buffersink |
                                                        |        (buffersink)        |
                                                        +----------------------------+

                                                            +----------------+
ffmpeg_consumer_buffer:default--[1280x720 1:1 bgra]--default| Parsed_scale_0 |default--[1280x720 1:1 yuv420p]--Parsed_format_1:default
                                                            |    (scale)     |
                                                            +----------------+

                                                       +-----------------+
Parsed_scale_0:default--[1280x720 1:1 yuv420p]--default| Parsed_format_1 |default--[1280x720 1:1 yuv420p]--ffmpeg_consumer_buffersink:default
                                                       |    (format)     |
                                                       +-----------------+


[2017-08-07 18:20:32.448] [9084]  [info]
+-------------------------+
| ffmpeg_consumer_abuffer |default--[48000Hz s32:stereo]--Parsed_aresample_0:default
|        (abuffer)        |
+-------------------------+

                                                          +-----------------------------+
Parsed_aresample_0:default--[44100Hz fltp:stereo]--default| ffmpeg_consumer_abuffersink |
                                                          |        (abuffersink)        |
                                                          +-----------------------------+

                                                              +--------------------+
ffmpeg_consumer_abuffer:default--[48000Hz s32:stereo]--default| Parsed_aresample_0 |default--[44100Hz fltp:stereo]--ffmpeg_consumer_abuffersink:default
                                                              |    (aresample)     |
                                                              +--------------------+


[2017-08-07 18:20:32.477] [9084]  [info]    [ffmpeg] [libx264 @ 0B1309A0] using SAR=1/1
[2017-08-07 18:20:32.480] [9084]  [info]    [ffmpeg] [libx264 @ 0B1309A0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[2017-08-07 18:20:32.484] [9084]  [info]    [ffmpeg] [libx264 @ 0B1309A0] profile High, level 3.2
[2017-08-07 18:20:32.487] [9084]  [info]    [ffmpeg] [libx264 @ 0B1309A0] 264 - core 142 r2431 ac76440 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range
=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint
_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=cbr mbtree=1 bitrate=1808 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1808 vbv_bufsize=61 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
[2017-08-07 18:20:33.100] [9084]  [info]    [ffmpeg] Output #0, flv, to 'rtmp://[ip]/[stream/key]':
[2017-08-07 18:20:33.107] [9084]  [info]    [ffmpeg]   Metadata:
[2017-08-07 18:20:33.110] [9084]  [info]    [ffmpeg]     encoder         :
[2017-08-07 18:20:33.112] [9084]  [info]    [ffmpeg] Lavf55.33.10
[2017-08-07 18:20:33.115] [9084]  [info]    [ffmpeg]
[2017-08-07 18:20:33.116] [9084]  [info]    [ffmpeg]     Stream #0:
[2017-08-07 18:20:33.118] [9084]  [info]    [ffmpeg] : Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1808 kb/
[2017-08-07 18:20:33.124] [9084]  [info]    [ffmpeg] , 1k tb
[2017-08-07 18:20:33.126] [9084]  [info]    [ffmpeg] , 60 tb
[2017-08-07 18:20:33.128] [9084]  [info]    [ffmpeg]
[2017-08-07 18:20:33.129] [9084]  [info]    [ffmpeg]     Stream #0:
[2017-08-07 18:20:33.131] [9084]  [info]    [ffmpeg] : Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 192 kb/
[2017-08-07 18:20:33.134] [9084]  [info]    [ffmpeg]
[2017-08-07 18:20:33.136] [9984]  [info]    output[1] streaming_consumer[rtmp://[ip]/[stream/key]] Added.
[2017-08-07 18:20:33.143] [9084]  [debug]   Executed command: AddCommand
[2017-08-07 18:20:33.145] [9084]  [info]    Sent message to 127.0.0.1: 202 ADD OK\r\n
[2017-08-07 18:21:34.394] [7776]  [warning] [fence] Performance warning. GPU was not ready during requested host read-back. Delayed by atleast: 4 ms. Further warnings are sent to trace log level. You can ignore this warning if you do not notice any problems with output video. This warning is caused
by insufficient support or performance of your graphics card for OpenGL based memory transfers.  Please try to update your graphics drivers or update your graphics card, see recommendations on (www.casparcg.com). Further help is available at (www.casparcg.com/forum).
the audio cuts off, the video slows down quite a bit and it struggles. The resulting stream, if I watch it on VLC via my server is an ok quality video stream, with audio, but only lasts a few seconds, I assume because my computer cannot keep the servers buffer full. Diag shows this
Image
When I send the remove command, everything returns to normal. Caspar responds;

Code: Select all

[2017-08-07 18:29:35.807] [3872]  [info]    Received message from Console: remove 1 stream rtmp://[ip]/[stream/key]\r\n
[2017-08-07 18:29:35.935] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] frame I:4     Avg QP:40.64  size:  6238
[2017-08-07 18:29:35.942] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] frame P:477   Avg QP:30.57  size:  2855
[2017-08-07 18:29:35.949] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] frame B:12    Avg QP:29.67  size:   578
[2017-08-07 18:29:35.954] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] consecutive B-frames: 96.8%  0.0%  0.0%  3.2%
[2017-08-07 18:29:35.960] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] mb I  I16..4: 21.3% 78.0%  0.6%
[2017-08-07 18:29:35.964] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] mb P  I16..4:  3.7%  3.7%  0.1%  P16..4: 14.4%  1.7%  0.9%  0.0%  0.0%    skip:75.5%
[2017-08-07 18:29:35.973] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] mb B  I16..4:  0.2%  0.2%  0.0%  B16..8:  6.2%  0.2%  0.0%  direct: 2.4%  skip:90.8%  L0:78.2% L1:18.4% BI: 3.4%
[2017-08-07 18:29:35.982] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] 8x8 transform intra:52.6% inter:91.6%
[2017-08-07 18:29:35.987] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] coded y,uvDC,uvAC intra: 17.0% 41.5% 1.9% inter: 3.6% 7.4% 0.0%
[2017-08-07 18:29:35.994] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] i16 v,h,dc,p: 41% 29% 11% 19%
[2017-08-07 18:29:35.998] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 10% 40%  4%  5%  6%  4%  6%  4%
[2017-08-07 18:29:36.004] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 27% 20%  5%  7%  6%  6%  4%  3%
[2017-08-07 18:29:36.011] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] i8c dc,h,v,p: 63% 14% 17%  6%
[2017-08-07 18:29:36.015] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] Weighted P-Frames: Y:0.8% UV:0.4%
[2017-08-07 18:29:36.019] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] ref P L0: 80.0% 20.0%
[2017-08-07 18:29:36.023] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] ref B L0: 88.6% 11.4%
[2017-08-07 18:29:36.026] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] ref B L1: 99.4%  0.6%
[2017-08-07 18:29:36.030] [10688] [info]    [ffmpeg] [libx264 @ 0AB5E880] kb/s:1357.08
[2017-08-07 18:29:36.034] [10688] [warning] [ffmpeg] [aac @ 0AB5EC80] 2 frames left in the queue on closing
[2017-08-07 18:29:36.090] [10688] [warning] [ffmpeg] [flv @ 13C0C160] Failed to update header with correct duration.
#202 REMOVE OK
[2017-08-07 18:29:36.095] [10688] [warning] [ffmpeg] [flv @ 13C0C160] Failed to update header with correct filesize.
[2017-08-07 18:29:36.103] [10688] [info]    output[1] streaming_consumer[rtmp://[ip]/[stream/key]] Removed.
[2017-08-07 18:29:36.108] [10688] [debug]   Executed command: RemoveCommand
Now one might assume that my video card is the problem, but is it? I can use Open Broadcaster Software [OBS] and use the video engine to encode and stream video to twitch or the same nginx server with no problem.

What can I do?