Discussion:
[FFmpeg-user] ffmpeg hangs when encoding rtmp input stream
Junior
2016-08-12 13:57:43 UTC
Permalink
Hi there,

I'm using ffmpeg to reencode the input coming from nginx_rtmp module with
the command below:

ffmpeg -i rtmp://localhost/publish/if_livestream -c:a libfdk_aac -b:a 64k
-c:v libx264 -b:v 136K -f flv "rtmp://localhost/live/if_livestream_lo
live=1 timeout=0 buffer=0" -c:a libfdk_aac -b:a 64k -c:v libx264 -b:v 436K
-f flv "rtmp://localhost/live/if_livestream_hi live=1 timeout=0 buffer=0"
ffmpeg version 3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --pkg-config-flags=--static --enable-gpl --enable-nonfree
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame
--enable-libvorbis --enable-libvpx --enable-libx264
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100

Unfortunately sometimes ffmpeg hangs exactly at that point. The last output
displayed is the line " libpostproc 54. 0.100 / 54. 0.100" and it
stops there. Sometimes it works fine.

Have anyone already faced this problem?

Thanks in advance,

Junior
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ff
Carl Eugen Hoyos
2016-08-13 10:21:52 UTC
Permalink
Hi!
Post by Junior
ffmpeg version 3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
Is the issue reprodicible with current FFmpeg git head?

Please provide a backtrace of FFmpeg when it hangs.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-req
Junior
2016-08-13 17:33:42 UTC
Permalink
Thanks for your prompt reply, Carl. Yes, it was reproductible with the
current FFmpeg head. Below you can see more information:


/root/build/FFmpeg/ffmpeg_g -loglevel debug -i
rtmp://localhost/publish/if_livestream\ live=1\ buffer=0 -c:a libfdk_aac
-b:a 64k -c:v libx264 -b:v 136K -f flv
rtmp://localhost/live/if_livestream_lo\ live=1\ timeout=0\ buffer=0 -c:a
libfdk_aac -b:a 64k -c:v libx264 -b:v 436K -f flv
rtmp://localhost/live/if_livestream_hi\ live=1\ timeout=0\ buffer=0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ffmpeg version N-81335-g3a81775 Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --pkg-config-flags=--static --enable-gpl --enable-nonfree
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-debug
--arch=amd64
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 51.102 / 57. 51.102
libavformat 57. 46.101 / 57. 46.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 51.100 / 6. 51.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument 'debug'.
Reading option '-i' ... matched as input file with argument
'rtmp://localhost/publish/if_livestream live=1 buffer=0'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument
'libfdk_aac'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '64k'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument
'libx264'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '136K'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'flv'.
Reading option 'rtmp://localhost/live/if_livestream_lo live=1 timeout=0
buffer=0' ... matched as output file.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument
'libfdk_aac'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '64k'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument
'libx264'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '436K'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'flv'.
Reading option 'rtmp://localhost/live/if_livestream_hi live=1 timeout=0
buffer=0' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file
rtmp://localhost/publish/if_livestream live=1 buffer=0.
Successfully parsed a group of options.
Opening an input file: rtmp://localhost/publish/if_livestream live=1
buffer=0.
[rtmp @ 0x5b9b680] No default whitelist set
[rtmp @ 0x5b9b680] Detected librtmp style URL parameters, these aren't
supported by the libavformat internal RTMP handler currently enabled. See
the documentation for the correct way to pass parameters.
[tcp @ 0x5b9bc60] No default whitelist set
[rtmp @ 0x5b9b680] Handshaking...
[rtmp @ 0x5b9b680] Type answer 3
[rtmp @ 0x5b9b680] Server version 13.14.10.13
[rtmp @ 0x5b9b680] Proto = rtmp, path = /publish/if_livestream, app =
publish, fname = if_livestream
[rtmp @ 0x5b9b680] Server bandwidth = 5000000
[rtmp @ 0x5b9b680] Client bandwidth = 5000000
[rtmp @ 0x5b9b680] New incoming chunk size = 4096
[rtmp @ 0x5b9b680] Creating stream...
[rtmp @ 0x5b9b680] Sending play command for 'if_livestream'


And here is the backtrace:

(gdb) bt
#0 0x00006d71987ed680 in __poll_nocancel () from /lib64/libc.so.6
#1 0x000000000066a9f2 in ff_network_wait_fd (write=0, fd=7) at
libavformat/network.c:78
#2 ff_network_wait_fd_timeout (fd=7, write=***@entry=0, timeout=0,
int_cb=0x5b9bc90) at libavformat/network.c:90
#3 0x00000000006c4ab6 in tcp_read (h=<optimized out>, buf=0x77e9e386528f
"", size=1) at libavformat/tcp.c:207
#4 0x00000000005ca204 in retry_transfer_wrapper (transfer_func=0x6c4a90
<tcp_read>, size_min=1, size=1, buf=0x77e9e386528f "", h=0x5b9bc60)
at libavformat/avio.c:378
#5 ffurl_read (h=***@entry=0x5b9bc60, buf=***@entry=0x77e9e386528f "",
size=***@entry=1) at libavformat/avio.c:411
#6 0x0000000000707dda in ff_rtmp_packet_read (h=0x5b9bc60,
p=***@entry=0x77e9e3865330,
chunk_size=4096, prev_pkt=***@entry=0x5b9b750,
nb_prev_pkt=***@entry=0x5b9b760) at libavformat/rtmppkt.c:164
#7 0x000000000068eb22 in get_packet (s=***@entry=0x5b9b680, for_header=0) at
libavformat/rtmpproto.c:2406
#8 0x00000000006932f1 in rtmp_open (s=0x5b9b680, uri=<optimized out>,
flags=<optimized out>) at libavformat/rtmpproto.c:2837
#9 0x00000000005c9876 in ffurl_connect (uc=0x5b9b680,
options=***@entry=0x77e9e386b540)
at libavformat/avio.c:209
#10 0x00000000005c9f3a in ffurl_open_whitelist (puc=***@entry=0x77e9e386b4a8,
filename=<optimized out>, flags=<optimized out>,
int_cb=<optimized out>, options=0x77e9e386b540, whitelist=0x0,
blacklist=***@entry=0x0, parent=***@entry=0x0) at
libavformat/avio.c:347
#11 0x00000000005d2bc0 in ffio_open_whitelist (s=0x5b9ade0,
filename=<optimized out>, flags=<optimized out>, int_cb=<optimized out>,
options=<optimized out>, whitelist=<optimized out>, blacklist=0x0) at
libavformat/aviobuf.c:1046
#12 0x000000000067d8b5 in io_open_default (s=<optimized out>, pb=<optimized
out>, url=<optimized out>, flags=<optimized out>,
options=<optimized out>) at libavformat/options.c:112
#13 0x00000000006d82a3 in init_input (options=0x77e9e386b540,
filename=0x77e9e386c830 "rtmp://localhost/publish/if_livestream live=1
buffer=0",
s=0x5b9adc0) at libavformat/utils.c:383
#14 avformat_open_input (ps=***@entry=0x77e9e386b608,
filename=***@entry=0x77e9e386c830
"rtmp://localhost/publish/if_livestream live=1 buffer=0", fmt=***@entry=0x0,
options=0x5b9a868)
at libavformat/utils.c:497
#15 0x000000000048d18d in open_input_file (o=***@entry=0x77e9e386b710,
filename=<optimized out>) at ffmpeg_opt.c:982
#16 0x0000000000490c5f in open_files (inout=0x137fc26 "input",
open_file=0x48b9f0 <open_input_file>, l=<optimized out>, l=<optimized out>)
at ffmpeg_opt.c:3069
#17 ffmpeg_parse_options (argc=***@entry=27, argv=***@entry=0x77e9e386c4b8)
at ffmpeg_opt.c:3106
#18 0x000000000047eb0d in main (argc=27, argv=0x77e9e386c4b8) at
ffmpeg.c:4325

Thanks again,

Junior
Post by Carl Eugen Hoyos
Hi!
Post by Junior
ffmpeg version 3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
Is the issue reprodicible with current FFmpeg git head?
Please provide a backtrace of FFmpeg when it hangs.
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-reques
Junior
2016-08-13 17:43:25 UTC
Permalink
Just as addendum, VLC is always able to play the stream which FFmpeg is
getting stucked.

Thanks,

