[FFmpeg-trac] #8647(ffmpeg:new): nginx rtmp via ffmpeg to hls output buffering issues
FFmpeg
trac at avcodec.org
Fri May 1 10:51:55 EEST 2020
#8647: nginx rtmp via ffmpeg to hls output buffering issues
--------------------------------+-------------------------------------
Reporter: lukea | Type: defect
Status: new | Priority: important
Component: ffmpeg | Version: 4.2
Keywords: hls | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
--------------------------------+-------------------------------------
'''Summary of the bug:'''
Hi,
We have a kubernetes cluster which we are using to setup a streaming
service. The service uses the nginx-rtmp module behind a TCP load
balancer. The nginx-rtmp module runs an exec command which calls ffmpeg
(4.2.2 built from source with libfdk-aac enabled, full compile options are
below). The ffmpeg command then sends the output via `-f hls` (through an
nginx ingress which balances requests) to a second nginx instance (pod)
which allows the hls files to be played. We have observed a couple of
issues which we think are linked to ffmpeg (probably hls parts of it).
Firstly, we noticed that when the buffering happens although the hls
segments arrive bang on time as expected, the index file sometimes does
not - so the index is then unaware of the segment file, which appears to
cause the buffering until the index is re-sent with the next segment data.
Further to this we disabled the sending of files over http to the second
nginx instance and just started writing the segments locally - although
the problem took longer to appear, we still observed the same behaviour.
On the nginx ingress (which balances between the ffmpeg command and the
nginx pods that handle the segments) we also noticed a bunch of 499 error
codes (see attached image)
We are not certain if this is a config issue with our ffmpeg command, or a
bug with ffmpeg - most likely the hls component within, though we have cut
down the ffmpeg command somewhat to be more minimal to try and debug this.
Please let me know if you need any more debug output?
Thanks!
'''How to reproduce:'''
{{{
/opt/ffmpeg/bin/ffmpeg -i
rtmp://127.0.0.1/${APP_NAME}/${INPUT_STREAM_NAME} \
-map 0 \
-framerate 30 -g 30 -keyint_min 30 -force_key_frames
"expr:gte(t,n_forced*1)" -sc_threshold 0 -b_strategy 0 \
-c:v:0 libx264 -b:v:0 2000k -maxrate:v:0 2200k -bufsize:v:0 3000k
-s:v:0 1280x720 -aspect:v:0 16\:9 -profile:v:0 main -crf:v:0 25 \
-c:a libfdk_aac \
-b:a:0 320k -maxrate:a:0 480k -bufsize:a:0 320k \
-hls_time 2 \
-hls_list_size 30 \
-hls_segment_type fmp4 \
-hls_start_number_source datetime \
-var_stream_map "v:0,a:0,name:720p" \
-master_pl_name "master.m3u8" \
-master_pl_publish_rate 1 \
-hls_flags +program_date_time-temp_file \
-f hls -method PUT
${UPSTREAM_TS_CACHE}/${PUBLIC_STREAM_NAME}/index-%v.m3u8
}}}
'''ffmpeg compiled with:'''
{{{
./configure \
--disable-debug \
--disable-doc \
--disable-ffplay \
--enable-avfilter \
--enable-avresample \
--enable-gpl \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-librtmp \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-openssl \
--enable-pic \
--enable-postproc \
--enable-pthreads \
--enable-small \
--enable-version3 \
--extra-cflags="-I${PREFIX}/include" \
--extra-ldflags="-L${PREFIX}/lib" \
--extra-libs="-lpthread -lm" \
--prefix="${PREFIX}" && \
make && make install && make distclean
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8647>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list