kidrigger / godot-videodecoder

GDNative Video Decoder libraries for Godot Game Engine, using FFmpeg library for codecs. A Google Summer of Code Project, 2018
MIT License
84 stars 22 forks source link

Fix audio synchronization and frame dropping performance. #20

Closed jamie-pate closed 4 years ago

jamie-pate commented 4 years ago

To decode the audio frames correctly: Check the pts value (presentation timestamp) and either skip audio frames or hold onto them until the timestamp is within ~1 game frame, then feed them into the buffer.

To prevent frame dropping from affecting game performance: Mark the time when get_videoframe is called, while dropping frames check the elapsed time and stop decoding frames if too much time has elapesd (hard coded at 10ms currently) This isn't really supported by the VideoStreamGdnative interface! The workaround is to lie about the video position during update(). If we are dropping frames then we will tell godot that the video time is whatever it expects and it will stop calling get_videoframe().

Also lots of cleanup of stray printfs, debugging information etc.

ALSO: Fix for osxcross build and include libwinpthread-1.dll for windows