[FFmpeg-user] RTMP relay livestream quits after some time with End of file error
regstuff
regstuff at yopmail.com
Sat Nov 3 10:34:44 EET 2018
*Some context:* I have an Nginx server (with rtmp-module) on a Ubuntu-16.04
VM. I'm using it to receive an input rtmp stream from my PC. FFmpeg is then
used in the VM to take this input and relay to multiple destinations after
transcoding, overlaying a lower third, and changing the volume.
*FFmpeg version:* ffmpeg version N-92147-gf85fa10 Copyright (c) 2000-2018
the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --pkg-config-flags=--static
--extra-cflags=-I/home/btech11/ffmpeg_build/include
--extra-ldflags=-L/home/btech11/ffmpeg_build/lib --extra-libs='-lpthread
-lm' --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx
--enable-libx264 --enable-libx265 --enable-libzmq --enable-librtmp
--enable-network --enable-nonfree
libavutil 56. 19.101 / 56. 19.101
libavcodec 58. 32.100 / 58. 32.100
libavformat 58. 18.104 / 58. 18.104
libavdevice 58. 4.105 / 58. 4.105
libavfilter 7. 33.100 / 7. 33.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
*FFmpeg command:* /usr/local/bin/ffmpeg -nostdin -thread_queue_size 512 -i
rtmp://127.0.0.1:1935/stream1/input -i
/usr/local/nginx/scripts/images/lowerthird.png -af azmq,volume=2 -c:a
libfdk_aac -filter_complex
'zmq=bind_address=tcp\\\://127.0.0.1\\\:5556,overlay=0:H' -vcodec libx264
-pix_fmt yuv420p -preset veryfast -r 25 -g 50 -b:v 6000k -maxrate 6M
-minrate 6M -bufsize 6M -f flv rtmp://a.rtmp.youtube.com/live2/[my key] -y
**Problem:** Ffmpeg quits after a random duration between 15-30 minutes with
this error.
av_interleaved_write_frame(): End of file
[flv @ 0x25fffc0] Failed to update header with correct duration.
[flv @ 0x25fffc0] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/[my key]: End
of file
frame=36101 fps= 25 q=11.0 Lsize= 1066356kB time=00:24:04.37
bitrate=6048.0kbits/s speed= 1x
video:1042015kB audio:22620kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.161639%
[libx264 @ 0x2600c80] frame I:743 Avg QP: 6.67 size:269470
[libx264 @ 0x2600c80] frame P:35336 Avg QP:10.16 size: 24546
[libx264 @ 0x2600c80] frame B:22 Avg QP:15.04 size: 8699
[libx264 @ 0x2600c80] consecutive B-frames: 99.9% 0.0% 0.0% 0.0%
[libx264 @ 0x2600c80] mb I I16..4: 29.9% 4.3% 65.8%
[libx264 @ 0x2600c80] mb P I16..4: 3.0% 1.1% 2.3% P16..4: 27.1%
1.8% 1.5% 0.0% 0.0% skip:63.1%
[libx264 @ 0x2600c80] mb B I16..4: 1.8% 0.6% 0.3% B16..8: 8.7%
3.0% 0.6% direct: 6.1% skip:78.9% L0:39.6% L1:52.4% BI: 8.0%
[libx264 @ 0x2600c80] 8x8 transform intra:14.1% inter:12.1%
[libx264 @ 0x2600c80] coded y,uvDC,uvAC intra: 53.5% 51.1% 27.5% inter:
10.4% 12.7% 2.0%
[libx264 @ 0x2600c80] i16 v,h,dc,p: 52% 38% 6% 4%
[libx264 @ 0x2600c80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 34% 27% 2% 0%
0% 0% 1% 1%
[libx264 @ 0x2600c80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 51% 28% 12% 1% 1%
2% 1% 2% 1%
[libx264 @ 0x2600c80] i8c dc,h,v,p: 48% 23% 22% 7%
[libx264 @ 0x2600c80] Weighted P-Frames: Y:0.4% UV:0.3%
[libx264 @ 0x2600c80] kb/s:5915.49
Conversion failed!
I've also tried it with a codec copy command to try and eliminate the
problem:
/usr/local/bin/ffmpeg -nostdin -thread_queue_size 512 -i
rtmp://127.0.0.1:1935/stream1/input -c copy -f flv
rtmp://a.rtmp.youtube.com/live2/[my key] -y
The stream seems to work for longer but errors out after an hour with below
error.
av_interleaved_write_frame(): End of filekB time=01:07:20.22
bitrate=3166.5kbits/s speed= 1x
[flv @ 0x2c21e40] Failed to update header with correct duration.
[flv @ 0x2c21e40] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/[my key]: End
of file
frame=101001 fps= 25 q=-1.0 Lsize= 1561874kB time=01:07:20.55
bitrate=3166.6kbits/s speed= 1x
video:1479592kB audio:77420kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.312238%
Conversion failed!
Third command I tried was with acodec copy but vcodec applied:
/usr/local/bin/ffmpeg -nostdin -thread_queue_size 512 -i
rtmp://127.0.0.1:1935/stream1/input -i
/usr/local/nginx/scripts/images/lowerthird.png -acodec copy -filter_complex
'zmq=bind_address=tcp\\\://127.0.0.1\\\:5556,overlay=0:H' -vcodec libx264
-pix_fmt yuv420p -preset veryfast -r 25 -g 50 -b:v 6000k -maxrate 6M
-minrate 6M -bufsize 6M -f flv rtmp://a.rtmp.youtube.com/live2/[my key] -y
Errored out in 3 minutes the first time and 19 minutes th second time I
tried. Error output:
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo,
fltp, 163 kb/s
av_interleaved_write_frame(): End of fileB time=00:03:07.45
bitrate=6072.8kbits/s speed=1.02x
[flv @ 0x3303200] Failed to update header with correct duration.
[flv @ 0x3303200] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/[my key]: End
of file
frame= 4653 fps= 25 q=20.0 Lsize= 139504kB time=00:03:07.94
bitrate=6080.7kbits/s speed=1.02x
video:135616kB audio:3684kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.146554%
[libx264 @ 0x3304100] frame I:99 Avg QP:10.71 size:163258
[libx264 @ 0x3304100] frame P:4553 Avg QP:14.70 size: 27059
[libx264 @ 0x3304100] frame B:1 Avg QP:26.37 size: 4978
[libx264 @ 0x3304100] consecutive B-frames: 100.0% 0.0% 0.0% 0.0%
[libx264 @ 0x3304100] mb I I16..4: 31.1% 8.7% 60.2%
[libx264 @ 0x3304100] mb P I16..4: 5.6% 2.6% 4.5% P16..4: 23.5%
2.5% 2.0% 0.0% 0.0% skip:59.3%
[libx264 @ 0x3304100] mb B I16..4: 2.0% 2.4% 0.0% B16..8: 10.8%
1.1% 0.1% direct: 1.1% skip:82.4% L0:75.0% L1:24.0% BI: 1.0%
[libx264 @ 0x3304100] 8x8 transform intra:18.8% inter:19.7%
[libx264 @ 0x3304100] coded y,uvDC,uvAC intra: 49.8% 48.9% 18.3% inter:
10.2% 11.5% 1.8%
[libx264 @ 0x3304100] i16 v,h,dc,p: 62% 28% 6% 5%
[libx264 @ 0x3304100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 43% 30% 22% 2% 0%
0% 0% 1% 2%
[libx264 @ 0x3304100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 61% 21% 12% 1% 1%
1% 1% 1% 1%
[libx264 @ 0x3304100] i8c dc,h,v,p: 49% 21% 24% 7%
[libx264 @ 0x3304100] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x3304100] kb/s:5990.48
Conversion failed!
Strangely enough, doing a vcodec copy did not throw any error even after 2
hours, 20 minutes of streaming. I'm doing a longer duration stream to
further validate this. Will update this post with any info. The command I
used was:
/usr/local/bin/ffmpeg -nostdin -thread_queue_size 512 -i
rtmp://127.0.0.1:1935/stream1/input -af azmq,volume=2 -c:a libfdk_aac
-vcodec copy -f flv rtmp://a.rtmp.youtube.com/live2/[my key] -y
*Possibilities I've eliminated:* My bandwidth from the PC to the VM is
between 40-80mbps upload and download. I'm able to stream fine from my PC
using OBS to youtube for 7-8 hrs, so it's not a network issue.
The error occurs with various destinations: youtube, facebook, even another
endpoint on the same nginx server, so it's not an issue with network from VM
to youtube etc.
Error DOES NOT occur while streaming out of a local mp4 file using codec
copy, so it seems to be an error with an input rtmp stream.
Someone else here
<http://www.ffmpeg-archive.org/Stream-relay-fails-after-running-some-time-td4684965.html>
has a similar problem, but doesn't seem to have found a solution.
--
Sent from: http://www.ffmpeg-archive.org/
More information about the ffmpeg-user
mailing list