Adding Audio to MotionEye Recordings

Thanks for your help!

Now that I am getting sound it seems like the audio is consistently about 15 seconds ahead of the video. Is there a tweak or anything I can do to align them better or it that just how my board is processing them?

Yes you can adjust it.
I haven’t had to as mine are close enough you can barely tell (less thank 0.25 seconds I think). To shift the audio use the -itoffset flag. You have to put it on the input you want to shift.

So if you want to shift the video ahead 15 seconds I believe you would change the merge line from this:

ffmpeg -y -i ${file_path} -i ${file_path}.aac -c:v copy -c:a copy ${file_path}.temp.${extension};

to this:

ffmpeg -y -itsoffset 15 -i ${file_path} -i ${file_path}.aac -c:v copy -c:a copy ${file_path}.temp.${extension};

You might have to play with it to get it right… I have used it once recently and had to play with it… you put the -itsoffset in front of the input you want to offset I believe… and then it can be + or - if I remember correctly… I think it will cause a still image for the 15 seconds and then everything should be synced up… like I said - play with it - you might even move it to the second input (audio) and use a negative to shift the audio up instead of delaying video…

Find what works best for you.
Cheers!
DeadEnd

Thanks again! I’ll tinker with it.

@crider17 - just thought I would let you know. I figured out how to get back to using camera_id instead of camera_name and not have the audio feeds get screwed up.

… at least I think I did :wink:

Repo has been updated including a change int he variable order for the start and stop commands.
I left the camera_name stuff in the script but commented in case my fix is flawed - easy enough to go comment/uncomment and go back.

BUT I think I got it working so that now it pulls the correct config every time.

Cheers!
DeadEnd

Thanks! I’ll update it and check it out.

Sorry for the noob question here but I’m struggling to figure out where to drop the script in my configuration. I’m running hassio in docker with MotionEye installed as an addon. I’m not finding any of the paths mentioned in the readme or this thread. My camera-1.conf is in /usr/share/hassio/addons/data/a0d7b954_motioneye/motioneye

Is that where I need to put the script? If so, is that then also the path I need to use in the start/stop calls? My video files are saved on a network share if that matters. Thanks for the help.

Hmm… haven’t worked with Hassio before.
To be honest, you can put the file anywhere the MotionEye container can see.
As long as the path you put into the start/stop calls is the same as where you put it (pay attention to volume mapping as you need the CONTAINER path not the HOST path) then it will work.

I put in the instructions to put it in the same location because I think it is best to keep all the configuration files together.

So yes, I expect /usr/share/hassio/addons/data/a0d7b954_motioneye/motioneye is where you will want to put it. Check the container map though - changes are that this is the host path and the container path is something different (like /etc/motioneye).

DeadEnd

Here’s a clip of my configuration’s host and container paths:


I put the script in /usr/share/hassio/share/motioneye By default motioneye writes movies to the /share/motioneye dir so I assume that’s the addon’s container path. I’m using /share/motioneye for the start/stop calls However, even after I’ve given the script permissions it’s not writing any audio files. Am I missing a step?

Ideally you need to attach to the motioneye container and see where the files are from that perspective. I have never used HassIO so I really don’t know where the volumes map to… the image you shared is for the HA container I believe… I don’t see anything there for the motioneye container.

