keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.6k stars 226 forks source link

RTSP audio crackle #177

Closed dick1980 closed 2 years ago

dick1980 commented 2 years ago

Describe the bug When viewing a camera (both live and recorded feed) the audio is crackling. Crackling is relative to the amount of sound an volume: more and louder sound equals more and louder crackling.

To Reproduce

  1. Open camera feed in Protect app
  2. Enable sound and raise volume
  3. View live feed or recorded feed

Expected behavior Clear sound - when viewing the RTSP feed directly in VLC player, no such crackling occurs. According to ffprobe output, video (h264) and audio (aac) should be compatible.

Screenshots N/A

Camera (please complete the following information):

Additional context Proxy = docker container running on an Raspberry Pi 4B+ 8GB, 256GB SD (Samsung EVO plus)

ffprobe output: Input #0, rtsp, from 'rtsp://admin:PASSWD@192.168.30.195/H.264': Metadata: title : Media Presentation Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 14.99 fps, 14.99 tbr, 90k tbn, 180k tbc Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp

docker-compose config: `version: "3" services: slaapkamer_espen: restart: unless-stopped image: keshavdv/unifi-cam-proxy:sha-daa705f5 volumes:

No suspicious errors in the container log, just plain sailing.

keshavdv commented 2 years ago

Does re-encoding the audio get rid of the crackle (i.e. with -ar 32000 -ac 1 -codec:a aac -b:a 32k)

dick1980 commented 2 years ago

Does re-encoding the audio get rid of the crackle (i.e. with -ar 32000 -ac 1 -codec:a aac -b:a 32k)

No, re-encoding with these parameters fully removes the audio.

dick1980 commented 2 years ago

Update. I've changed the RTSP string to contain the following: --ffmpeg-args='-c:v copy -bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 1 -codec:a aac -b:a 32k'

That seems to have fixed all for the Protect web interface. So here's where I stand.

Now working:

Not working:

This situation is somewhat okay (ish), as from a security point of view my recorded video and sound are intact and viewable. But it's a pity to be unable to view this in the Protect app. Any and all suggestions are welcome!!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.