-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long-term sync issues between audio and video in %ffmpeg #1091
Comments
Why aren't you using output.youtube.live? |
|
@dhannyz I've just added It seems that I can reproduce the freeze sometimes, will investigate next. |
@toots great stuff, still need clarification on how output resolution is configured. Am also looking at the ffmpeg.filter stuff, looks great. One question I have is for filters like @Allavaz short answer is I'm doing some pretty complex stuff currently with output.external and af fmpeg command that generates a visualizer and streams to many endpoints. Future ideas are even more complex |
Small remark: should we change the default implementation of |
@toots thanks for those changes. does definitely seem more stable. Liquidsoap has stopped crashing, and I can CTRL+C out of it without fail (yet) However im having a major issue with huge A/V desync. audio seems to be upward of 5 to 10 seconds ahead of video. I've been eliminating sections of the script that I thought may be the cause, like muxing default stock videos with audio and rotating between that and real video files. However I now have only a pure video playlist and still have the extremely large desync. I also had youtube complain about the keyframe interval (which might be a cause of the desyncs?) there doesn't seem to be a way to set this. For example there is no The general g=GOPSIZE argument seemed not to do anything |
Thanks for the feedback again. I have just added a change that makes sure the encoded audio stream has a pts set just like video, that could explain the temporal drift. Would you mind testing again? Have you tried setting those options using the
As for the filters with dynamic input or output such as |
I don't know how many times I've reported A/V sync issues. In the past 5 years I've never cracked it. The only way to not have A/V sync issues it to use the built in theora/vorbis codec. Not even sure that works anymore. The one consistent thing I have found is that all the source files must have the same frame rate. Mixing 24fps and 30fps will immediately cause A/V sync issues on the transition from one source to another. I can't find my old configurations, from what I can remember I had to use +igndts and +genpts. There's also on the audio side first_pts=0. Dropped and Duplicating frames can also cause sync issues as well. Setting the GOP and keyint is critical for DASH/HLS and must be a multiple of the frame rate. Not some random number. If your output is 25fps and you want GOP every 6 seconds the GOP and keyint should be 150. I would make sure that the actual internal raw AVI video is synchronized or not. Dump the raw output and see if it is de-synchronized or not. If it is, this is an uphill battle which you won't ever win. I suspect this is the ultimate problem. There's just been something inherently wrong with the internal AVI generation for years. And of course as I said, all of this never worked properly so I ended up giving up. I give it a try about once a year. What does work properly is jb-alvarado's ffplayout, which is essentially a python script that creates a continuous mpegts using piping methods and several instances of ffmpeg. I believe I did create a possible working scenario using LS and GStreamer output using mpegts via UDP. Again, can't stress this enough, all source material cannot change fps. Welcome to hell. |
@autonarcosis, this issue is about the internal ffmpeg encoder. A lot of the trouble you're describing should go away once this encoder is stable. Any chance you could try it yourself as well? |
@toots No Solution Is Found .... |
@autonarcosis Wanna open another issue describing how you installed and what your issue/error logs are? Happy to look at it.. |
@toots
|
@autonarcosis It looks like you are still using the external ffmpeg encoder. The doc for the internal @dhannyz and other people interested in this encoder: I just pushed some changes to the syntax, now it looks like: %ffmpeg(format=<format>,
# Audio section
%audio(codec=<codec>,<option_name>=<option_value>,..),
# Video section
%video(codec=<codec>,<option_name>=<option_value>,..),
# Generic options
<option_name>=<option_value>,..) Example: %ffmpeg(format="mpegts",
%audio(codec="ac3",channel_coupling=0),
%video(codec="libx264",b="2600k",preset="ultrafast")) That seems much more clean and logical to me.. |
@toots yes that makes a lot more sense now. Unfortunately I'm still getting extremely bad issues with sync, it looks like maybe liquidsoap is reading video in too fast if the framerates are different. eg: source file at 25fps and liquidsoap internally at 30fps On another note i seem to be having issues with some unicode characters when drawing text. I know the font supports the characters. At the moment I am testing by writing the metadata to a file that my external ffmpeg reads via the drawtext filter (I tried using the EDIT: Have just set a bunch of videos to all the same fps and matched with the liquidsoap internal setting - sync seems better so far, will leave it on a while to test |
In my testing I found that the source files must match the video FPS and the audio sample rate. For example if Liquidsoap is configured for 25fps and 44.1khz audio, the source files must be that. Frame rate mismatches is immediate on track change. Audio sample rate takes time. My source files were 48khz and I was getting consistent gap errors of about 200 microseconds when Liquidsoap was configured for 44.1khz. Nearly imperceptible unless you are highly familiar with the source material. This would give the slight perception that the first few tracks seemed OK, but over hours that sync expands. After about 6 hours the de-sync is at about 4 seconds. Obviously noticeable. Once I changed Liquidsoap to 48khz to match my source files, there were no more gap errors and the stream maintained sync. |
Thanks that's very interesting. We're suppose to convert frame rate for video so I'll double check on that. Also, we've historically been doing |
@autonarcosis Are those testing info based on using the latest ffmpeg builtin encoder? And what decoder are you using for your input files? |
Thanks! I'm gonna try to reproduce the issue next. |
@toots Just from what i know about ffmpeg I've had the same issue when setting |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue was closed for lack of activity. If you believe that it is still relevant, please confirm that it applies to the latest released version of liquidsoap and re-open the ticket. Thanks! |
@toots
The stream comes up, plays ok, but a little glitchy, and then sometimes liquidsoap crashes with
The output section of my script is as follows
You can see I tried adding a buffer to smooth things out a bit
Without the buffer it seems sometimes it doesnt connect at all and hangs.
Also some questions about missing ffmpeg settings. there does not seem to be an -r=30 (framerate) equivalent, however i assumed setting
set("frame.video.samplerate",30)
may account for this?also -bsf (bitstream filter) and -pix_fmt seem to be missing?
Also it seems the resolution defined in the liquidsoap set() frame options is not preserved through the ffmpeg encoder, how should this be defined?
Also having some issues where the process hangs when trying to end it, and I'm forced to SIGKILL it
The text was updated successfully, but these errors were encountered: