audio / video out of sync after recording rtmp stream

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

audio / video out of sync after recording rtmp stream

zwerfkat
Hi,

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

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

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.

*Questions*:
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
stream?

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)

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

logflv.log (27K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: audio / video out of sync after recording rtmp stream

Carl Eugen Hoyos-2
2019-04-13 11:33 GMT+02:00, Frans Gouverne <[hidden email]>:

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

Instead please use something like (untested):
$ ffmpeg -f data -i rtmp://... -c copy -f data -map 0 out.flv
if you cannot use mplayer -dumpstream or something equivalent.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: audio / video out of sync after recording rtmp stream

zwerfkat
okay, thanks, will try it out.

By the way, I also find this workaround myself: stripping off the first 4
seconds (corresponds to the keyframe interval) from the flv file using: -ss
00:00:04.000
As a result, the excessive audio frames are gone, have tested this with the
problematic record and it works as expected: audio and video are perfectly
in sync now!

Frans





Op za 13 apr. 2019 om 13:57 schreef Carl Eugen Hoyos <[hidden email]>:

> 2019-04-13 11:33 GMT+02:00, Frans Gouverne <[hidden email]>:
>
> > ffmpeg -y -i "rtmp:/domein/client/name live=1" -vcodec copy
> > -acodec copy -f ouput.flv
>
> Instead please use something like (untested):
> $ ffmpeg -f data -i rtmp://... -c copy -f data -map 0 out.flv
> if you cannot use mplayer -dumpstream or something equivalent.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".