I'm trying to use ffmpeg in order to transcode RTSP stream from CCTV to HLS stream so it could be accessed through a web server.
ffmpeg used to stream video from CCTV with following command
$ ffmpeg -i "rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0" -hls_time 3 -hls_wrap 10 -f mpegts udp://localhost:6601
ffmpeg version 4.2.8 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[rtsp @ 0x5576c7340600] getaddrinfo(cam-1.loc): Name or service not known
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0':
Metadata:
title : RTSP Session
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
Stream #0:1 -> #0:1 (pcm_alaw (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://localhost:6601':
Metadata:
title : RTSP Session
encoder : Lavf58.29.100
Stream #0:0: Video: mpeg2video (Main), yuv420p, 1920x1080, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc
Metadata:
encoder : Lavc58.54.100 mpeg2video
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp2, 16000 Hz, mono, s16, 160 kb/s
Metadata:
encoder : Lavc58.54.100 mp2
[rtsp @ 0x5576c7340600] max delay reached. need to consume packette=5338.9kbits/s dup=0 drop=5 speed=1.12x
[rtsp @ 0x5576c7340600] RTP: missed 3 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 4 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[h264 @ 0x5576c7993c80] concealing 972 DC, 972 AC, 972 MV errors in I frame
rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0: corrupt decoded frame in stream 0=1.11x
[rtsp @ 0x5576c7340600] max delay reached. need to consume packette=5298.4kbits/s dup=0 drop=5 speed=1.02x
[rtsp @ 0x5576c7340600] RTP: missed 2 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 4 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 3 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 4 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 2 packets
[h264 @ 0x5576c779b9c0] cabac decode of qscale diff failed at 66 60
[h264 @ 0x5576c779b9c0] error while decoding MB 66 60, bytestream 9825
[h264 @ 0x5576c779b9c0] concealing 943 DC, 943 AC, 943 MV errors in I frame
rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0: corrupt decoded frame in stream 0=1.02x
frame= 1315 fps= 25 q=31.0 Lsize= 34249kB time=00:00:53.32 bitrate=5261.8kbits/s dup=0 drop=5 speed=1.02x
video:30544kB audio:1042kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.431973%
nmap used to check if 6601 port is open
$ nmap -Pn localhost -p 6601
Starting Nmap 7.70 ( https://nmap.org ) at 2023-12-26 10:47 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0011s latency).
Other addresses for localhost (not scanned): ::1
PORT STATE SERVICE
6601/tcp closed mstmg-sstp
Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
However, ffplayer able to play video stream
ffplay udp://localhost:6601
ffplay version 4.2.8 Copyright (c) 2003-2022 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mpeg2video @ 0x7f1ad854afc0] Invalid frame dimensions 0x0. f=0/0
Last message repeated 7 times
Input #0, mpegts, from 'udp://localhost:6601':0KB sq= 0B f=0/0
Duration: N/A, start: 59.288000, bitrate: N/A
Program 1
Metadata:
service_name : RTSP Session
service_provider: FFmpeg
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x101]: Audio: mp2 ([4][0][0][0] / 0x0004), 16000 Hz, mono, s16p, 160 kb/s
VLC cannot play the video stream:
vlc udp://localhost:6601
VLC media player 3.0.18 Vetinari (revision )
[000055769aa81ba0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[00007fec64011e90] mjpeg demux error: cannot peek
ffprobe output
ffprobe udp://localhost:6601
ffprobe version 4.2.8 Copyright (c) 2007-2022 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mpeg2video @ 0x55e1be0910c0] Invalid frame dimensions 0x0.
Last message repeated 9 times
Input #0, mpegts, from 'udp://localhost:6601':
Duration: N/A, start: 262.760000, bitrate: N/A
Program 1
Metadata:
service_name : RTSP Session
service_provider: FFmpeg
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x101]: Audio: mp2 ([4][0][0][0] / 0x0004), 16000 Hz, mono, s16p, 160 kb/s
Why the video stream is not playing in VLC?
Why nmap do not see that UPD port is open?