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
Support playing movies with libav and fix ffmpeg audio stutter #621
Conversation
Actually I'd like to look into the framerate issue a little more before this is merged. The value I came up with is perfect for the intro video (17.5fps) but the lose videos have a drastically different intended framerate (8.333fps). |
Actually I was pretty close to the answer. It seems I should be using the time_base from the AVStream not the AVCodecContext. I'll fix this tonight or tomorrow night. |
c1fb6de
to
54e392b
Compare
I've corrected the framerate issue, and now I'm quite happy with the state of playing videos with libav. (So happy that unless I can improve the ffmpeg version I'm going to ship 0.50 with libav) |
Added a second commit to this pull request which fixes the stutter in ffmpeg. Incidentally I had caused it trying to take advantage of newer features. That they weren't available in libav and audio was working fine lead me to the solution. |
3f76480
to
a26e46a
Compare
Added explicit include for libavutil/mathematics.h for libav-9.16 as reported by @legluondunet |
Note: I have verified that this works with libav-11.1 for windows and Ubuntu 14.10. This code does not work on the earlier libav-9.16 included in Ubuntu 14.04 LTS. (Of note: avplay in ubuntu 14.04 is also unable to properly play intro.sm4 so it may not be possible to support our movies with that version of libav.) |
I didn't manage to create 64-bit binaries for Visual Studio here either... I think I'll scrap Visual Studio soon. :-P On Ubuntu on the other hand everything worked as a charm as usual. |
While the sound doesn't stutter anymore I get some image stuttering back and forth when running on a virtual Ubuntu machine (always had this) |
Again you have to run the libav compile instructions from the Visual Studio x64 console. Enhanced edition can't, but community edition and pro have it. |
@Lego3 when you say 'always had this', you mean you had an issue with video stuttering in ffmepg as well and libav just doesn't fix it? Is there anything holding this back from being merged? |
I don't think there is anything holding it back, no. I managed to compile once I found the correct command prompt. :-P CMake still asks for postproc, which I couldn't see is a part of libav. But the game works fine without it... |
And by the way, has SDL_mixer inclusion always been under the advanced tab in CMake? |
You are right about postproc. I'll fix FindLibAV to match all the right libraries before it's merged. Not sure about sdl2mixer - not a change I made. |
ecad961
to
5710f1c
Compare
Removed postproc and add libavfilter to FindLibAV.cmake for correctness. Neither are used by CorsixTH. |
Makes libav an optional alternative to ffmpeg, selected in cmake. The intro movie plays perfectly with this libav code.
Attempting to calculate the resampling delay for determining the number of out samples was actually causing underruns. There is no harm in not accounting for any resample delay because any samples not taken are buffered for the next conversion.
Use av_frame_alloc, av_frame_unref, and av_frame_free instead of their earlier equivalents. In the case of av_frame_free we were not using the earlier equivalent but av_free. With these changes avcodec_frame_free will be used on versions that don't yet support av_frame_free. FFMPEG versions that do not support avcodec_frame_free are not supported with this commit.
Support playing movies with libav and fix ffmpeg audio stutter
Makes libav an optional alternative to ffmpeg, selected in cmake.
The intro movie actually plays better with this libav code, but the frame
rate had to be determined experimentally as time_base for these videos in
libav seems to be giving a value of 0/1.
This addresses the issue of building on Ubuntu (e.g. #594)
The second commit fixes the audio stutter in ffmpeg, making it use the same path for calculating the out samples as libav is using.
The third commit fixes deprecated function warnings while falling back to earlier versions when those functions are not available. Most importantly it uses av_frame_free instead of av_free for frames which is needed to free extended data associated with frames.