-
Notifications
You must be signed in to change notification settings - Fork 105
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
Infinite Loop in GetAudio for certain files #423
Comments
Give the latest commit a try |
Still happens, unfortunately, at the same timestamp as it did before the rewrite. |
Guess I'll simply revert the last commit then. Great success! |
qyot27
pushed a commit
to qyot27/ffms2_cplugin
that referenced
this issue
Sep 29, 2023
…loop, hopefully fixes FFMS#423
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello - I was sent an audio file which makes FFMS2 lock up when reading the entire audio from start to finish.
Audio file
The file is here: https://www.dropbox.com/scl/fi/wljguppohkwgexiq50kqx/out.m4a?rlkey=lem4n70q5jqq5dgvkke9i8s79&dl=0
It seems like this file was produced by concatenating two audio files with ffmpeg, which definitely fits the analysis below.
Steps to reproduce
Open this audio file in FFMS2 and repeatedly call
FFMS_GetAudio
to read the audio from the beginning to the end. Eventually, FFMS2 will freeze. Specifically, this was reproduced in Aegisub, where opening that audio file (while having the Aegisub's Audio Cache Type set to either RAM or HDD) would work, but closing the file would make Aegisub freeze.Analysis
Debugging shows that the
GetAudio
function enters an infinite loop,ffms2/src/core/audiosource.cpp
Lines 381 to 434 in ef243ab
which is caused by the previous call to
DecodeNextBlock
gettingAVERROR(EAGAIN)
fromavcodec_receive_frame
.ffms2/src/core/audiosource.cpp
Lines 306 to 330 in ef243ab
This happens somewhere in the middle of the audio file, likely at the point where the two files were concatenated. With this,
CurrentFrame
is already overwritten, but sinceavcodec_receive_frame
didn't return data yet, no audio frame was added to the cache. Since the condition in line 427 assumes that there's a suitable audio frame in the cache,DecodeNextBlock
isn't called any more and the function loops infinitely.Fixes
A simple band-aid solution would be to check the return value of
DecodeNextBlock
in line 428 and throw an error if it's zero. Properly fixing this would mean sending more data toavcodec
untilavcodec_receive_frame
works again, but I don't know enough about the code base and the packet counting involved to want to attempt that, if it's even possible.Finally, a side note... it'd be really great to have a new release of ffms2 sometime soon. Linux distributions still have release 2.40, which still has the seeking regression in #394 , which causes seeking errors in lots of videos. New Aegisub users on Linux or Mac run into this a lot, for example.
The text was updated successfully, but these errors were encountered: