I want to record both audio and video to my local using rpi zero. I've been struggling with this for a long time and at the end of the day there are 2 different problems that I can't solve for 2 different methods.
Using raspivid and ffmpeg. The script I use is as follows.
raspivid -t 0 -a 1024 -a "TEST" -a 12 -ae 32 -n -w 1280 -h 720 -fps 30 -b 2000000 -o - | ffmpeg -y -framerate 30 -i - -itsoffset 00:00:06.0 -f alsa -ar 16000 -i plughw:0 -c:a aac -c:v copy -map 0:0 -map 1:0 -fflags nobuffer test.mp4
Audio and video are not in sync here. Although I tried all the suggested ways when I searched, none of them worked for me. However, by using itsoffset
, I can catch the sync for a certain time at the beginning, but then the audio continues to get in front of the video.
- Using picam. Github link; https://github.com/iizukanao/picam
Here the sound and the picture are perfectly synchronized. Everything is great so far, thanks again iizukanao.
But, I record 1280x720p
30fps
while using picam, and when I watch console outputs or after video, I occasionally see small jumps or stuttering due to low fps.
Any suggestions on these 2 issues? Or any other method suggestions that I can use?