Commit 05cc3437 authored by Éloi Bail's avatar Éloi Bail Committed by Guillaume Roguez

Daemon: set FPS for streamed files

Refs #69334

Change-Id: I2b1e6916b9d7aa314676cc9ef69eca653a3818e2
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent e6f9ff4e
......@@ -250,7 +250,8 @@ int MediaDecoder::setupFromVideoData()
}
// Get a pointer to the codec context for the video stream
decoderCtx_ = inputCtx_->streams[streamIndex_]->codec;
avStream_ = inputCtx_->streams[streamIndex_];
decoderCtx_ = avStream_->codec;
if (decoderCtx_ == 0) {
RING_ERR("Decoder context is NULL");
return -1;
......@@ -428,6 +429,14 @@ int MediaDecoder::getWidth() const
int MediaDecoder::getHeight() const
{ return decoderCtx_->height; }
int // TODO : use of float fps is more accurate
MediaDecoder::getFps() const
{
return (avStream_->avg_frame_rate.den != 0 ?
(int)(avStream_->avg_frame_rate.num / avStream_->avg_frame_rate.den)
: 0);
}
int MediaDecoder::getPixelFormat() const
{ return libav_utils::ring_pixel_format(decoderCtx_->pix_fmt); }
......
......@@ -99,6 +99,7 @@ class MediaDecoder {
int getWidth() const;
int getHeight() const;
int getFps() const;
int getPixelFormat() const;
void setOptions(const std::map<std::string, std::string>& options);
......@@ -109,6 +110,7 @@ class MediaDecoder {
AVCodec *inputDecoder_ = nullptr;
AVCodecContext *decoderCtx_ = nullptr;
AVFormatContext *inputCtx_ = nullptr;
AVStream *avStream_ = nullptr;
std::unique_ptr<Resampler> resampler_;
int streamIndex_ = -1;
bool emulateRate_ = false;
......
......@@ -185,6 +185,11 @@ VideoInput::createDecoder()
}
decOpts_.width = decoder_->getWidth();
decOpts_.height = decoder_->getHeight();
decOpts_.framerate = decoder_->getFps();
RING_INFO("create decoder with video params : size=%dX%d, fps=%d",
decOpts_.width,
decOpts_.height,
decOpts_.framerate);
foundDecOpts(decOpts_);
}
......@@ -266,9 +271,6 @@ VideoInput::initFile(std::string path)
decOpts_.framerate = 1;
} else {
RING_WARN("Guessing file type for %s", path.c_str());
// FIXME: proper parsing of FPS etc. should be done in
// MediaDecoder, not here.
decOpts_.framerate = 25;
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment