Adding Audio to MotionEye Recordings

Yes without the script I get the full video.

I’m running it with docker running under ubuntu server 20.04 with a Intel NUC8I3BEH2 (8GB RAM, SSD, Intel Core i3-8109U and 8GB of RAM)

hmm… I am testing different variations now (movie passthrough, mp4, mkv). So far I have noticed that if I use mkv format, my recordings have a still image of video (single frame). Not sure what would cause this…

I normally use movie passthrough as it can greatly reduce CPU load. If you are not re-encoding to a required codec, you can try turning this on and see if it resolves the issue. It would also be interesting as it would point to an issue with certain codec/containers…

1 Like

Thanks again!
I was using mp4 but I will try wit the movie passthrough setting.

Could you please tell us which settings for motion detection are the best? so it will be only recording when a moving objetct is detected?

Movie Passthrough will cause MotionEye to record from the source directly without re-encoding. I use this as it lowers CPU usage and I have no reason to re-encode. If you need to change something like adding overlay, changing formats, etc. then you don’t use movie passthrough - but I expect most users will prefer to use it.

As far as Motion Detection - I don’t use it. My camera’s handle this and HA has a binary sensor for each to know whey they see motion. So I have not setup any motion detection in MotionEye - it is only used for recording. You can probably search online to find a forum or blog with suggested settings. Heck you can probably even post a new topic on this forum and some users will have suggestions.

If you have a question about what a setting is, the first thing I would do it hover your mouse over the right side of the setting where you see the question mark (?). This will give a short explanation of what that setting does:

Cheers!
DeadEnd

1 Like

DeadEnd -

Thank you for doing this! I was dismayed to learn that MotionEyeOS does not include sound after I installed it last week. I read your readme file but am not clear on how to proceed. I’m a bit of a noob so please bear with me. The instructions says to copy the script to /etc/motioneye/ but I do not see a motioneye folder under /etc. I’m running MotionEyeOS on a RPi 4. No Docker.

Can you clarify? Thanks!

Can you check at /data/etc/ and see if the configuration files are there?
It looks like MotionEyeOS has a slightly different structure.
Once you confirm the location, I will update the readme with MotionEyeOS details.

Thanks,
DeadEnd

I think that is it. See below for the content of my /data/etc/ directory.

Yep that’s it.
I’ll update the readme with MotionEyeOS directory.

Thanks,
DeadEnd

Thanks!

I’m not able to get it to work. I verified that the two variables are defined in my camera-3.conf file. When I run ffmpeg against it as you suggested in a previous post it does create a test.wav file. See output attached. However, my videos are not producing any sound.

My motion log from MotionEyeOS event ends in:
/data/media/sda1/data/output/Driveway/2020-06-30/17-08-51.mp4.aac: No such file or directory
mv: can’t rename ‘/data/media/sda1/data/output/Driveway/2020-06-30/17-08-51.mp4.temp.mp4’: No such file or directory

Any ideas of what to check?

Thank you!

Can you check the log and see if there are any errors earlier?
That appears to be stating that the intermediary file was not created.
The Audio file does appear to be being created - you can check the /data/media/sda1/data/output/Driveway/2020-06-30 directory and see if you have audio files being generated. Normally they are deleted at the end of the script, but if the script is failing to complete, they might still be there. Either way the current recordings audio file should be present.

If the audio file is there - which it looks like it should be from the log output, then the next step is the merge into the temp file. That looks like it worked too since it says the error was moving. Not sure why it would fail to move unless one of the files was still being accessed/generated.

Lets see what you have in the directory - that might help understand where its having issues.

DeadEnd

There are no files in the directory other then the .mp4 and thumb pics. No audio files. I had my son walk out and trigger a motion while I watched the directory and I never seen any .wav files pop up unless it came and went too fast for me to see. Although it is finding a stream, it appears that no files are being generated. I’ve attached the entire ffmpeg log output. I don’t see any error until the very end.

Thanks.

I’m writing my video files out to a USB drive and not the internal SD Card if that would make a difference…

Okay, so it appears that neither of the files are being created.
The last two messages are that the AAC file and the temp file both don’t exist.
Both of these are part of the STOP process - so lets check if the START is working.

Check your /tmp directory and see if you have any files like /tmp/motion-audio-ffmpeg-camera-#.
This will helps us know if the start process is working.

Thanks for your reply. I do see those tmp files. See the attached directory listing.

Okay, for testing purpose it is helpful to change the recordings from motion triggered to continuous and have them set to 1 minute or something like that… this way we can keep checking things without having to have someone trigger the motion activation.

The next thing I would like you to check is the processes running (after you set it to continuous).
Run this after the recordings are running:

ps -ef

This will give a list of running processes - we should see an ffmpeg process running for the audio recording (and the PID should match what you see in the temp file for that camera). Lets see what the ps command shows (blank your user/password).

Thanks. See attached output. I ran the ps -ef command once I saw the mp4 pop up to confirm it was recording. I do not see an ffmpeg instance running unless I’m missing it. There is a lot there.

hmm… maybe there is a difference in MotionEyeOS vs MotionEye that is causing it to fail. In the MotionEye container there are less than a dozen processes running. SO - can you share your camera-1.conf (or whichever camera you are testing on) - there is a username password and IP’s that you can blank out before sharing.

I am wondering if possibly MotionEyeOS has different tags than the MotionEye Docker image… that might explain what it isn’t working.

Thanks for your help.

See attached conf file. Tried to just upload the txt file but do not see how. System requires a pic. I had to combine screenshots…hopefully readable.

Edit: uploaded a better pic.

Okay, that looks good… can you confirm the permissions on /data/etc/motioneye-audio.sh?
ls -la on the /data/etc/ directory should show it. Want to make sure it is readable and executable.

If that is setup correctly then I think it is failing to start the audio recording - well have to dig into that as it could be a camera specific issue - hard to tell until we dig.

Thanks. See attached output.