don't delay audio on matroska files

This commit is contained in:
odrling 2022-03-05 03:08:45 +01:00
parent d73de0cdb4
commit bdd2d0f578
No known key found for this signature in database
GPG Key ID: EC907F69A27A90C5
1 changed files with 11 additions and 2 deletions

View File

@ -43,6 +43,8 @@
#include <map>
#include <boost/algorithm/string.hpp>
namespace {
class FFmpegSourceAudioProvider final : public agi::AudioProvider, FFmpegSourceProvider {
/// audio source object
@ -90,6 +92,8 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
throw agi::AudioDataNotFound(ErrInfo.Buffer);
}
const char* container = FFMS_GetFormatNameI(Indexer);
std::map<int, std::string> TrackList = GetTracksOfType(Indexer, FFMS_TYPE_AUDIO);
// initialize the track number to an invalid value so we can detect later on
@ -142,8 +146,13 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
// update access time of index file so it won't get cleaned away
agi::fs::Touch(CacheName);
AudioSource = FFMS_CreateAudioSource(filename.string().c_str(), TrackNumber, Index, FFMS_DELAY_FIRST_VIDEO_TRACK, &ErrInfo);
if (!AudioSource)
int delay_mode;
if (boost::algorithm::contains(container, "matroska"))
delay_mode = FFMS_DELAY_TIME_ZERO;
else
delay_mode = FFMS_DELAY_FIRST_VIDEO_TRACK;
AudioSource = FFMS_CreateAudioSource(filename.string().c_str(), TrackNumber, Index, delay_mode, &ErrInfo); if (!AudioSource)
throw agi::AudioProviderError(std::string("Failed to open audio track: ") + ErrInfo.Buffer);
const FFMS_AudioProperties AudioInfo = *FFMS_GetAudioProperties(AudioSource);