Skip to content

Commit

Permalink
Change frame rate detection
Browse files Browse the repository at this point in the history
Make FPS detection of the input file similar to the FFmpeg's own
re-encoding algorithm.
  • Loading branch information
SuslikV committed Feb 27, 2020
1 parent 689f1e1 commit e7bd918
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/FFmpegReader.cpp
Expand Up @@ -706,9 +706,16 @@ void FFmpegReader::UpdateVideoInfo() {
info.vcodec = pCodecCtx->codec->name;
info.video_bit_rate = (pFormatCtx->bit_rate / 8);

// set frames per second (fps)
info.fps.num = pStream->avg_frame_rate.num;
info.fps.den = pStream->avg_frame_rate.den;
// Frame rate from the container and codec
AVRational framerate = av_guess_frame_rate(pFormatCtx, pStream, NULL);
info.fps.num = framerate.num;
info.fps.den = framerate.den;

ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdateVideoInfo", "info.fps.num", info.fps.num, "info.fps.den", info.fps.den);

// TODO: remove excessive debug info in the next releases
// The debug info below is just for comparison and troubleshooting on users side during the transition period
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdateVideoInfo (pStream->avg_frame_rate)", "num", pStream->avg_frame_rate.num, "den", pStream->avg_frame_rate.den);

if (pStream->sample_aspect_ratio.num != 0) {
info.pixel_ratio.num = pStream->sample_aspect_ratio.num;
Expand Down

0 comments on commit e7bd918

Please sign in to comment.