diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp index 588191d91e..979c0e1707 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp @@ -486,6 +486,7 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex) = codecContext->channels; format->u.encoded_audio.output.format = avformat_to_beos_format(codecContext->sample_fmt); + format->u.raw_audio.buffer_size = codecContext->block_align; break; case B_MEDIA_ENCODED_VIDEO: @@ -698,9 +699,8 @@ AVFormatReader::StreamCookie::GetStreamInfo(int64* frameCount, *format = fFormat; - // TODO: Possibly use fStream->metadata for this? - *infoBuffer = 0; - *infoSize = 0; + *infoBuffer = fStream->codec->extradata; + *infoSize = fStream->codec->extradata_size; return B_OK; } @@ -730,17 +730,19 @@ AVFormatReader::StreamCookie::Seek(uint32 flags, int64* frame, if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0) *time = (bigtime_t)(*frame * 1000000LL / FrameRate()); - double timeBase = av_q2d(fStream->time_base); int64_t timeStamp; if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0) { // Can use frame, because stream timeStamp is actually in frame // units. timeStamp = *frame; - } else - timeStamp = (int64_t)(*time / timeBase / 1000000.0); + } else { + timeStamp = *time * fStream->time_base.num + / ((int64_t)fStream->time_base.den * 1000000); + } - TRACE_SEEK(" time: %.2fs -> %lld, current DTS: %lld (time_base: %f)\n", - *time / 1000000.0, timeStamp, fStream->cur_dts, timeBase); + TRACE_SEEK(" time: %.5fs -> %lld, current DTS: %lld (time_base: %d/%d)\n", + *time / 1000000.0, timeStamp, fStream->cur_dts, fStream->time_base.num, + fStream->time_base.den); if (av_seek_frame(fContext, Index(), timeStamp, 0) < 0) { TRACE_SEEK(" av_seek_frame() failed.\n");