1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-30 08:57:00 +02:00

Fix crash on attempt to play audio from video without such stream

This commit is contained in:
Ivan Savenko 2024-07-16 09:53:16 +00:00
parent ad9750ed3e
commit a273eb6413

View File

@ -494,7 +494,11 @@ std::pair<std::unique_ptr<ui8 []>, si64> CAudioInstance::extractAudio(const Vide
if (!openInput(videoToOpen))
return { nullptr, 0};
openContext();
openCodec(findAudioStream());
int audioStreamIndex = findAudioStream();
if (audioStreamIndex == -1)
return { nullptr, 0};
openCodec(audioStreamIndex);
const auto * codecpar = getCodecParameters();