mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-09 07:47:33 +00:00
Don't trust AVFormatContext duration in Webm video.
It reports some strange numbers like 1000, which is 1ms.
This commit is contained in:
parent
219ffd2c48
commit
2e39befd7c
@ -18,6 +18,18 @@ namespace {
|
||||
constexpr auto kMaxSingleReadAmount = 8 * 1024 * 1024;
|
||||
constexpr auto kMaxQueuedPackets = 1024;
|
||||
|
||||
[[nodiscard]] bool UnreliableFormatDuration(
|
||||
not_null<AVFormatContext*> format,
|
||||
not_null<AVStream*> stream) {
|
||||
return stream->codec
|
||||
&& (stream->codec->codec_id == AV_CODEC_ID_VP9)
|
||||
&& format->iformat
|
||||
&& format->iformat->name
|
||||
&& QString::fromLatin1(
|
||||
format->iformat->name
|
||||
).split(QChar(',')).contains(u"webm");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
File::Context::Context(
|
||||
@ -174,6 +186,8 @@ Stream File::Context::initStream(
|
||||
result.timeBase = info->time_base;
|
||||
result.duration = (info->duration != AV_NOPTS_VALUE)
|
||||
? FFmpeg::PtsToTime(info->duration, result.timeBase)
|
||||
: UnreliableFormatDuration(format, info)
|
||||
? kTimeUnknown
|
||||
: FFmpeg::PtsToTime(format->duration, FFmpeg::kUniversalTimeBase);
|
||||
if (result.duration == kTimeUnknown) {
|
||||
result.duration = kDurationUnavailable;
|
||||
|
Loading…
Reference in New Issue
Block a user