I have been looking for information about this subject but none of the topics I have read deal with this issue.
I have configured my wifi cameras using generic camera integration and all of them are working fine, including audio.
In my automations I take a snapshot or a video which is stored in my media folder without any issue, problem is that those videos do not have audio. I have tried different media players and devices and it seems that there is no audio track in file generated (.mp4).
However, if I get these videos from webrtc and send them via telegram, audio is fine.
Same here. Audio also works on my onvif, go2rtc, offical and unoffical tp-link integrations, generic camera, you name it but no audio on recorded mp4 videos. It’s not that it’s silent, there is no audio in the file. Can’t find any information on this.
I finally solved! @franlmc@shane0802
With this shell command, the video output has audio in it.
You will need to paste the shell_command in your configuration.yaml, if you are beginner ask help from AI for your situation.
You need to create the folder if it doesn’t exists, otherwise ffmpeg command will fail. That’s why the code creates the folder first.
If you want to record more than 60 seconds you need to install long_shell_command from hacs because default shell command will timeout after 60 seconds. This one is 600 seconds.
I will share my setup which creates folders for each week for the year. ( 2025-06-26 )
And the file name is from an input text. Which you will see in my automation.
Only downside compared to camera.record is there seems no way for lookback feature. If you find a way, let me know.
Your message really made me happy. I tried to implement it in my setup, but… it didn’t work
Following your advice, I asked ChatGPT what the issue might be, and after lots of tests and technical explanations, we (well, it) came to this conclusion:
“Your Home Assistant setup (probably using Home Assistant OS or running in a Docker container) doesn’t have ffmpeg available in the environment where shell_commands run. That’s why any command trying to call ffmpeg from a shell_command will fail automatically — the system just can’t find it.”
So then I asked if there was any alternative way to get audio in my recordings, and it suggested pulling both, video and audio, directly from go2rtc instead of using camera.record.
The workaround was to create a new shell_command that fetches the stream straight from go2rtc, and right there it converts the audio to a more “universal” codec like AAC or FLAC. Here’s the command in case it helps someone else:
Just remember to change the folder path to wherever you want to save the file. And in my case, the 15 at the end means I’m recording 15 seconds of video.
Lastly, in your automation or script, instead of calling camera.record, just call shell_command.go2rtc_record_garaje.
Hope this helps someone out there — and huge thanks again @xertux for pointing me in the right direction to solve the issue!
This may or may not work for you, but I had the same issue as the OP where live audio worked in Home Assistant, but camera.record wouldn’t record it. I found that changing the audio codec in the camera from G711 to AAC worked.
Here is my new solution for camera record with sound and dynamic record duration. The code must be revised for your own use. Get help from AI if you are not sure what to do.
To get rid of long_shell_command extension we now create the folder that will contain the video beforehand.Fixed 1 minute record was timing out the shell command module that’s why we were using long_shell_command but with this build, the code gets the job done immediately and ffmpeg works in background.
These are shell_commands that will be put into the configuration.yaml
Bonus. This command will trim your video from the end. It’s usefull if your movement sensor has delayed clear duration. For me it’s sonoff snzb-03 which sends cleared after 1 min. of no motion. last 1 minute of my videos were always empty but no more.