1

I need to cast a stream from a USB camera via RTSP as stable as possible (at any moment i need to be able to get a static picture on a remote host, reflecting the real state of affairs in front of the camera) and economically on the used resources (the hardware is very weak).

Trying to write mjpeg to rtsp only displays green screen

Camera information:

[dshow @ 000001e6a938b880] DirectShow video device options (from video devices)
[dshow @ 000001e6a938b880]   vcodec=mjpeg  min s=1280x720 fps=30 max s=1280x720 fps=30
[dshow @ 000001e6a938b880]   vcodec=mjpeg  min s=640x360 fps=30 max s=640x360 fps=30
[dshow @ 000001e6a938b880]   vcodec=mjpeg  min s=640x480 fps=30 max s=640x480 fps=30
[dshow @ 000001e6a938b880]   vcodec=mjpeg  min s=848x480 fps=30 max s=848x480 fps=30
[dshow @ 000001e6a938b880]   vcodec=mjpeg  min s=960x540 fps=30 max s=960x540 fps=30
[dshow @ 000001e6a938b880]   pixel_format=yuyv422  min s=160x120 fps=30 max s=160x120 fps=30
[dshow @ 000001e6a938b880]   pixel_format=yuyv422  min s=320x180 fps=30 max s=320x180 fps=30
[dshow @ 000001e6a938b880]   pixel_format=yuyv422  min s=320x240 fps=30 max s=320x240 fps=30
[dshow @ 000001e6a938b880]   pixel_format=yuyv422  min s=424x240 fps=30 max s=424x240 fps=30
[dshow @ 000001e6a938b880]   pixel_format=yuyv422  min s=640x360 fps=30 max s=640x360 fps=30
[dshow @ 000001e6a938b880]   pixel_format=yuyv422  min s=640x480 fps=30 max s=640x480 fps=30

Mediamtx output output:

ffmpeg version 6.1.1-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, dshow, from 'video=Integrated Webcam':
  Duration: N/A, start: 152089.739306, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 30 fps, 30 tbr, 10000k tbn
2024/06/28 14:58:55 INF [RTSP] [conn [::1]:36681] opened
2024/06/28 14:58:55 INF [RTSP] [session f3037426] created by [::1]:36681
2024/06/28 14:58:55 INF [RTSP] [session f3037426] is publishing to path 'camera01', 1 track (M-JPEG)
Output #0, rtsp, to 'rtsp://localhost:8554/camera01':
  Metadata:
    encoder         : Lavf60.16.100
  Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, q=2-31, 30 fps, 30 tbr, 90k tbn
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
2024/06/28 14:59:00 INF [RTSP] [conn 127.0.0.1:36683] opened=N/A
2024/06/28 14:59:00 INF [RTSP] [session 0462ceb2] created by 127.0.0.1:36683
2024/06/28 14:59:00 INF [RTSP] [session 0462ceb2] is reading from path 'camera01', with UDP, 1 track (M-JPEG)

runOnInit in mediamtx.yml:

FFmpeg -hwaccel_output_format qsv -fflags nobuffer -f dshow -vcodec mjpeg_qsv -s 640x480 -i video="Integrated Webcam" -vcodec copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH

Thank you for your help

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.