I am trying to stream low-quality audio & video from my Raspberry Pi to another device. I have a Raspberry Pi camera & a USB microphone. Both devices work separately but i cannot seem to get the audio & video to sync up.
I am running Raspbian. I began by compiling ffmpeg as described at http://blog.giuseppeurso.net/raspberry-pi-streaming-webcam/.
Here is my ffmpeg info:
ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers built on Oct 27 2014 00:14:25 with gcc 4.6 (Debian 4.6.3-14+rpi1) configuration: --enable-filter=movie --enable-filter=aresample --enable-avfilter
Before i get streaming working, i want to just dump the audio & video to an MKV file. I wrote this script to dump audio & video to out.mkv until terminated.
#!/bin/bash vpipe=/tmp/videopipe apipe=/tmp/audiopipe vw=320 vh=240 fps=15 trap "rm -r $vpipe" EXIT trap "rm -r $apipe" EXIT if [[ ! -p $vpipe ]]; then mkfifo $vpipe fi if [[ ! -p $apipe ]]; then mkfifo $apipe fi raspivid -t 0 -w $vw -h $vh -fps $fps -o - > $vpipe & arecord -D plughw:1,0 -r 16000 > $apipe & ffmpeg \ -y \ -fflags nobuffer \ -r $fps \ -i $vpipe \ -fflags nobuffer \ -analyzeduration 0 \ -i $apipe \ -map 0:0 \ -map 1:0 \ -filter:a aresample=async=1 \ -c:a copy \ -c:v copy \ out.mkv
The audio & video are grossly out of sync. I have tried changing the framerates on both raspivid & ffmpeg with no success. Not sure what piece of the puzzle i am missing.