DeadEnded / MotionEyeAudio

Script to add Audio to MotionEye recordings
66 stars 26 forks source link

ffmpeg couldn't access rtsp audio when the video recording is on #15

Open upsangel opened 9 months ago

upsangel commented 9 months ago

After reading several issues discussion also the lengthy debug in https://community.home-assistant.io/t/adding-audio-to-motioneye-recordings/198438/8 , I finally figured out why the script is not working on my setup:

"Official" motioneye docker install on arm64 pi board (orange pi 3b)

Turned off Camera1 in motionEye Video Device settings, get the container shell and can successfully try ffmpeg -y -i "rtsp://admin:password@192.168.1.200:554/" -c:a copy test.wav the wav file can be played smoothly

Turned on Camera1, video recording is turned on. Run the same ffmpeg command in the shell but get: rtsp://admin:password@192.168.1.200:554/: Operation not permitted

I don't know why I counldn't get ffmpeg to stream the rtsp at the same time of video recording. Is it a limitation from ffmpeg? from container's network? from the IP-CAM which doesn't allow two connections from the same IP?

Running out of ideas to move forward... Any insight is much appreciated. Thanks!

DeadEnded commented 9 months ago

Sounds like you might have found the cause. It sounds like your camera can only support one stream at a time. I would look up your camera model and confirm it - but that does sound like your answer.

There are probably ways around it - but I moved on. Agent DVR was one thing I ran for a bit that supported audio - you might give that a try instead.

DeadEnd

upsangel commented 9 months ago

Thank you for your reply. Yes you are right, it's the limitation from the IP-CAM, if I hard code the stream url to be it's sub-stream, then the acc can be recorded. But I still find the aac doesn't merge to the mp4 properly. I commented out the remove aac line, the aac can be played fine. But the ffmpeg doesn't combine it to the mp4 correctly. Need more time to investigate why.

Sure! Let me check out the Agent DVR, seems that it can save lots of debugging time.

I found Frigate and Synology NVR can record audio correctly, but the former one needs lots of computing power (too demanding on a pi board), the later one is not free (as least legally speaking).

DeadEnded commented 9 months ago

Frigate is what I use - and if you don't need/plan on using object detection it's overkill and probably not worth setting up. It's awesome - but if you don't need object detection there are simpler solutions. Agent DVR worked well for me to capture video+audio and even (if I remember correctly) had multiple integration options (mqtt, etc.) without needing the paid tier.

If I hadn't gone to Frigate, I would have stayed on Agent DVR until something else new and shiny came up. Again, it's been a long time since I've looked at what's available... could be some new thing I never tested that's even better/easier.

DeadEnd