diff --git a/src/media/media_stream.h b/src/media/media_stream.h index a8f8eeeb41dd549b7c3ed5296ffec0e706939da0..b3e43e4ebc4916d4782be0bc3553c6ede687cb55 100644 --- a/src/media/media_stream.h +++ b/src/media/media_stream.h @@ -80,9 +80,9 @@ struct MediaStream { MediaStream(std::string name, AVCodecContext* c, int64_t firstTimestamp) : name(name) + , firstTimestamp(firstTimestamp) { timeBase = c->time_base; - this->firstTimestamp = firstTimestamp; switch (c->codec_type) { case AVMEDIA_TYPE_VIDEO: format = c->pix_fmt; @@ -114,6 +114,20 @@ struct MediaStream { else return sampleRate > 0 && nbChannels > 0; } + + void update(AVFrame* f) + { + // update all info possible (AVFrame has no fps data) + format = f->format; + if (isVideo) { + width = f->width; + height = f->height; + aspectRatio = f->sample_aspect_ratio; + } else { + sampleRate = f->sample_rate; + nbChannels = f->channels; + } + } }; inline std::ostream& operator<<(std::ostream& os, const MediaStream& ms)