[FFmpeg-user] audio / video out of sync after recording rtmp stream

Frans Gouverne fransgnl at gmail.com
Sat Apr 13 12:33:37 EEST 2019


Have some troubles with syncing audio with video after record a live RTMP

ffmpeg -y -i "rtmp:/domein/client/name live=1" -vcodec copy -acodec copy -f

When looking at the first frames of ouput.flv using ffprobe, it starts with
about 30 audio frames. Then, after e.g. half a second, the first video
frame do show up. This is expected because I suppose ffmpeg has to wait for
the first key frame of the video.

So the record has approx. 30 audio frames for about half a second, after
this the video and audio frames do show up repeatedly.

Now when I convert the flv file to mp4 and run the mp4 file in a player,
players like Windows Media Player do play the video half a second later
compared to the audio, so audio is completely out of sync. (VLC player does
play it right by the way).

I could correct it with a video editor (shifting the audio track with half
a second), then it plays correctly in both Windows Media Player as well as
VLC player. But of course I would like to have a correct version right away.

Is there any way I can tell ffmpeg to start recording the audio channel
only after the first video keyframe is received?

Or can ffmpeg add time stamps explicitly (starting with 00:00:00.000) to
both audio and video frames channels when starting recording the RTMP

Or, after the fact, is there a way to remove the first set of audio frames
(from the flv or mp4 file) before the first video frame shows up without
converting the complete file again?

Have attached the log file of ffprobe, the first video frame shows up at
line 457.

Any hints are much appreciated,
best regards,
Frans (Netherlands)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logflv.log
Type: application/octet-stream
Size: 20533 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20190413/e609bea6/attachment.obj>

More information about the ffmpeg-user mailing list