nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

ffmpeg stuck at startup; Input/Output error

Open the-papi opened this issue 9 years ago • 7 comments

Hello, I have stream server using nginx 1.12.0, nginx-rtmp-module 1.1.11 and ffmpeg 3.2.5-1~bpo8+1. When I connect to nginx using OBS everything goes fine, but ffmpeg often stuck at startup, but hardly ever doesn't goes stuck and everything works fine.

My command for ffmpeg:

ffmpeg -i rtmp://127.0.0.1:1935/$1/$STREAM_KEY -vcodec libx264 -vprofile high -preset ultrafast -x264opts keyint=40 -vf scale=640x360 -minrate 600k -maxrate 800k -acodec aac -strict -2 -f flv rtmp://127.0.0.1:1935/hls/"$NICK"_low -vcodec libx264 -vprofile high -preset ultrafast -x264opts keyint=40 -vf scale=858x480 -minrate 900k -maxrate 1200k -acodec aac -strict -2 -f flv rtmp://127.0.0.1:1935/hls/"$NICK"_mid -c copy -f flv rtmp://127.0.0.1:1935/hls/"$NICK"_src

FFmpeg output before it goes stuck

Splitting the commandline.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtmp://127.0.0.1:1935/show/EOKvvX9IgGJYjwa38zLeVUMEVBwHGq925pwVA52aJaIpqdOGI2'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
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 url rtmp://127.0.0.1:1935/show/EOKvvX9IgGJYjwa38zLeVUMEVBwHGq925pwVA52aJaIpqdOGI2.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: rtmp://127.0.0.1:1935/show/EOKvvX9IgGJYjwa38zLeVUMEVBwHGq925pwVA52aJaIpqdOGI2.
[rtmp @ 0x56351812d140] No default whitelist set
[tcp @ 0x56351812d740] No default whitelist set
[rtmp @ 0x56351812d140] Handshaking...
[rtmp @ 0x56351812d140] Type answer 3
[rtmp @ 0x56351812d140] Server version 13.14.10.13
[rtmp @ 0x56351812d140] Proto = rtmp, path = /show/EOKvvX9IgGJYjwa38zLeVUMEVBwHGq925pwVA52aJaIpqdOGI2, app = show, fname = EOKvvX9IgGJYjwa38zLeVUMEVBwHGq925pwVA52aJaIpqdOGI2
[rtmp @ 0x56351812d140] Server bandwidth = 5000000
[rtmp @ 0x56351812d140] Client bandwidth = 5000000
[rtmp @ 0x56351812d140] New incoming chunk size = 4000
[rtmp @ 0x56351812d140] Creating stream...
[rtmp @ 0x56351812d140] Sending play command for 'EOKvvX9IgGJYjwa38zLeVUMEVBwHGq925pwVA52aJaIpqdOGI2'

Nginx receive play command, because I can find it in access log.

Situation is same with this very simple command that should ends with error there is needed atleast one output.

ffmpeg -i rtmp://127.0.0.1:1935/$1/$STREAM_KEY

When I kill ffmepg with CTRL+C I get Input/Output error.

There shouldn't be any problem with RTMP stream, because it plays normally in VLC.

In my PC everything worked fine, but in server of my company I get this error.

the-papi avatar Jun 08 '17 06:06 the-papi

Solved. Problem was with nginx 1.12.0, 1.10.3 is ok.

the-papi avatar Jun 09 '17 19:06 the-papi

@PapiCZ If you still monitor this thread, I have the same issues you had, but unfortunately going to nginx 1.10.3 did not fix it. Would you care to give your ffmpeg build version ? I am wondering if this has to do with ffmpeg or nginx or rtmp module. an exec to ffmpeg is simply unusable as a result, extremely frustrating ...

pkviet avatar Oct 09 '17 15:10 pkviet

Here is output of ffmpeg -version

ffmpeg version 3.2.5-1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18) 20170516
configuration: --prefix=/usr --extra-version=1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil      55. 34.101 / 55. 34.101
libavcodec     57. 64.101 / 57. 64.101
libavformat    57. 56.101 / 57. 56.101
libavdevice    57.  1.100 / 57.  1.100
libavfilter     6. 65.100 /  6. 65.100
libavresample   3.  1.  0 /  3.  1.  0
libswscale      4.  2.100 /  4.  2.100
libswresample   2.  3.100 /  2.  3.100
libpostproc    54.  1.100 / 54.  1.100

I use it with nginx rtmp module 1.1.11.

the-papi avatar Oct 10 '17 09:10 the-papi

Thanks a lot. Figured out the reason of the errors: multi workers was on auto instead of 1.

pkviet avatar Oct 10 '17 11:10 pkviet

@pkviet Thanks! I had the same problem. ffmpeg would sometimes start and process the stream correctly but often it would just fail. Setting worker_processes to 1 fixed it.

milesegan avatar Jan 31 '18 02:01 milesegan

This issue disappeared when I compiled the module statically in nginx.

mischa85 avatar Feb 18 '21 00:02 mischa85

I am getting input/output error when I am using FFmpeg. Ngnix is working fine status come ok for NGINX and snapped code is below please help me out

./stream1.sh

ffmpeg -re -i sample.mp4 -vcodec copy -loop -1 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv rtmp:198.168.0.0/live/1234567890 ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36) configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.40.101 Duration: 00:45:30.48, start: 0.000000, bitrate: 525 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 391 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler

rtmp:198.168.0.0/live/1234567890: Input/output error

rahul1001knp avatar Mar 05 '21 15:03 rahul1001knp