I took a look at the MotionEye Add-on github repo. Based on what I see there, it looks like the dockerfile copies in a motioneye.conf to /etc/motioneye. So I would expect that is where the config (and likely camera-#.conf) are from the container side. Try using /etc/motioneye/... in the start and stop and see if it works.

DeadEnd

That’s the thing, my configuration doesn’t have a separate container for motioneye. I have a very limited understanding of this side of things but because I’ve installed it as an add-on not a separate container my situation is a bit different. I’ll keep trying to sort through documentation and let you know if I find a solution.

HassIO (with supervisor) is a style of installation where it manages the containers for you.
Add-On’s are containers - its just that the supervisor manages them for you.
Every add-on you install is another container.

Try /etc/motioneye... in the start and stop commands and it should work. Unless I misread the dockerfile and git repo… which happens - I’m no expert.

That’s sort of what I assumed initially as well. However, my portainer instance only lists the following containers


It does list motioneye as an “image” as seen below.

I’ve tried that and tested it with a 60 second max movie length and there’s no audio.

Well, that confuses me more… unless you have more images/containers not in the screen shots.

The pics are from Portainer, but you have 2 Portainercontainers, and they are both stopped… so you must have a third instance of Portainer running?

The image list shows that NONE of them are being used - so you have the images, but no containers based on them…

Did you install any containers manually (outside of the add-on store)? Also, in your container list you don’t even have a MotionEye container… so from this screen shot its not even running…

My guess is you have installed some containers from the add-on store and some manually in docker? This is just a guess - and don’t feel discouraged if you are having trouble/getting confused. Everyone started with no knowledge of how this all works… it is a powerful system, but can sometimes be hard to wrap your head around.

So again, my thought is that you have both manually installed containers, and hassio “add-on” containers. Since I don’t use hassio I don’t know if it does “docker-in-docker” (meaning all the add-ons are actually containers within the hassio container) or not… I’ll see if I can find an answer to that…

DeadEnd

That’s all that shows up on the “containers” tab but I do have more “images” see below:

not that I recall but as you can tell I’m a novice with docker and mostly rely on installation guides and videos. I do seem to recall that I may have tried to install portainer as a separate container before I realized there was an add-on. I thought I had cleaned up that first installation but maybe that explains the stopped portainer containers.

I appreciate your patience. I enjoy learning about how the different pieces fit together. Sometimes I hit a dead end with documentation so it’s helpful to hear from someone with more of an understanding

So… this is what I see:

All the images that all start with homeassistant/ I expect are part of the HassIO installation… I thought there were only 2 (supervisor and HA) so I don’t know what audio, DNS, multicast, observer, etc. are for… would have to look it up.

All the images that start with hassaddon/ are from the add on store - this are what are installed and managed by the supervisor and HassIO installation.

The node.alpine, pihole, and portainer images look like ones you manually installed - and Portainer is in use, so I expect you are viewing through a manually installed Portainer container, not one from the add-on store.

The last two images I’m guessing are from some custom hassio repo someone made… I think the Add-On store allows that? Not sure - again, don’t use it :man_shrugging:.

So, you have a lot of extra images from trying to get things working… depending on how far along you are you could either start over, or start cleaning out all the stuff you aren’t using.

I expect the system won’t let you start the Portainer add-on because you have a manually installed instance of it using the port already. You’d need to remove (or at least stop) the manually installed one and then start the add-on version… maybe that would help, but I still don’t see motioneye being ran in a container… I’m not sure if you installed it outside of a container or what…

You might have to retrace your steps a bit… but at this point its a bit off topic from this forum post… if you’d like you can message me directly, and I can try and help get you straightened out… Good luck!

DeadEnd

sounds like i have some clean up to do. I’ll keep looking into it. thanks!

@joe_blow did you end up getting this working? I’m using HassIO too and would love to be able to get this audio script working

Joe_blow’s issue was his installation. If your installation of HA and addon’s are correct then you should be able to use the script. You just need to look at the mapped volumes and see where the configuration files are.

DeadEnd

@jokkydee let me know if you get it working. I haven’t put anymore time into it in a few weeks but would like to test the theory of an installation issue against what sounds like an identical hassio setup.

oaky so i tried installing this on hassio - container motioneye addon
i put the script in both /etc/motion/ and /etc/motioneye/ i enter the container commit it and when i reboot it disappears so i am thinking maybe the containers are rebuilt or something ?

note : /etc/motion is where the camera- conf files are so i figured it should probably actually go there