Ticket #12047: 0001-use-av_guess_frame_rate-from-ffmpeg-2.2-to-replace-o.patch

File 0001-use-av_guess_frame_rate-from-ffmpeg-2.2-to-replace-o.patch, 2.8 KB (added by Karl Egly, 6 years ago)
  • mythtv/libs/libmythtv/avformatdecoder.cpp

    From b847ef40e2f9a13f54315518be45d5ff11276632 Mon Sep 17 00:00:00 2001
    From: Karl Dietz <dekarl@mythtv.org>
    Date: Sun, 27 Apr 2014 02:19:55 +0200
    Subject: [PATCH 1/5] use av_guess_frame_rate from ffmpeg 2.2+ to replace own
     guesswork
    
    Fixes #12047
    ---
     mythtv/libs/libmythtv/avformatdecoder.cpp |   27 +++++++++++++++++++++------
     1 file changed, 21 insertions(+), 6 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index 412806c..55c9b27 100644
    a b int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo, 
    13571357
    13581358float AvFormatDecoder::normalized_fps(AVStream *stream, AVCodecContext *enc)
    13591359{
    1360     float fps, avg_fps, codec_fps, container_fps, estimated_fps;
    1361     avg_fps = codec_fps = container_fps = estimated_fps = 0.0f;
    1362 
     1360    float fps, avg_fps, codec_fps, container_fps, estimated_fps, guess_fps;
     1361    avg_fps = codec_fps = container_fps = estimated_fps = guess_fps = 0.0f;
     1362
     1363    /*
     1364     * Let ffmpeg do the guessing instead of duplicating their work.
     1365     * Only use our guess when ffmpeg doesn't come up with anything
     1366     * >3fps
     1367     */
     1368    guess_fps = av_q2d(av_guess_frame_rate(ic, stream, NULL));
     1369
     1370    /* this is not a good source for FPS according to
     1371     * https://trac.bunkus.org/wiki/FAQ:WrongFrameRateDisplayed
     1372     */
    13631373    if (stream->avg_frame_rate.den && stream->avg_frame_rate.num)
    13641374        avg_fps = av_q2d(stream->avg_frame_rate); // MKV default_duration
    13651375
    float AvFormatDecoder::normalized_fps(AVStream *stream, AVCodecContext *enc) 
    13781388    if (stream->r_frame_rate.den && stream->r_frame_rate.num) // tbr
    13791389        estimated_fps = av_q2d(stream->r_frame_rate);
    13801390
     1391    if (guess_fps > 3.0f)
     1392    {
     1393       fps = guess_fps;
     1394    }
    13811395    // matroska demuxer sets the default_duration to avg_frame_rate
    13821396    // mov,mp4,m4a,3gp,3g2,mj2 demuxer sets avg_frame_rate
    1383     if ((QString(ic->iformat->name).contains("matroska") ||
     1397    else if ((QString(ic->iformat->name).contains("matroska") ||
    13841398        QString(ic->iformat->name).contains("mov")) &&
    13851399        avg_fps < 121.0f && avg_fps > 3.0f)
    13861400        fps = avg_fps;
    float AvFormatDecoder::normalized_fps(AVStream *stream, AVCodecContext *enc) 
    14011415    if (fps != m_fps)
    14021416    {
    14031417        LOG(VB_PLAYBACK, LOG_INFO, LOC +
    1404             QString("Selected FPS is %1 (avg %2 codec %3 "
     1418            QString("Selected FPS is %1 (guess %6 avg %2 codec %3 "
    14051419                    "container %4 estimated %5)").arg(fps).arg(avg_fps)
    1406                 .arg(codec_fps).arg(container_fps).arg(estimated_fps));
     1420                .arg(codec_fps).arg(container_fps).arg(estimated_fps)
     1421                .arg(guess_fps));
    14071422        m_fps = fps;
    14081423    }
    14091424