Opened 12 years ago

Last modified 9 years ago

#1604 new defect

Rtmp streaming fps continually drops

Reported by: Pyriel0 Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: rtmp
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Clément Bœsch)

Summary of the bug: Rtmp output to justin.tv fps continually drops, the 64 bit version slowly uses all system ram (8 GB). It goes up by 100 MB every second or two until the ram is full. The audio is fine even with the low frame rate. If I change "-f flv rtmp:xxxx" to "f:\test.mp4" to record to a hard drive, it works perfect. This problem only occurs when I'm trying to stream. It happens for both file input and direct show input. My cpu is an Intel 3770k at 4.4 GHz and cable upload is 3 Mb/s. Both are more than capable of handling 1280x720 at 30fps and 2400kb/s.

How to reproduce:

ffmpeg -re -rtbufsize 100000k -i "f:\xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-pix_fmt yuv420p -s hd720 -vcodec libx264 -preset medium -b:v 2400k -maxrate 240
0k -bufsize 600k -acodec libmp3lame -ac 2 -b:a 128k -ar 44100 -f flv "rtmp://liv
e-dfw.justin.tv/app/xxxxxxxxxxxxxxxxxxxxx flashver=FME/2.5 (compatible; FMSc 1.0
)"
ffmpeg version N-43060-ga85b4a5 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jul 30 2012 13:14:08 with gcc 4.7.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass
 --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libope
njpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libth
eora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --e
nable-zlib
  libavutil      51. 66.100 / 51. 66.100
  libavcodec     54. 45.100 / 54. 45.100
  libavformat    54. 22.100 / 54. 22.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3.  5.101 /  3.  5.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f:\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : HandBrake 0.9.5 2011010300
  Duration: 01:39:15.71, start: 0.000000, bitrate: 4822 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x800
[SAR 1:1 DAR 12:5], 4179 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 180k tbc
    Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), s16,
640 kb/s
[libx264 @ 0514f860] using SAR=27/20
[libx264 @ 0514f860] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE
4.2 AVX
[libx264 @ 0514f860] profile High, level 3.1
[libx264 @ 0514f860] 264 - core 125 r2200 999b753 - H.264/MPEG-4 AVC codec - Cop
yleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deb
lock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 m
e_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro
ma_qp_offset=-2 threads=12 lookahead_threads=2 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=2 keyint=250 keyint_min=23 scene
cut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=2400 ratetol=1.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=2400 vbv_bufsize=600 nal_hrd=no
ne ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://live-dfw.justin.tv/app/xxxxxxxxxxxxxxxxxxxxx flashver
=FME/2.5 (compatible; FMSc 1.0)':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf54.22.100
    Stream #0:0(und): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SA
R 27:20 DAR 12:5], q=-1--1, 2400 kb/s, 1k tbn, 23.98 tbc
    Stream #0:1(und): Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16,
 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (ac3 -> libmp3lame)
Press [q] to stop, [?] for help
DTS -3754, next:-83406 st:0 invalid dropping
frame=    4 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
frame=   15 fps= 15 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
frame=   27 fps= 17 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
frame=   40 fps= 19 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
frame=   51 fps= 20 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
frame=   67 fps= 22 q=0.0 size=       8kB time=00:00:00.37 bitrate= 172.5kbits/s
frame=   76 fps= 21 q=0.0 size=      15kB time=00:00:00.75 bitrate= 161.4kbits/s
frame=   87 fps= 21 q=0.0 size=      23kB time=00:00:01.21 bitrate= 153.9kbits/s
frame=  103 fps= 22 q=0.0 size=      44kB time=00:00:01.87 bitrate= 192.1kbits/s
frame=  112 fps= 22 q=0.0 size=      50kB time=00:00:02.25 bitrate= 183.5kbits/s
frame=  123 fps= 22 q=0.0 size=      59kB time=00:00:02.71 bitrate= 177.6kbits/s
frame=  130 fps= 21 q=10.0 size=     135kB time=00:00:03.00 bitrate= 367.5kbits/
frame=  141 fps= 21 q=37.0 size=     223kB time=00:00:03.46 bitrate= 528.9kbits/
frame=  147 fps= 20 q=38.0 size=     313kB time=00:00:03.71 bitrate= 690.7kbits/
frame=  155 fps= 20 q=30.0 size=     408kB time=00:00:04.04 bitrate= 825.6kbits/
frame=  167 fps= 20 q=36.0 size=     492kB time=00:00:04.54 bitrate= 885.6kbits/
frame=  174 fps= 20 q=37.0 size=     602kB time=00:00:04.83 bitrate=1019.8kbits/
frame=  182 fps= 19 q=36.0 size=     692kB time=00:00:05.17 bitrate=1096.3kbits/
frame=  191 fps= 19 q=37.0 size=     783kB time=00:00:05.54 bitrate=1156.8kbits/
frame=  197 fps= 19 q=36.0 size=     888kB time=00:00:05.79 bitrate=1254.4kbits/
frame=  203 fps= 18 q=35.0 size=     983kB time=00:00:06.04 bitrate=1331.5kbits/
frame=  211 fps= 18 q=34.0 size=    1063kB time=00:00:06.38 bitrate=1364.8kbits/
frame=  222 fps= 18 q=33.0 size=    1170kB time=00:00:06.84 bitrate=1401.4kbits/
frame=  231 fps= 18 q=34.0 size=    1272kB time=00:00:07.21 bitrate=1444.4kbits/
frame=  237 fps= 18 q=33.0 size=    1356kB time=00:00:07.46 bitrate=1488.0kbits/
frame=  247 fps= 18 q=32.0 size=    1460kB time=00:00:07.88 bitrate=1517.4kbits/
frame=  255 fps= 18 q=34.0 size=    1554kB time=00:00:08.21 bitrate=1548.9kbits/
frame=  262 fps= 18 q=34.0 size=    1643kB time=00:00:08.50 bitrate=1582.3kbits/
frame=  269 fps= 18 q=33.0 size=    1735kB time=00:00:08.80 bitrate=1615.2kbits/
frame=  277 fps= 18 q=33.0 size=    1823kB time=00:00:09.13 bitrate=1635.1kbits/
frame=  284 fps= 17 q=33.0 size=    1922kB time=00:00:09.42 bitrate=1670.1kbits/
frame=  293 fps= 17 q=32.0 size=    2004kB time=00:00:09.80 bitrate=1674.9kbits/
frame=  302 fps= 17 q=32.0 size=    2107kB time=00:00:10.17 bitrate=1696.5kbits/
frame=  307 fps= 17 q=32.0 size=    2195kB time=00:00:10.38 bitrate=1731.4kbits/
frame=  319 fps= 17 q=31.0 size=    2304kB time=00:00:10.88 bitrate=1734.1kbits/
frame=  327 fps= 17 q=28.0 size=    2402kB time=00:00:11.22 bitrate=1754.0kbits/
frame=  335 fps= 17 q=28.0 size=    2498kB time=00:00:11.55 bitrate=1770.8kbits/
frame=  341 fps= 17 q=28.0 size=    2597kB time=00:00:11.80 bitrate=1802.5kbits/
frame=  351 fps= 17 q=26.0 size=    2677kB time=00:00:12.22 bitrate=1794.4kbits/
frame=  365 fps= 17 q=26.0 size=    2777kB time=00:00:12.80 bitrate=1776.6kbits/
frame=  375 fps= 17 q=27.0 size=    2880kB time=00:00:13.22 bitrate=1784.5kbits/
frame=  385 fps= 17 q=24.0 size=    2978kB time=00:00:13.63 bitrate=1788.7kbits/
frame=  395 fps= 17 q=28.0 size=    3117kB time=00:00:14.05 bitrate=1816.5kbits/
frame=  404 fps= 17 q=27.0 size=    3212kB time=00:00:14.43 bitrate=1823.1kbits/
frame=  410 fps= 17 q=28.0 size=    3304kB time=00:00:14.68 bitrate=1843.7kbits/
frame=  418 fps= 17 q=25.0 size=    3414kB time=00:00:15.01 bitrate=1862.5kbits/
frame=  426 fps= 17 q=25.0 size=    3490kB time=00:00:15.34 bitrate=1862.8kbits/
frame=  437 fps= 17 q=20.0 size=    3597kB time=00:00:15.80 bitrate=1864.1kbits/
frame=  442 fps= 17 q=15.0 size=    3680kB time=00:00:16.01 bitrate=1882.4kbits/
frame=  450 fps= 17 q=12.0 size=    3761kB time=00:00:16.35 bitrate=1884.4kbits/
frame=  458 fps= 17 q=13.0 size=    3857kB time=00:00:16.68 bitrate=1893.8kbits/
frame=  467 fps= 17 q=12.0 size=    3945kB time=00:00:17.05 bitrate=1894.6kbits/
frame=  479 fps= 17 q=8.0 size=    4029kB time=00:00:17.56 bitrate=1879.6kbits/s
frame=  490 fps= 17 q=23.0 size=    4129kB time=00:00:18.01 bitrate=1877.5kbits/
frame=  497 fps= 17 q=28.0 size=    4235kB time=00:00:18.30 bitrate=1895.0kbits/
frame=  503 fps= 17 q=28.0 size=    4336kB time=00:00:18.56 bitrate=1913.7kbits/
frame=  511 fps= 17 q=27.0 size=    4412kB time=00:00:18.89 bitrate=1912.9kbits/
frame=  518 fps= 17 q=27.0 size=    4495kB time=00:00:19.18 bitrate=1919.4kbits/
frame=  526 fps= 17 q=26.0 size=    4583kB time=00:00:19.52 bitrate=1923.5kbits/
frame=  534 fps= 17 q=29.0 size=    4676kB time=00:00:19.85 bitrate=1929.5kbits/
frame=  543 fps= 17 q=32.0 size=    4778kB time=00:00:20.22 bitrate=1934.8kbits/
frame=  549 fps= 17 q=31.0 size=    4868kB time=00:00:20.47 bitrate=1947.3kbits/
frame=  557 fps= 16 q=32.0 size=    4960kB time=00:00:20.81 bitrate=1952.2kbits/
frame=  565 fps= 16 q=31.0 size=    5055kB time=00:00:21.14 bitrate=1958.4kbits/
frame=  571 fps= 16 q=30.0 size=    5135kB time=00:00:21.39 bitrate=1966.0kbits/
frame=  578 fps= 16 q=28.0 size=    5236kB time=00:00:21.68 bitrate=1977.6kbits/
frame=  586 fps= 16 q=26.0 size=    5325kB time=00:00:22.02 bitrate=1981.1kbits/
frame=  594 fps= 16 q=25.0 size=    5426kB time=00:00:22.35 bitrate=1988.1kbits/
frame=  602 fps= 16 q=23.0 size=    5525kB time=00:00:22.69 bitrate=1994.7kbits/
frame=  609 fps= 16 q=23.0 size=    5617kB time=00:00:22.98 bitrate=2002.3kbits/
frame=  615 fps= 16 q=22.0 size=    5697kB time=00:00:23.23 bitrate=2008.8kbits/
frame=  623 fps= 16 q=22.0 size=    5784kB time=00:00:23.56 bitrate=2010.6kbits/
frame=  634 fps= 16 q=21.0 size=    5898kB time=00:00:24.02 bitrate=2011.1kbits/
frame=  643 fps= 16 q=23.0 size=    5981kB time=00:00:24.40 bitrate=2008.1kbits/
frame=  651 fps= 16 q=21.0 size=    6071kB time=00:00:24.73 bitrate=2010.9kbits/
frame=  657 fps= 16 q=20.0 size=    6170kB time=00:00:24.98 bitrate=2023.2kbits/
frame=  666 fps= 16 q=21.0 size=    6270kB time=00:00:25.35 bitrate=2025.6kbits/
frame=  675 fps= 16 q=20.0 size=    6350kB time=00:00:25.73 bitrate=2021.6kbits/
frame=  685 fps= 16 q=20.0 size=    6444kB time=00:00:26.15 bitrate=2018.7kbits/
frame=  693 fps= 16 q=15.0 size=    6532kB time=00:00:26.48 bitrate=2020.4kbits/
frame=  703 fps= 16 q=20.0 size=    6622kB time=00:00:26.90 bitrate=2016.7kbits/
frame=  712 fps= 16 q=21.0 size=    6715kB time=00:00:27.27 bitrate=2016.7kbits/
frame=  719 fps= 16 q=20.0 size=    6798kB time=00:00:27.57 bitrate=2020.1kbits/
frame=  727 fps= 16 q=16.0 size=    6890kB time=00:00:27.90 bitrate=2023.0kbits/
frame=  738 fps= 16 q=20.0 size=    6980kB time=00:00:28.36 bitrate=2016.0kbits/
frame=  746 fps= 16 q=18.0 size=    7089kB time=00:00:28.69 bitrate=2023.7kbits/
frame=  758 fps= 15 q=13.0 Lsize=    7879kB time=00:00:31.53 bitrate=2047.0kbits
/s
video:7350kB audio:496kB subtitle:0 global headers:0kB muxing overhead 0.436182%

[libx264 @ 0514f860] frame I:23    Avg QP:18.98  size: 22743
[libx264 @ 0514f860] frame P:498   Avg QP:24.53  size: 12099
[libx264 @ 0514f860] frame B:237   Avg QP:16.09  size:  4121
[libx264 @ 0514f860] consecutive B-frames: 48.8% 27.4%  3.2% 20.6%
[libx264 @ 0514f860] mb I  I16..4: 41.8% 47.4% 10.8%
[libx264 @ 0514f860] mb P  I16..4: 19.6% 10.0%  1.0%  P16..4: 28.3%  7.3%  3.2%
 0.0%  0.0%    skip:30.6%
[libx264 @ 0514f860] mb B  I16..4:  0.4%  0.2%  0.0%  B16..8: 19.4%  4.2%  0.8%
 direct: 3.9%  skip:71.0%  L0:46.6% L1:48.0% BI: 5.4%
[libx264 @ 0514f860] 8x8 transform intra:34.6% inter:82.7%
[libx264 @ 0514f860] coded y,uvDC,uvAC intra: 27.7% 47.6% 13.5% inter: 17.2% 23.
4% 1.2%
[libx264 @ 0514f860] i16 v,h,dc,p: 26% 71%  1%  1%
[libx264 @ 0514f860] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 47% 21%  3%  3%  3%  3%
 3%  3%
