[FFmpeg-user] Audio/video stream are out of sync?
zou.christina at gmail.com
Thu Feb 9 08:02:06 EET 2017
I've made some progress thanks to advice from the IRC channel. I increased
my pipe max buffer size as high as I could:
I also lowered my video resolution and bitrate.
Now, with the below command I've managed 3 minutes of fully synced
audio/video livestream to Youtube from my Pi Zero. At the 3 minute mark,
there's a slight desync, and the audio goes about 0.5s ahead of the video.
That's my next question. I don't mind if there's a stutter every 3 minutes,
but I need the A/V sync to recover after that. So if I lose a few audio
frames, I need the video to catch up (or audio to slow down). Any
suggestions about how to do this (either ffmpeg param, or script)?
Here's my current command:
*sudo rm temp_audio.v*
*sudo rm temp_video.h264*
*arecord -Dmic_sv -c2 -r48000 -fS32_LE -twav temp_audio.v & \*
*raspivid *-w *640* -h *480** -fps 10 -v -b 1000000 -o temp_video.h264 -t 0
* -framerate 10 \*
* -i temp_video.h264 \*
* -i temp_audio.v \*
* -ab 24k \*
* -c:v copy \*
* -c:a aac \*
* -report \*
* -f flv **rtmp://188.8.131.52/live2/KEY*
On Wed, Feb 8, 2017 at 3:50 PM, christina zou <zou.christina at gmail.com>
> I spent a lot of time trying to use ffmpeg alone (alsa/v4l2), but it
> produces extreme stuttering on the audio track. Using my approach of
> writing to named pipes and sending those into ffmpeg, I add a bit of
> latency but ensure that there's no loss of frames. This was the approach
> suggested to me by the ffmpeg IRC channel. I'm on a Pi Zero (single core),
> by the way.
> Is there any way to align the two input streams' timestamps, if they are
> both being read from named pipes?
> Here is my full console output: http://pastebin.com/phmiphaL
> On Wed, Feb 8, 2017 at 3:02 PM, Carl Eugen Hoyos <ceffmpeg at gmail.com>
>> 2017-02-08 22:57 GMT+01:00 christina zou <zou.christina at gmail.com>:
>> > *arecord -Dmic_sv -c2 -r48000 -fS32_LE -twav temp_audio.v & \*
>> (See below)
>> > *raspivid -fps 10 -v -b 3000000 -o temp_video.h264 -t 0 & \*
>> Is this not possible with ffmpeg alone?
>> > ~/special/ffmpeg/ffmpeg* \*
>> > * -framerate 10 \*
>> > * -re \*
>> > * -i temp_video.h264 \*
>> > * -i temp_audio.v \*
>> (Complete, uncut console output missing.)
>> How are these two input streams supposed to be synced?
>> Normally, you would use (for example) alsa and v4l2 input
>> and hope that the two drivers both provide wallclock timestamps.
>> Carl Eugen
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> To unsubscribe, visit link above, or email
>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user