Ticket #12055: 0259-ticket12xxx-hls-add-preset-tune.patch

File 0259-ticket12xxx-hls-add-preset-tune.patch, 3.8 KB (added by warpme@…, 6 years ago)

patch to transcoder speed-up

  • mythtv/external/FFmpeg/libavcodec/libx264.c

    diff -Naur mythtv-0.27-build-old/mythtv/external/FFmpeg/libavcodec/libx264.c mythtv-0.27-build-new/mythtv/external/FFmpeg/libavcodec/libx264.c
    old new  
    289289    x4->params.rc.f_pb_factor             = avctx->b_quant_factor;
    290290    x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
    291291    if (x4->preset || x4->tune)
     292        av_log(avctx, AV_LOG_INFO, "x264 setting preset/tune to: %s/%s.\n", x4->preset, x4->tune);
    292293        if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) {
    293294            int i;
    294295            av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", x4->preset, x4->tune);
  • mythtv/libs/libmythtv/avformatwriter.cpp

    diff -Naur mythtv-0.27-build-old/mythtv/libs/libmythtv/avformatwriter.cpp mythtv-0.27-build-new/mythtv/libs/libmythtv/avformatwriter.cpp
    old new  
    545545        av_opt_set_int(c, "mixed-refs", 1, 0);
    546546        av_opt_set_int(c, "8x8dct", 0, 0);
    547547        av_opt_set_int(c, "weightb", 0, 0);
     548
     549        const char* preset = m_EncodingPreset.toStdString().c_str();
     550        av_opt_set(c->priv_data, "preset", preset, 0);
     551        const char* tune = m_EncodingTune.toStdString().c_str();
     552        av_opt_set(c->priv_data, "tune", tune, 0);
    548553    }
    549554
    550555    if(m_ctx->oformat->flags & AVFMT_GLOBALHEADER)
  • mythtv/libs/libmythtv/filewriterbase.h

    diff -Naur mythtv-0.27-build-old/mythtv/libs/libmythtv/filewriterbase.h mythtv-0.27-build-new/mythtv/libs/libmythtv/filewriterbase.h
    old new  
    4040    void SetAudioFormat(AudioFormat f)  { m_audioFormat = f; }
    4141    void SetThreadCount(int count)      { m_encodingThreadCount = count; }
    4242    void SetTimecodeOffset(long long o) { m_startingTimecodeOffset = o; }
     43    void SetEncodingPreset(QString preset) { m_EncodingPreset = preset; }
     44    void SetEncodingTune(QString tune)  { m_EncodingTune = tune; }
    4345
    4446    long long GetFramesWritten(void)  const { return m_framesWritten; }
    4547    long long GetTimecodeOffset(void) const { return m_startingTimecodeOffset; }
     
    6769    int         m_encodingThreadCount;
    6870    long long   m_framesWritten;
    6971    long long   m_startingTimecodeOffset;
     72    QString     m_EncodingPreset;
     73    QString     m_EncodingTune;
    7074};
    7175
    7276#endif
  • mythtv/programs/mythtranscode/transcode.cpp

    diff -Naur mythtv-0.27-build-old/mythtv/programs/mythtranscode/transcode.cpp mythtv-0.27-build-new/mythtv/programs/mythtranscode/transcode.cpp
    old new  
    556556            avfw->SetKeyFrameDist(30);
    557557        }
    558558
    559         avfw->SetThreadCount(
    560             gCoreContext->GetNumSetting("HTTPLiveStreamThreads", 2));
     559        int threads    = gCoreContext->GetNumSetting("HTTPLiveStreamThreads", 2);
     560        QString preset = gCoreContext->GetSetting("HTTPLiveStreamPreset", "medium");
     561        QString tune   = gCoreContext->GetSetting("HTTPLiveStreamTune", "film");
     562
     563        LOG(VB_GENERAL, LOG_NOTICE,
     564            QString("x264 HLS using: %1 threads, '%2' profile and '%3' tune")
     565                .arg(threads).arg(preset).arg(tune));
     566
     567        avfw->SetThreadCount(threads);
     568        avfw->SetEncodingPreset(preset);
     569        avfw->SetEncodingTune(tune);
    561570
    562571        if (avfw2)
    563572            avfw2->SetThreadCount(1);