Fallback to detecting the stream duration from the AVFormatContext, if the
AVStream does not provide it. For my test Flash Videos, I can at least get a duration now, although seeking is pretty broken. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31616 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -656,12 +656,24 @@ AVFormatReader::StreamCookie::GetStreamInfo(int64* frameCount,
|
|||||||
// for a couple of streams and are in line with the documentation, but
|
// for a couple of streams and are in line with the documentation, but
|
||||||
// unfortunately, libavformat itself seems to set the time_base and
|
// unfortunately, libavformat itself seems to set the time_base and
|
||||||
// duration wrongly sometimes. :-(
|
// duration wrongly sometimes. :-(
|
||||||
TRACE(" stream duration: %lld, time_base %.4f (%d/%d)\n",
|
static const int64 kNoPTSValue = 0x8000000000000000LL;
|
||||||
fStream->duration,
|
// NOTE: For some reasons, I have trouble with the avcodec.h define:
|
||||||
av_q2d(fStream->time_base),
|
// #define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
|
||||||
fStream->time_base.num, fStream->time_base.den);
|
// INT64_C is not defined here.
|
||||||
*duration = (bigtime_t)(1000000LL * fStream->duration
|
if ((int64)fStream->duration != kNoPTSValue) {
|
||||||
* av_q2d(fStream->time_base));
|
*duration = (bigtime_t)(1000000LL * fStream->duration
|
||||||
|
* fStream->time_base.num / fStream->time_base.den);
|
||||||
|
TRACE(" stream duration: %lld, time_base %.4f (%d/%d)\n",
|
||||||
|
*duration, av_q2d(fStream->time_base),
|
||||||
|
fStream->time_base.num, fStream->time_base.den);
|
||||||
|
} else if ((int64)fContext->duration != kNoPTSValue) {
|
||||||
|
*duration = (bigtime_t)(1000000LL * fContext->duration / AV_TIME_BASE);
|
||||||
|
TRACE(" stream duration: %lld (from AVFormatContext)\n",
|
||||||
|
*duration);
|
||||||
|
} else {
|
||||||
|
*duration = 0;
|
||||||
|
TRACE(" stream duration: N/A\n");
|
||||||
|
}
|
||||||
|
|
||||||
TRACE(" duration: %lld or %.2fs\n", *duration, *duration / 1000000.0);
|
TRACE(" duration: %lld or %.2fs\n", *duration, *duration / 1000000.0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user