MrBrax / LiveStreamDVR

An automatic livestream recorder
MIT License
331 stars 25 forks source link

Audio out of sync (and slowed down) from video #8

Closed bondurantdt closed 3 years ago

bondurantdt commented 3 years ago

All my vods from the live recordings have this issue where the audio is slowed down and out of sync with the video. Example: https://dan.dijonbooj.com/vods/DansGaming_2020-11-01T17_04_40Z_39632748797.mp4

FFmpeg | /usr/bin/ffmpeg | ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers Mediainfo | /usr/bin/mediainfo | MediaInfoLib - v19.09 Twitch chat downloader | /var/www/.local/bin/tcd | Twitch Chat Downloader 3.2.1 Streamlink | /var/www/.local/bin/streamlink | streamlink 1.7.0 youtube-dl | /var/www/.local/bin/youtube-dl | 2020.11.01.1 Pipenv | /var/www/.local/bin/pipenv | pipenv, version 2020.8.13, not enabled. TwitchDownloaderCLI | /usr/bin/TwitchDownloaderCLI | TwitchDownloaderCLI 1.0.0 Python3 version: Python 3.8.5 PHP version: 7.4.3 PHP User: wwadmin PHP PID: 910 PHP UID: 1000 PHP GID: 1000 Platform: Linux

Any thoughts? Thanks!

MrBrax commented 3 years ago

That video you linked looks fine to me, is your system ok? Tried a different video player?

bondurantdt commented 3 years ago

Chrome/Firefox playback both have the same issue. Downloading the file and playing out in VLC seems to be more in-sync but has audio cutouts. This only occurs when recording live, grabbing the vod does not produce the same result.

I'll try a completely separate computer to rule it out, but I do not have this issue with any other media.

MrBrax commented 3 years ago

It's a bit strange, when i seek in the file the first time, it seems to desync for a second, but if i continue seeking, it fixes itself. Not sure what could be the cause of that

MrBrax commented 3 years ago

I've added a setting for forcing some kind of sync on the remuxing to mp4. Untested.

bondurantdt commented 3 years ago

Thanks, I'll take a look at that, also going to experiment with a newer stable ffmpeg compared to what Ubuntu's apt repo has.

MrBrax commented 3 years ago

Try downloading/playing the ts file while it's capturing and check if that one is desynced too

bondurantdt commented 3 years ago

Still having the issue with the mp4 file, here is a new one: https://dan.dijonbooj.com/vods/DansGaming_2020-11-05T21_22_15Z_39657664893.mp4

The TS file does not have that problem.

MrBrax commented 3 years ago

then i honestly don't know, there must be something with the ffmpeg arguments i'm using, i can't really find this anywhere else

bondurantdt commented 3 years ago

Inspecting the TS file, there are a few corrupt packets in the stream. Not sure that this would be the cause of FFmpeg or video players to have issues when MPEG-ts is copied to an mp4 container, but allowing FFmpeg to process the audio stream versus just copying it seems to fix it. The process takes a little longer but is still quite fast since only audio is being processed. The command I am using is ffmpeg -i .ts -c:v copy -c:a aac output.mp4.

MrBrax commented 3 years ago

Not a bad idea, just not perfect for 1:1 archival. I'll add an option for it.

MrBrax commented 3 years ago

I got an extremely bad case of audio desync and stuttering the past two days, i pushed an option to test yet another fix. ebaa3e3