I use ffmpeg + nginx/rtmp to restream video from ip cam to web page. The command I use is:
ffmpeg -rtsp_transport tcp -use_wallclock_as_timestamps 1 -i rtsp://admin:[email protected]/ -f flv -c:v copy -c:a copy rtmp://hls.mydomain.com/show/120
Then I use this URL to watch it in chrome:
http://hls.mydomain.com:8080/hls/120.m3u8
The problem is that the video in chrome is very choppy and can barely last only a few minutes before it stops.
On the re-streming server, I saw that ffmpeg quit automatically, without any error output:
ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, rtsp, from 'rtsp://admin:[email protected]/':
Metadata:
title : SDP Descrption
comment : SDP Description
Duration: N/A, start: 1604569309.322911, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp
Output #0, flv, to 'rtmp://hls.mydomain.com/show/120':
Metadata:
title : SDP Descrption
comment : SDP Description
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (Baseline) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 1k tbn, 90k tbc
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, mono, fltp
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[rtsp @ 0x5559c1d26940] CSeq 6 expected, 0 received.0:16.73 bitrate=2725.1kbits/s speed= 1.1x
[rtsp @ 0x5559c1d26940] CSeq 6 expected, 0 received.0:21.50 bitrate=2447.1kbits/s speed=1.08x
Last message repeated 1 times
[rtsp @ 0x5559c1d26940] CSeq 6 expected, 0 received.0:35.10 bitrate=2191.8kbits/s speed=1.05x
Last message repeated 1 times
[rtsp @ 0x5559c1d26940] CSeq 6 expected, 0 received.0:39.04 bitrate=2180.5kbits/s speed=1.04x
Last message repeated 2 times
[flv @ 0x5559c1d30440] Failed to update header with correct duration.406.8kbits/s speed=1.03x
[flv @ 0x5559c1d30440] Failed to update header with correct filesize.
frame= 1009 fps= 17 q=-1.0 Lsize= 17912kB time=00:01:00.28 bitrate=2434.0kbits/s speed=1.02x
video:17401kB audio:459kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.288416%
I confirmed that the exit code of ffmpeg is 0. Streaming and serving are on two standalone Debian Linux server.
Any help is greatly appreciated. Also, I would like to know the command like arguments to re-stream H265 video. TIA.