Pi Zero 2 W + ov5647 for streaming

I’m trying to stream from a Raspberry Pi Zero 2 W using the ov5647 camera and a usb microphone (lavalier).

I can get both streams running independently but I’m running into issues combining them because of timestamp issues.

I’m currently using ffmpeg but I have gstreamer installed too (although I haven’t really touched it yet).

Currently I’m recording using rpicam-vid and piping it directly into ffmpeg and then trying to have ffmpeg combine everything. If my understanding is correct, rpicam-vid does not include timestamps on h264 recordings so ffmpeg can’t combine the audio from my usb microphone. I’m trying to test by recording to a file and then watching it back. I can see the audio, but there’s no video.

rpicam-vid -t 0 -o - | ffmpeg -f alsa -ac 1 -ar 44100 -i plughw:0,0 -f h264 -i - -c:v copy -c:a aac test.mp4

I want to try to avoid reencoding things as much as possible since there’s not a lot of compute power on the raspberry pi zero. I’ve tried adding timestamps in ffmpeg with -flags +genpts (this wasn’t successful). I also tried using wallclock for timestamps (also didn’t yield results).

Any ideas on how I might be able to do this? I feel like I’m missing something here.

Don’t know about combining audio and video but in my CCTV project I could never getting time stamping to work consistently. I also found that to get the Zero 2 W to work reliably I had to run at 720p, 1 FPS due to lag and over heating.

Hi Tommy
Good luck with synchronising audio with video.
There is a good reason why professional film makers use those Clapper boards. They can get a visual spike on the audio waveform to align with the exact time the 2 boards “clap” together. That worked well with optical film but I am not sure how it is done in this digital age. Probably with a processor with a lot more grunt than a Pi Zero.
Cheers Bob