Есть ли простой способ использовать пресеты x264 с ffmpeg в коде? - PullRequest
0 голосов
/ 26 марта 2012

Я пытаюсь кодировать видео с помощью ffmpeg и x264.Я знаю, что ffmpeg может использовать предустановки x264 при использовании программы ffmpeg из командной строки.Но возможно ли легко использовать эти пресеты при кодировании с помощью ffmpeg в коде?

Если нет, как лучше всего установить параметры x264 из кода ffmpeg?Это просто использование свойств AVCodecContext?Все ли опции x264 доступны через это?

Спасибо!

Ответы [ 2 ]

0 голосов
/ 29 августа 2014

Во-первых, вы должны знать, что ffmpeg поддерживает x264opts и x264-params, чтобы добавить более точное управление x264 encodec. и он передает список ключ = значение, разделенный ":", в x264. например:

ffmpeg .... -x264opts bframes=0:... ...

что означает установку bframes в 0 для x264. этот формат не полностью совпадает с x264.

Более подробно проверьте это:

1, ffmpge document

2 x264

0 голосов
/ 09 августа 2012

Извините за очень поздний ответ, но у меня был тот же вопрос, и я хочу поделиться решением, которое я нашел.Да, многие параметры x264 можно передавать через командную строку и API, по крайней мере, при использовании libav (сейчас я не могу подтвердить с помощью ffmpeg).Выпустив avconv --help, вы можете найти это:

libx264 AVOptions:
-preset            <string> E.V.. Set the encoding preset (cf. x264 --fullhelp)
-tune              <string> E.V.. Tune the encoding params (cf. x264 --fullhelp)
-profile           <string> E.V.. Set profile restrictions (cf. x264 --fullhelp)
-fastfirstpass     <int>   E.V.. Use fast settings when encoding first pass
-crf               <float> E.V.. Select the quality for constant quality mode
-crf_max           <float> E.V.. In CRF mode, prevents VBV from lowering quality beyond this point.
-qp                <int>   E.V.. Constant quantization parameter rate control method
-aq-mode           <int>   E.V.. AQ method
   none                    E.V..
   variance                E.V.. Variance AQ (complexity mask)
   autovariance            E.V.. Auto-variance AQ (experimental)
-aq-strength       <float> E.V.. AQ strength. Reduces blocking and blurring in flat and textured areas.
-psy               <int>   E.V.. Use psychovisual optimizations.
-psy-rd            <string> E.V.. Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.
-rc-lookahead      <int>   E.V.. Number of frames to look ahead for frametype and ratecontrol
-weightb           <int>   E.V.. Weighted prediction for B-frames.
-weightp           <int>   E.V.. Weighted prediction analysis method.
   none                    E.V..
   simple                  E.V..
   smart                   E.V..
-ssim              <int>   E.V.. Calculate and print SSIM stats.
-intra-refresh     <int>   E.V.. Use Periodic Intra Refresh instead of IDR frames.
-b-bias            <int>   E.V.. Influences how often B-frames are used
-b-pyramid         <int>   E.V.. Keep some B-frames as references.
   none                    E.V..
   strict                  E.V.. Strictly hierarchical pyramid
   normal                  E.V.. Non-strict (not Blu-ray compatible)
-mixed-refs        <int>   E.V.. One reference per partition, as opposed to one reference per macroblock
-8x8dct            <int>   E.V.. High profile 8x8 transform.
-fast-pskip        <int>   E.V..
-aud               <int>   E.V.. Use access unit delimiters.
-mbtree            <int>   E.V.. Use macroblock tree ratecontrol.
-deblock           <string> E.V.. Loop filter parameters, in <alpha:beta> form.
-cplxblur          <float> E.V.. Reduce fluctuations in QP (before curve compression)
-partitions        <string> E.V.. A comma-separated list of partitions to consider. Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all
-direct-pred       <int>   E.V.. Direct MV prediction mode
   none                    E.V..
   spatial                 E.V..
   temporal                E.V..
   auto                    E.V..
-slice-max-size    <int>   E.V.. Limit the size of each slice in bytes
-stats             <string> E.V.. Filename for 2 pass stats

При использовании структуры AVCodecContext вы также можете установить такие параметры, как -rc-lookahead, которые можно установить в AVCodecContext :: rc_lookahead, но яне уверен насчет -preset сейчас.

Надеюсь, это поможет

...