Junior
Post by Junior
Thanks for your prompt reply, Carl. Yes, it was reproductible with the
/root/build/FFmpeg/ffmpeg_g -loglevel debug -i rtmp://localhost/publish/if_livestream\
live=1\ buffer=0 -c:a libfdk_aac -b:a 64k -c:v libx264 -b:v 136K -f flv
rtmp://localhost/live/if_livestream_lo\ live=1\ timeout=0\ buffer=0 -c:a
libfdk_aac -b:a 64k -c:v libx264 -b:v 436K -f flv rtmp://localhost/live/if_livestream_hi\
live=1\ timeout=0\ buffer=0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ffmpeg version N-81335-g3a81775 Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --pkg-config-flags=--static --enable-gpl --enable-nonfree
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-debug
--arch=amd64
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 51.102 / 57. 51.102
libavformat 57. 46.101 / 57. 46.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 51.100 / 6. 51.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument 'debug'.
Reading option '-i' ... matched as input file with argument
'rtmp://localhost/publish/if_livestream live=1 buffer=0'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument
'libfdk_aac'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '64k'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument
'libx264'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '136K'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'flv'.
Reading option 'rtmp://localhost/live/if_livestream_lo live=1 timeout=0
buffer=0' ... matched as output file.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument
'libfdk_aac'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '64k'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument
'libx264'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '436K'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'flv'.
Reading option 'rtmp://localhost/live/if_livestream_hi live=1 timeout=0
buffer=0' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file rtmp://localhost/publish/if_livestream
live=1 buffer=0.
Successfully parsed a group of options.
Opening an input file: rtmp://localhost/publish/if_livestream live=1
buffer=0.
supported by the libavformat internal RTMP handler currently enabled. See
the documentation for the correct way to pass parameters.
publish, fname = if_livestream
(gdb) bt
#0 0x00006d71987ed680 in __poll_nocancel () from /lib64/libc.so.6
#1 0x000000000066a9f2 in ff_network_wait_fd (write=0, fd=7) at
libavformat/network.c:78
int_cb=0x5b9bc90) at libavformat/network.c:90
#3 0x00000000006c4ab6 in tcp_read (h=<optimized out>, buf=0x77e9e386528f
"", size=1) at libavformat/tcp.c:207
#4 0x00000000005ca204 in retry_transfer_wrapper (transfer_func=0x6c4a90
<tcp_read>, size_min=1, size=1, buf=0x77e9e386528f "", h=0x5b9bc60)
at libavformat/avio.c:378
at libavformat/rtmpproto.c:2406
#8 0x00000000006932f1 in rtmp_open (s=0x5b9b680, uri=<optimized out>,
flags=<optimized out>) at libavformat/rtmpproto.c:2837
#9 0x00000000005c9876 in ffurl_connect (uc=0x5b9b680,
filename=<optimized out>, flags=<optimized out>,
int_cb=<optimized out>, options=0x77e9e386b540, whitelist=0x0,
libavformat/avio.c:347
#11 0x00000000005d2bc0 in ffio_open_whitelist (s=0x5b9ade0,
filename=<optimized out>, flags=<optimized out>, int_cb=<optimized out>,
options=<optimized out>, whitelist=<optimized out>, blacklist=0x0) at
libavformat/aviobuf.c:1046
#12 0x000000000067d8b5 in io_open_default (s=<optimized out>,
pb=<optimized out>, url=<optimized out>, flags=<optimized out>,
options=<optimized out>) at libavformat/options.c:112
#13 0x00000000006d82a3 in init_input (options=0x77e9e386b540,
filename=0x77e9e386c830 "rtmp://localhost/publish/if_livestream live=1
buffer=0",
s=0x5b9adc0) at libavformat/utils.c:383
at libavformat/utils.c:497
filename=<optimized out>) at ffmpeg_opt.c:982
#16 0x0000000000490c5f in open_files (inout=0x137fc26 "input",
open_file=0x48b9f0 <open_input_file>, l=<optimized out>, l=<optimized out>)
at ffmpeg_opt.c:3069
at ffmpeg_opt.c:3106
#18 0x000000000047eb0d in main (argc=27, argv=0x77e9e386c4b8) at
ffmpeg.c:4325
Thanks again,
Junior
Post by Carl Eugen Hoyos
Hi!
Post by Junior
ffmpeg version 3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
Is the issue reprodicible with current FFmpeg git head?
Please provide a backtrace of FFmpeg when it hangs.
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscrib
Reuben Martin
2016-08-15 04:26:03 UTC
Permalink
Post by Junior
I'm using ffmpeg to reencode the input coming from nginx_rtmp module with
What code-base are you sourcing the nginx_rtmp module from? And which version
of nginx?