[libx264 @ 0514f860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 54% 10%  2%  3%  2%  4%
 2%  3%
[libx264 @ 0514f860] i8c dc,h,v,p: 64% 19% 11%  5%
[libx264 @ 0514f860] Weighted P-Frames: Y:11.2% UV:7.6%
[libx264 @ 0514f860] ref P L0: 55.7% 12.9% 20.2% 10.3%  0.8%
[libx264 @ 0514f860] ref B L0: 76.7% 21.5%  1.8%
[libx264 @ 0514f860] ref B L1: 95.4%  4.6%
[libx264 @ 0514f860] kb/s:1896.70

ffmpeg version: Zeranoe 7-30-2012 version
built on ... Jul 30 2012 (taken from the top of what I pasted)

Change History (28)

comment:1 by Clément Bœsch, 12 years ago

Description: modified (diff)

comment:2 by Pyriel0, 12 years ago

After some troubleshooting, we found that the outputs -f flv udp://127.0.0.1:12345 and -f flv - > NUL work. The problem occurs with rtmp output and when trying to pipe to another ffmpeg for streaming with rtmp. Suspected problem with librtmp

Last edited 12 years ago by Pyriel0 (previous) (diff)

in reply to:  description comment:3 by Carl Eugen Hoyos, 12 years ago

Replying to Pyriel0:

If I change "-f flv rtmp:xxxx" to "f:\test.mp4" to record to a hard drive, it works perfect.

What about f:\test.flv ?

comment:4 by Pyriel0, 12 years ago

f:\test.flv works fine

comment:5 by burek, 12 years ago

In the following examples, piping of 2 ffmpeg processes was used to distinguish which process exhibits the memory exhaustion bug.

Examples that exhibit 8GB memory exhaustion:

1: All-in-one cmd line:

ffmpeg -re -i "f:\xxx"\
	-pix_fmt yuv420p -s hd720\
	-vcodec libx264 -preset medium -b:v 2400k -maxrate 2400k -bufsize 600k\
	-acodec libmp3lame -ac 2 -b:a 128k -ar 44100\
	-f flv rtmp://live-dfw.justin.tv/app/xxx"

2: Split into 2 processes, first one encodes the stuff, the second one streams it. What is strange is that 1st process, that does the encoding, exhibits the bug with high ram memory usage, but it was expected that 2nd process would do so, because of rtmp. I can only guess that second process does not read data from pipe fast enough, which causes the first process to suffocate the available ram memory:

ffmpeg -re -i "f:\xxx" -pix_fmt yuv420p -s hd720\
	-vcodec libx264 -preset medium -b:v 2400k -maxrate 2400k -bufsize 600k\
	-acodec libmp3lame -ac 2 -b:a 128k -ar 44100\
	-f flv - |\
		ffmpeg -f flv -i - -c copy -f flv "rtmp://live-dfw.justin.tv/app/xxx"

Examples that DON'T exhibit 8GB memory exhaustion:

1: Output to DEV/NULL using flv file format:

ffmpeg -re -i "f:\xxx" -pix_fmt yuv420p -s hd720\
	-vcodec libx264 -preset medium -b:v 2400k -maxrate 2400k -bufsize 600k\
	-acodec libmp3lame -ac 2 -b:a 128k -ar 44100\
	-y -f flv - > NUL

2: Output using udp instead of rtmp:

ffmpeg -re -i "f:\xxx" -pix_fmt yuv420p -s hd720\
	-vcodec libx264 -preset medium -b:v 2400k -maxrate 2400k -bufsize 600k\
	-acodec libmp3lame -ac 2 -b:a 128k -ar 44100 -f flv - |\
		ffmpeg -f flv -i - -c copy -f flv udp://127.0.0.1:12345
Last edited 12 years ago by burek (previous) (diff)

comment:6 by Carl Eugen Hoyos, 12 years ago

Keywords: framerate removed
Version: unspecifiedgit-master

comment:7 by Pyriel0, 12 years ago

I have been messing around with this more and found the rtmp will work if the bitrate is 1500k or less. When I run ffmpeg with -report it shows

HandleServerBW: server BW = 2500000
HandleClientBW: client BW = 2500000 2

in the handshake with the justin.tv server. Is either ffmpeg or librtmp artificially capping the bandwidth? When I move the bitrate up to 2000k the fps starts dropping and all ram is slowly taken up.

comment:8 by Roger Pack, 12 years ago

@Pyriel0 does it lose latency over time? like it gets farther and farther behind?
Also what's your complete command line?

comment:9 by Pyriel0, 12 years ago

The command line I used for what is pasted is at the very top. Here are some examples.
I used this command line to record to the hard drive first and it works fine. Then I changed the output from f:\testing.mp4 to -f flv "rtmp://live-dfw.justin.tv/app/xxxxxx".

ffmpeg -re -y -rtbufsize 100000k -f dshow -i video="SCFH DSF":audio="Line 1 (Virtual Audio Cable)" -pix_fmt yuv420p -s hd720 -vcodec libx264 -preset medium -maxrate 2400k -bufsize 600k -acodec libmp3lame -ac 2 -b:a 128k f:\testing.mp4

I used the 32 bit 7-30-2012 zeranoe version. Forgot the 32 bit does not pick up virtual audio cable so the first 3 examples do not have audio. For the last video "2400k test 3 audio", I changed the audio to "virtual-audio-capturer" so there would be sound. 2400kb test 1 and 2 are the same, I only ran it again because I forgot how low the fps went on the first run.

http://www.twitch.tv/pyriel0/videos

2400k tests were done using the bitrates in the commnad line. 1500k used 1500k maxrate and 500k buffer. The 1500k streaming held 30 fps. 2400k dropped down to 12 fps. The audio remains stable in the final 2400kb test when the video is choppy. I doubt there is a latency problem since the audio does not get messed up.

System ram usage:
Game only: ~3.5 GB
Recording to hard drive: ~3.8 GB
Streaming 1500k: ~4 GB
Streaming 2400kb: ~5 GB

The highest cpu usage from windows task manager while recording to the hard drive at 2400k was 55%. This is approx 20% from the game and 35% from ffmpeg.

I can only use the 32 bit version for these tests because the 64 bit uses all available ram which causes everything to stutter.

Edit: I uploaded one last video using ffsplit to show the server can take more than 1500k bitrate. Ffsplit was set for 2000k and I watched the upload through my router's dd-wrt bandwidth monitor. It went well above 2000k a lot and spiked up over 3000k quite a bit too. The video does not have these fps issues even though the bitrate being output was much higher at parts than what I am attempting to do with ffmpeg.


Last edited 12 years ago by Pyriel0 (previous) (diff)

comment:10 by Defiance, 12 years ago

I've got the same problem both with own3d.tv and justin.tv . One difference is

Using this code is impossible to me because it eats ~1.5 GB memory instantly and start to real time buffer very soon (since i dont have any free memory anymore and my system crash)

ffmpeg -re -rtbufsize 100000k -r 25 -f dshow -i video="screen-capture-recorder" -f dshow -i audio="DirectSound Capture Device" -f dshow -i audio="Microphone (Realtek High Defini" -filter_complex amix=inputs=2:duration=first:dropout_transition=3 -c:a libmp3lame -ac 2 -b:a 128k -ar 44100 -c:v libx264 -preset faster -pix_fmt yuv420p -x264opts vbv-bufsize=3600:vbv-maxrate=1800:crf=23 -s 1920x1080 -y -f flv "rtmp://live-lhr-backup.justin.tv/app/STREAMKEY"

Splitting ffmpeg into two processes fixed memory usage (400mb for process that encodes dshow input and audio into test.flv and 3mb for process that sends test.flv to rtmp) :

Input:

ffmpeg -re -rtbufsize 100000k -r 30 -f dshow -i video="screen-capture-recorder" -f dshow -i audio="DirectSound Capture Device" -f dshow -i audio="Microphone (Realtek High Defini" -filter_complex amix=inputs=2:duration=first:dropout_transition=3 -c:a libmp3lame -ac 2 -b:a 128k -ar 44100 -c:v libx264 -preset faster -pix_fmt yuv420p -x264opts vbv-bufsize=3600:vbv-maxrate=1800:crf=23 -s 1920x1080 -y -f flv "test.flv"

Output:

ffmpeg -re -i "test.flv" -c copy -f flv "rtmp://live-lhr-backup.justin.tv/app/STREAMKEY"

But my FPS still drops from 25 to 12 in a few minutes in Output command line (when input is constant 25 fps@1500 bitrate). CPU usage is around 40% from ffpmeg.

Adding video too (sorry for the convesation i dont have any good example):

http://ru.twitch.tv/defiance_test/b/328108751

Last edited 12 years ago by Defiance (previous) (diff)

comment:11 by Roger Pack, 12 years ago

@Pyriel0 I did see this line in rtmp.c:

r->m_nServerBW = 2500000;

FWIW.

Also as a note I'm going to put my latest theories/ideas on this one at http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=7&t=657 so there may be some other feedback there...

My next question is...does ffmpeg have any internal buffering mechanism *before* the output (generic or otherwise) anybody? Does it have a separate thread for the "output" container et al? (or does the encoder, libx264, basically block while it is writing to the output?)

comment:12 by Roger Pack, 12 years ago

@Pyriel0 does 32 bit not eat RAM? (I have some suggestions/questions on the zeranoe forum...) in general when you get drops in fps, do you have free (idle) cpu, and free bandwidth?

comment:13 by Roger Pack, 12 years ago

ok the rtbufsize has landed in the zeranoe builds, give it a shot (if there's no further feedback in a week or so I'd close this, since I'm unable to reproduce it elsewise...)

comment:14 by Pyriel0, 12 years ago

I posted on the zeranoe site. The new version makes the buffer drop a lot of frames while using rtmp and the video is choppy. It still records to the hard drive without any problem though.

I read the 32 bit programs cannot use more than 2GB. The problems still happen but it doesn't let the program take all my memory like the 64 bit version does. These encodings do not take all of the bandwidth or my cpu.

comment:15 by Roger Pack, 12 years ago

I believe "part" of the problem has been fixed with a966d94891cea4b571bd2 . The original problem (the problem given in the title) is quite possibly still there. @Pyriel0 so...do you still see fps drops over time (and also have idle cpu and idle bandwidth?)

comment:16 by Pyriel0, 12 years ago

All of the newer versions drop virtually all the frames when trying to stream to justin.tv with rtmp. It still works fine if I only record to the hard drive. I have idle cpu power and idle bandwidth. I have tried 2-3 updates in the last month and I just tried the latest (9-19 64 bit) a few minutes ago.

comment:18 by mkovac, 11 years ago

Hello,

Any news regarding this ? I have the same issue, FPS dropping continuously when using libx264 ==> FLV ==> RTMP, it will just dropp slower or faster depending on the bitrate.

What I don't get is that how RTMP is still supported in ffmpeg with such an issue, or why isn't there any note warning on this ?

Here's my version (on Windows) :

C:\Users\ext-mko\Desktop\ffmpeg-20130314-git-9efcfbe-win32-static\bin>ffmpeg -version
ffmpeg version N-50911-g9efcfbe
built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --
enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-lib
vo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 19.100 / 52. 19.100
libavcodec 55. 0.100 / 55. 0.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 54. 4.100 / 54. 4.100
libavfilter 3. 45.103 / 3. 45.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

Thank you.

comment:19 by Pyriel0, 11 years ago

I tried a more recent ffmpeg build from the zeranoe site and it still did not work.

All I found about it was the packet size is larger than what windows likes. This causes the framerate to drop because ffmpeg would keep trying to hold/buffer the packets. There is a free streaming program called FFsplit. On that forum one of the makers said he split the packets but that is beyond me. The name was taqattack I think. This is to the best of my memory. It has been a long time since I looked at anything about this problem.

When I had these troubles, I kept getting run in circles about my internet speed and cpu power (which are both more than sufficient) and the only thing done was dumping the buffer when it filled. The packet size problem was ignored. I just gave up and now I use Open Broadcaster Software if I need to stream or record the desktop.

Anyways that is all I have on it. I hope you have better luck than me if you decide to try and get this problem fixed.

comment:20 by mikeversteeg, 10 years ago

This bug is still present in the current release (and I wish I had found this topic a week ago).

comment:21 by Daniel Miranda, 10 years ago

I'm not sure if this is supposed to be Windows-specific, but I'm experiencing what seem to be similar symptoms on Linux (Fedora 20, ffmpeg 2.1.4). I have 20Mbps of effective upload bandwidth, but trying to stream a 2000Kbps encoded stream to twitch.tv (using RTMP) only allows me to send at ~40FPS, but encoding to a local file works perfectly at 60FPS.

Last edited 10 years ago by Daniel Miranda (previous) (diff)

comment:22 by ctetrick, 9 years ago

I've been looking at this issue for the last couple of weeks and have some observations.
If I stream to live-dwf.twitch.tv/app/ The frame rate does not drop. This server is near my location, and has a very low RTT.
If I stream to live-prg.twitch.tv/app The frame rate drops as described. RTT is around 147ms.
I'm using an ffmpeg build with librtmp enabled.
Some people have noted that a TPC Relay app seems to help. I got similar results.
Now, in librtmp the function RTMP_SendPacket() packets are broken up by the default outgoing chunksize (128 bytes) and these are sent to the socket directly. However, I noticed this code:

  /* send all chunks in one HTTP request */
  if (r->Link.protocol & RTMP_FEATURE_HTTP) 
  {
    int chunks = (nSize+nChunkSize-1) / nChunkSize;
    if (chunks > 1)
    {
      tlen = chunks * (cSize + 1) + nSize + hSize;
      tbuf = malloc(tlen);
      if (!tbuf)
        return FALSE;
      toff = tbuf;
    }
  }

By forcing the use of buffering with

  if(TRUE)

or

  if ((r->Link.protocol & RTMP_FEATURE_HTTP) ||
	  (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO) ||
	  (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO))

The framerate improves considerably - limited by RTT.

Last edited 9 years ago by ctetrick (previous) (diff)

comment:23 by junogoose, 9 years ago

Just chiming in with my experiences. Not much to contribute, as the scenario is similar to the other posters. ... also wishing I had seen this post weeks ago (adding 'memory' to the search terms makes the difference).

Using ffmpeg-20141217-git-3ba1050-win64-static on Win7 Pro. i5 quad core, 8GB ram. Similar to what Pyriel0 noted 2 years ago, the issues only arise for bitrates > 1400k or so.

Saving to local file works fine.

>ffmpeg -rtsp_transport tcp -i rtsp://<stream url> -video_size 1280x720 -vcodec libx264 -pix_fmt + -framerate 12 -g 24 -b:v 20
48k -maxrate 3000k -bufsize 4096k -acodec libmp3lame -ac 1 -ar 44100 -ab 32k -f
flv rtmp://a.rtmp.youtube.com/live2/<stream key>


ffmpeg version N-68500-g3ba1050 Copyright (c) 2000-2014 the FFmpeg developers
  built on Dec 17 2014 01:55:42 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 15.100 / 56. 15.100
  libavformat    56. 15.105 / 56. 15.105
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  4.100 /  5.  4.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, rtsp, from 'rtsp://<stream url>':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9],
14.99 fps, 30 tbr, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: adpcm_g726, 8000 Hz, mono, s16, 32 kb/s
No pixel format specified, yuvj420p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 00000000053d0b40] using SAR=1/1
[libx264 @ 00000000053d0b40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX
[libx264 @ 00000000053d0b40] profile High, level 3.1
[libx264 @ 00000000053d0b40] 264 - core 142 r2479 dd79a61 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 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_pski
p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
mate=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=2 keyint=24 keyint_min=2
scenecut=40 intra_refresh=0 rc_lookahead=24 rc=abr mbtree=1 bitrate=2048 ratetol
=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=3000 vbv_bufsize=4096 nal_
hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/<stream key>
':
  Metadata:
    title           : Media Presentation
    encoder         : Lavf56.15.105
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuvj420p(pc), 12
80x720 [SAR 1:1 DAR 16:9], q=-1--1, 2048 kb/s, 14.99 fps, 1k tbn, 14.99 tbc
    Metadata:
      encoder         : Lavc56.15.100 libx264
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, mono
, s16p, 32 kb/s
    Metadata:
      encoder         : Lavc56.15.100 libmp3lame
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (adpcm_g726 (g726) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
frame=   33 fps=0.0 q=0.0 size=       0kB time=00:00:03.34 bitrate=   1.0kbits/s
frame=   35 fps= 31 q=30.0 size=      99kB time=00:00:03.47 bitrate= 232.7kbits/
frame=   47 fps= 27 q=29.0 size=     194kB time=00:00:04.46 bitrate= 356.4kbits/
frame=   53 fps= 22 q=24.0 size=     278kB time=00:00:04.96 bitrate= 458.7kbits/
frame=   59 fps= 17 q=22.0 size=     475kB time=00:00:05.48 bitrate= 709.8kbits/
frame=   64 fps= 16 q=26.0 size=     573kB time=00:00:05.90 bitrate= 795.4kbits/
frame=   68 fps= 15 q=27.0 size=     686kB time=00:00:06.23 bitrate= 901.8kbits/
frame=   75 fps= 15 q=25.0 size=     792kB time=00:00:06.98 bitrate= 929.2kbits/
frame=   80 fps= 14 q=26.0 size=     926kB time=00:00:07.40 bitrate=1024.7kbits/
frame=   83 fps= 12 q=24.0 size=    1086kB time=00:00:07.67 bitrate=1159.5kbits/
frame=   88 fps= 12 q=27.0 size=    1185kB time=00:00:08.21 bitrate=1182.6kbits/
frame=   92 fps= 12 q=26.0 size=    1294kB time=00:00:08.55 bitrate=1239.6kbits/
[h264 @ 00000000059c4360] Cannot use next picture in error concealment
[h264 @ 00000000059c4360] concealing 1362 DC, 1362 AC, 1362 MV errors in P frame

[h264 @ 00000000056c33c0] negative number of zero coeffs at 44 35
[h264 @ 00000000056c33c0] error while decoding MB 44 35
[h264 @ 00000000056c33c0] concealing 805 DC, 805 AC, 805 MV errors in I frame
frame=   99 fps= 12 q=26.0 size=    1396kB time=00:00:09.98 bitrate=1145.2kbits/
frame=  103 fps= 12 q=27.0 size=    1511kB time=00:00:10.46 bitrate=1182.8kbits/
frame=  107 fps= 11 q=27.0 size=    1679kB time=00:00:11.21 bitrate=1226.3kbits/
frame=  111 fps= 11 q=28.0 size=    1779kB time=00:00:11.54 bitrate=1261.8kbits/
[h264 @ 00000000056c33c0] Cannot use next picture in error concealment
[h264 @ 00000000056c33c0] concealing 1358 DC, 1358 AC, 1358 MV errors in P frame

frame=  118 fps= 11 q=27.0 size=    1884kB time=00:00:12.13 bitrate=1272.5kbits/
[h264 @ 00000000056c0c80] Cannot use next picture in error concealment
[h264 @ 00000000056c0c80] concealing 1461 DC, 1461 AC, 1461 MV errors in P frame

frame=  123 fps= 11 q=26.0 size=    1985kB time=00:00:12.45 bitrate=1305.4kbits/
[h264 @ 00000000056c3b00] out of range intra chroma pred mode at 10 4
[h264 @ 00000000056c3b00] error while decoding MB 10 4
[h264 @ 00000000056c3b00] concealing 3319 DC, 3319 AC, 3319 MV errors in I frame

frame=  131 fps= 10 q=25.0 size=    2183kB time=00:00:13.81 bitrate=1294.6kbits/
frame=  134 fps= 10 q=19.0 size=    2283kB time=00:00:14.07 bitrate=1328.5kbits/
frame=  136 fps= 10 q=23.0 size=    2376kB time=00:00:14.25 bitrate=1365.4kbits/
frame=  139 fps=9.9 q=24.0 size=    2478kB time=00:00:14.52 bitrate=1397.6kbits/
frame=  141 fps=9.6 q=23.0 size=    2585kB time=00:00:14.67 bitrate=1442.8kbits/
frame=  146 fps=9.6 q=24.0 size=    2691kB time=00:00:16.04 bitrate=1373.8kbits/
frame=  152 fps=9.6 q=25.0 size=    2820kB time=00:00:16.88 bitrate=1367.6kbits/
[h264 @ 0000000005b85000] Cannot use next picture in error concealment
[h264 @ 0000000005b85000] concealing 1447 DC, 1447 AC, 1447 MV errors in P frame

frame=  155 fps=9.2 q=25.0 size=    3001kB time=00:00:17.83 bitrate=1378.2kbits/
frame=  160 fps=9.2 q=22.0 size=    3085kB time=00:00:19.98 bitrate=1264.2kbits/
frame=  167 fps=9.3 q=25.0 size=    3190kB time=00:00:20.54 bitrate=1271.6kbits/
frame=  170 fps=8.9 q=24.0 size=    3402kB time=00:00:20.79 bitrate=1340.0kbits/
frame=  175 fps=8.9 q=22.0 size=    3542kB time=00:00:21.19 bitrate=1369.2kbits/
frame=  180 fps=8.9 q=19.0 size=    3643kB time=00:00:21.63 bitrate=1379.6kbits/
frame=  182 fps=8.7 q=17.0 size=    3779kB time=00:00:21.82 bitrate=1418.4kbits/
[h264 @ 00000000059c4360] concealing 2710 DC, 2710 AC, 2710 MV errors in I frame

frame=  186 fps=8.5 q=16.0 size=    3954kB time=00:00:22.22 bitrate=1457.0kbits/
[h264 @ 00000000059c4360] Cannot use next picture in error concealment
[h264 @ 00000000059c4360] concealing 1511 DC, 1511 AC, 1511 MV errors in P frame

frame=  190 fps=8.2 q=22.0 size=    4172kB time=00:00:22.53 bitrate=1517.0kbits/
frame=  192 fps=8.1 q=22.0 size=    4271kB time=00:00:22.71 bitrate=1540.2kbits/
frame=  194 fps=7.9 q=22.0 size=    4480kB time=00:00:22.87 bitrate=1604.6kbits/
[h264 @ 0000000005b85000] Cannot use next picture in error concealment
[h264 @ 0000000005b85000] concealing 1659 DC, 1659 AC, 1659 MV errors in P frame

frame=  196 fps=7.7 q=23.0 size=    4604kB time=00:00:23.01 bitrate=1639.1kbits/
frame=  200 fps=7.7 q=23.0 size=    4725kB time=00:00:24.22 bitrate=1598.1kbits/
frame=  206 fps=7.7 q=23.0 size=    4834kB time=00:00:27.09 bitrate=1461.8kbits/
frame=  210 fps=7.7 q=24.0 size=    4941kB time=00:00:29.11 bitrate=1390.3kbits/
frame=  215 fps=7.7 q=24.0 size=    5060kB time=00:00:29.64 bitrate=1398.5kbits/
frame=  218 fps=7.6 q=20.0 size=    5224kB time=00:00:29.86 bitrate=1433.0kbits/
frame=  222 fps=7.6 q=24.0 size=    5327kB time=00:00:30.20 bitrate=1444.7kbits/
frame=  228 fps=7.7 q=20.0 size=    5441kB time=00:00:30.77 bitrate=1448.1kbits/
frame=  232 fps=7.4 q=21.0 size=    5708kB time=00:00:31.10 bitrate=1503.2kbits/
frame=  235 fps=7.4 q=21.0 size=    5845kB time=00:00:31.81 bitrate=1505.0kbits/
[h264 @ 00000000056c33c0] negative number of zero coeffs at 5 37
[h264 @ 00000000056c33c0] error while decoding MB 5 37
[h264 @ 00000000056c33c0] concealing 684 DC, 684 AC, 684 MV errors in I frame
frame=  240 fps=7.4 q=17.0 size=    5972kB time=00:00:32.89 bitrate=1487.5kbits/
frame=  242 fps=7.2 q=19.0 size=    6181kB time=00:00:33.05 bitrate=1531.9kbits/
[h264 @ 00000000056c0c80] Cannot use next picture in error concealment
[h264 @ 00000000056c0c80] concealing 967 DC, 967 AC, 967 MV errors in P frame
frame=  244 fps=7.0 q=14.0 size=    6363kB time=00:00:33.17 bitrate=1571.3kbits/
frame=  246 fps=7.0 q=20.0 size=    6462kB time=00:00:33.34 bitrate=1587.7kbits/
frame=  249 fps=7.0 q=21.0 size=    6560kB time=00:00:35.52 bitrate=1512.6kbits/
frame=  253 fps=7.0 q=21.0 size=    6657kB time=00:00:35.86 bitrate=1520.4kbits/
frame=  256 fps=6.8 q=18.0 size=    6928kB time=00:00:36.13 bitrate=1570.5kbits/
frame=  260 fps=6.8 q=20.0 size=    7037kB time=00:00:36.46 bitrate=1580.9kbits/
[h264 @ 0000000005b85000] concealing 2646 DC, 2646 AC, 2646 MV errors in I frame

frame=  265 fps=6.8 q=15.0 size=    7148kB time=00:00:38.88 bitrate=1505.8kbits/
frame=  266 fps=6.8 q=19.0 size=    7250kB time=00:00:38.97 bitrate=1523.9kbits/
frame=  271 fps=6.8 q=16.0 size=    7379kB time=00:00:39.64 bitrate=1524.6kbits/
frame=  273 fps=6.7 q=18.0 size=    7537kB time=00:00:39.81 bitrate=1550.8kbits/
[h264 @ 00000000056c3b00] concealing 674 DC, 674 AC, 674 MV errors in I frame
frame=  277 fps=6.6 q=17.0 size=    7776kB time=00:00:41.34 bitrate=1540.7kbits/
frame=  280 fps=6.4 q=18.0 size=    8030kB time=00:00:41.71 bitrate=1577.0kbits/
[h264 @ 00000000056c0c80] concealing 60 DC, 60 AC, 60 MV errors in I frame
frame=  286 fps=6.5 q=21.0 size=    8137kB time=00:00:43.31 bitrate=1539.2kbits/
frame=  290 fps=6.4 q=21.0 size=    8375kB time=00:00:45.34 bitrate=1513.0kbits/
WriteN, RTMP send error 10054 (129 bytes)
WriteN, RTMP send error 10053 (63 bytes)
WriteN, RTMP send error 10038 (42 bytes)
av_interleaved_write_frame(): Operation not permitted
[flv @ 00000000053d00a0] Failed to update header with correct duration.
[flv @ 00000000053d00a0] Failed to update header with correct filesize.
frame=  292 fps=6.3 q=-1.0 Lsize=    8424kB time=00:00:46.79 bitrate=1474.5kbits
/s dup=0 drop=5
video:8311kB audio:104kB subtitle:0kB other streams:0kB global headers:0kB muxin
g overhead: 0.103250%
[libx264 @ 00000000053d0b40] frame I:14    Avg QP:15.72  size:160659
[libx264 @ 00000000053d0b40] frame P:158   Avg QP:18.42  size: 43366
[libx264 @ 00000000053d0b40] frame B:120   Avg QP:25.83  size:  8177
[libx264 @ 00000000053d0b40] consecutive B-frames: 33.2% 23.3% 38.0%  5.5%
[libx264 @ 00000000053d0b40] mb I  I16..4:  5.2% 35.0% 59.9%
[libx264 @ 00000000053d0b40] mb P  I16..4:  1.6%  1.9%  2.6%  P16..4: 48.2% 13.6
% 10.0%  0.0%  0.0%    skip:22.0%
[libx264 @ 00000000053d0b40] mb B  I16..4:  0.1%  0.2%  0.1%  B16..8: 35.3%  3.1
%  1.3%  direct: 6.6%  skip:53.5%  L0:35.8% L1:59.5% BI: 4.7%
[libx264 @ 00000000053d0b40] 8x8 transform intra:33.5% inter:19.9%
[libx264 @ 00000000053d0b40] coded y,uvDC,uvAC intra: 86.3% 80.4% 61.6% inter: 3
5.7% 21.9% 7.4%
[libx264 @ 00000000053d0b40] i16 v,h,dc,p: 85%  4%  5%  6%
[libx264 @ 00000000053d0b40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 21% 11%  4%  7%
 7%  9%  7% 11%
[libx264 @ 00000000053d0b40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 23% 11%  5%  8%
 6% 10%  6% 10%
[libx264 @ 00000000053d0b40] i8c dc,h,v,p: 31% 33% 30%  6%
[libx264 @ 00000000053d0b40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000053d0b40] ref P L0: 76.6% 10.0%  8.6%  4.9%
[libx264 @ 00000000053d0b40] ref B L0: 92.5%  7.3%  0.2%
[libx264 @ 00000000053d0b40] ref B L1: 94.9%  5.1%
[libx264 @ 00000000053d0b40] kb/s:1845.30
Conversion failed!

Last edited 9 years ago by junogoose (previous) (diff)

comment:24 by junogoose, 9 years ago

Just set up a Fedora 21 x64 vmware machine off the host machine used in previous post. 1.5GB ram, 2 cores. Ran ffmpeg-git-20150103-64bit-static linux build with identical ffmpeg command from previous post.

Runs without a hitch.

comment:25 by ctetrick, 9 years ago

junogoose,

I'm running on a i7-2600 3.4GHz, 6GB ram, Windows 7. I don't think ram or cpu is an issue in this.

I am using a modified windows build based on ffmpeg-git-85f2c01 source.
My test command line is

-re -y -loglevel verbose -probesize 4096 -i "D:\Media\Clips\Studio Ghibli 25.mp4" -flags +global_header -c:v copy -c:a copy -f flv "rtmp://live-prg.twitch.tv/app/ playpath=live_<mystreamid>"

The video clip is h264/aac 720p 2.5mbps. This effectively eliminates the encoders.
The main factor seems to be the ping time.
Since I'm in Texas, the above url is far away and has an average ping of 143ms.
If I stream to live-dfw.twitch.tv/app/ (Server is in Dallas TX), the ping time is 9ms, and works without modification.

Your test may indicate that this is a windows specific socket's problem, but so far I haven't been able to confirm this.

If anything it may be that Linux handles things differently. The main thing seems to be that many small sends with a large RTT stalls on Windows, but not Linux.

comment:26 by ctetrick, 9 years ago

sorry, duplicate comment. :(

Last edited 9 years ago by ctetrick (previous) (diff)

comment:27 by ctetrick, 9 years ago

OK. in a previous comment I suggested changing the rtmp send function to use the available buffering.
While this may make things a bit more efficient, it's not the real problem.
I've added a couple of options to librtmp. One to turn the NO_TCPDELAY flag off, and another to set the socket output buffer size. (the first is experimental.) without the arguments behavior is unchanged. I'm hoping to get a patch into librtmp.

I think this explains a number of previous observations.
Windows 7 uses a default buffer of 8Kb, a friend's Linux installation uses 16k, and I've read that many Linux implementations use 128k.
This would explain why some users report better results on Linux.
This would explain why apps like TCPRelay help assuming it changes the buffering.
Users have suggested changing the default buffer size in Windows using the registry as well. But I think that's a bad idea since it is likely to affect other applications or use a great deal of ram if you set it too high.

comment:28 by hamletmun, 9 years ago

ctetrick,

Probably you are referring to this registry change:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AFD\Parameters]
 "DefaultReceiveWindow"=dword:00010000
 "DefaultSendWindow"=dword:00010000

http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=7&t=657&start=60#p5527

I agree that this is not the best solution and I don't like changing registry values either. :-)
However, this is an effective workaround. At least, now I can use ffmpeg+rtsp+windows.

I hope you could find a definitive solution to this problem.

Note: See TracTickets for help on using tickets.