mpromonet / v4l2rtspserver

RTSP Server for V4L2 device capture supporting HEVC/H264/JPEG/VP8/VP9
The Unlicense
1.82k stars 423 forks source link

Insert audio over rtsp #276

Closed Tormund1985 closed 2 years ago

Tormund1985 commented 2 years ago

Describe the bug I can't add audio over rtsp connection.

To Reproduce ./v4l2rtspserver -W 1280 -H 720 -F 25 /dev/video0,hw:1,0 -A 48000 -a S32_LE -p 8555

Expected behavior The video works, I can play it from VLC, but not the audio coming from a microphone.

Screenshots

root@raspberrypi:/# arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@raspberrypi:/# 
root@raspberrypi:/# cat /proc/asound/card1/stream0
C-Media Electronics Inc. USB PnP Sound Device at usb-3f980000.usb-1.3, full spe : USB Audio

Capture:
  Status: Stop
  Interface 1
    Altset 1
    Format: S16_LE
    Channels: 1
    Endpoint: 2 IN (ADAPTIVE)
    Rates: 48000, 44100
    Bits: 16
    Channel map: MONO

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Audio works fine with ffmpeg command: ffmpeg -ar 44100 -ac 1 -f alsa -i plughw:1,0 -f wav -listen 1 tcp://0.0.0.0:5002

  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
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, alsa, from 'plughw:1,0':
  Duration: N/A, start: 1651745738.976498, bitrate: 768 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s

Of course libasound2-dev is present and ALSA found when I compile v4l2rtspserver

root@raspberrypi:/home/pi/v4l2rtspserver# cmake .
-- CMAKE_TOOLCHAIN_FILE=
-- CMAKE_C_COMPILER=/usr/bin/cc
-- CMAKE_CXX_COMPILER=/usr/bin/c++
OpenSSL_FOUND = TRUE
-- Could NOT find libliveMedia (missing: LIBLIVEMEDIA_LIBRARY LIBLIVEMEDIA_INCLUDE_DIR) 
-- Could NOT find libUsageEnvironment (missing: LIBUSAGEENVIRONMENT_LIBRARY LIBUSAGEENVIRONMENT_INCLUDE_DIR) 
-- Could NOT find libBasicUsageEnvironment (missing: LIBBASICUSAGEENVIRONMENT_LIBRARY LIBBASICUSAGEENVIRONMENT_INCLUDE_DIR) 
-- Could NOT find libgroupsock (missing: LIBGROUPSOCK_LIBRARY LIBGROUPSOCK_INCLUDE_DIR) 
ALSA_FOUND = TRUE
running git submodule update --init 2>&1
-- SystemD available
-- SystemD directory '/lib/systemd/system'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/v4l2rtspserver

I follow this issue from 2018:

mpromonet commented 2 years ago

Hi,

You may try -A48000 -C1 -aS16_LE that seems better correspond to your capture device.

Best regards Michel

Tormund1985 commented 2 years ago

HI Michel!

Now its working with next command:

.../dev/video0,hw:1,0 -A48000 -C1 -aS16_LE

I can't hear because I was trying to reproduce the rtsp "ts", but with unicast its working.

Thanks you very much, I really appreciate your help.