The origional code-base by Arut has not received any significant development
in quite some time. Please make sure you are using the fork maintained by
Sergey: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module

-Reuben
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpe
Junior
2016-08-15 12:59:36 UTC
Permalink
Hi Reuben,

I was using the head of nginx_rtmp module and version 1.11.3. I've
dongraded nginx to version 1.6.3 and it seems to be working now. Probably a
nginx_rtmp bug with newer versions of nginx.

Thanks for your reply,

Junior
Post by Reuben Martin
Post by Junior
I'm using ffmpeg to reencode the input coming from nginx_rtmp module with
What code-base are you sourcing the nginx_rtmp module from? And which version
of nginx?
The origional code-base by Arut has not received any significant development
in quite some time. Please make sure you are using the fork maintained by
Sergey: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module
-Reuben
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffm
Reuben Martin
2016-08-15 15:26:30 UTC
Permalink
Post by Junior
I was using the head of nginx_rtmp module and version 1.11.3
If you want to use the module with nginx >= 1.10.0 then you need to build from
Sergey’s dev branch. (it’s stable despite being the dev branch. Unstable
features each have their own branches)

-Reuben
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscribe"
Junior
2016-08-15 19:06:52 UTC
Permalink
Thanks Reuben,

Do you know what is the recommended (more stable) version of nginx and
nginx_rtmp to work with for a production environment?

Thanks again,

Junior
Post by Reuben Martin
Post by Junior
I was using the head of nginx_rtmp module and version 1.11.3
If you want to use the module with nginx >= 1.10.0 then you need to build from
Sergey’s dev branch. (it’s stable despite being the dev branch. Unstable
features each have their own branches)
-Reuben
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscr
Reuben Martin
2016-08-16 01:18:10 UTC
Permalink
Post by Junior
Do you know what is the recommended (more stable) version of nginx and
nginx_rtmp to work with for a production environment?
There really is no “recommendation” other than test it out and see if it works
for you.

I’m currently using bleending edge nginx (1.11.3) with the module from Segey’s
dev branch without any issues. But I’m only pushing out RTMP. I’m not serving
up any HLS or DASH. That said, the dev branch is probably in better shape for
those feautres anyway. This is using Gentoo systems, so there may be other
factors that influence stability of Nginx between different distributions.

The one minor issue I’ve encountered is that if you have a push address
defined in the settings, and during the boot process when nginx is started up,
if it is unable to resolve those addresses it will fail to load. This happens
for me 99% of the time and I just have to restart it once the OS has obtained
an IP address and a DNS resolver address. There’s probably an "ip address
obtained" target or something similar I could set the service to wait for, but
I havn’t bothered to try messing with it since I already know what is causing
the problem.

-Reuben
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject
Junior
2016-08-17 11:21:34 UTC
Permalink
Thanks for sharing your experience, Reuben
Post by Reuben Martin
Post by Junior
Do you know what is the recommended (more stable) version of nginx and
nginx_rtmp to work with for a production environment?
There really is no “recommendation” other than test it out and see if it works
for you.
I’m currently using bleending edge nginx (1.11.3) with the module from Segey’s
dev branch without any issues. But I’m only pushing out RTMP. I’m not serving
up any HLS or DASH. That said, the dev branch is probably in better shape for
those feautres anyway. This is using Gentoo systems, so there may be other
factors that influence stability of Nginx between different distributions.
The one minor issue I’ve encountered is that if you have a push address
defined in the settings, and during the boot process when nginx is started up,
if it is unable to resolve those addresses it will fail to load. This happens
for me 99% of the time and I just have to restart it once the OS has obtained
an IP address and a DNS resolver address. There’s probably an "ip address
obtained" target or something similar I could set the service to wait for, but
I havn’t bothered to try messing with it since I already know what is causing
the problem.
-Reuben
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-r

Loading...