<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">Den 26.10.2024 01:37, skrev Andrew
      Randrianasulu:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+rFky4XYNhD3+Xfceo29FwqZyuzOE2F1u_BW62PFGbBaXfJsg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr"><br>
        </div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Sat, Oct 26, 2024 at
            2:14 AM Andrew Randrianasulu <<a
              href="mailto:randrianasulu@gmail.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">randrianasulu@gmail.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div dir="ltr">
              <div dir="ltr"><br>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Sat, Oct 26, 2024
                  at 1:29 AM Andrew Randrianasulu <<a
                    href="mailto:randrianasulu@gmail.com"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">randrianasulu@gmail.com</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div dir="auto">
                    <div><br>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">сб, 26 окт.
                          2024 г., 00:58 Terje J. Hanssen <<a
                            href="mailto:terjejhanssen@gmail.com"
                            rel="noreferrer" target="_blank"
                            moz-do-not-send="true"
                            class="moz-txt-link-freetext">terjejhanssen@gmail.com</a>>:<br>
                        </div>
                        <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                          <div> <br>
                            <br>
                            <br>
                            <div>Den 25.10.2024 21:48, skrev Andrew
                              Randrianasulu:<br>
                            </div>
                            <blockquote type="cite">
                              <div dir="auto">We branching!
                                <div dir="auto"><br>
                                </div>
                                <div dir="auto">I looked at
                                  gpu-screen-recorder</div>
                                <div dir="auto"><br>
                                </div>
                                <div dir="auto"><a
href="https://git.dec05eba.com/gpu-screen-recorder/tree/src/encoder/video/vaapi.c"
rel="noreferrer noreferrer noreferrer" target="_blank"
                                    moz-do-not-send="true"
                                    class="moz-txt-link-freetext">https://git.dec05eba.com/gpu-screen-recorder/tree/src/encoder/video/vaapi.c</a><br>
                                </div>
                                <div dir="auto"><br>
                                </div>
                                <div dir="auto">it sets</div>
                                <div dir="auto"><br>
                                </div>
                                <div dir="auto">
                                  <pre><code>AVHWFramesContext *hw_frame_context = (AVHWFramesContext*)frame_context->data;
    hw_frame_context->width = video_codec_context->width;
    hw_frame_context->height = video_codec_context->height;
    hw_frame_context->sw_format = self->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? AV_PIX_FMT_P010LE : AV_PIX_FMT_NV12;
    hw_frame_context->format = video_codec_context->pix_fmt;
    hw_frame_context->device_ctx = (AVHWDeviceContext*)self->device_ctx->data;</code></pre>
                                  <pre><code>
</code></pre>
                                  <pre><code>
</code></pre>
                                  <pre><code>so may be we need to set </code>AV_PIX_FMT_P010LE and not just P010?</pre>
                                </div>
                              </div>
                            </blockquote>
                            <br>
                            Sorry, It didn't render more than 8bit
                            yuv420p<br>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
            </div>
          </blockquote>
        </div>
      </div>
    </blockquote>
    <br>
    I continue from the last point above with a similar setup for VAAPI
    that I just did for Quicksync Video - QSV encoding with system
    ffmpeg 7.1:<br>
    <a class="moz-txt-link-freetext"
href="https://lists.cinelerra-gg.org/pipermail/cin/2024-October/008950.html">https://lists.cinelerra-gg.org/pipermail/cin/2024-October/008950.html</a><br>
    <br>
    FFmpeg supported VAAPI pixel formats and profiles:<br>
    <br>
    <font face="Courier New, Courier, monospace">ffmpeg -hide_banner
      -encoders | grep vaapi<br>
       V....D av1_vaapi            AV1 (VAAPI) (codec av1)<br>
       V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)<br>
       V....D hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)<br>
       V....D mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)<br>
       V....D mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)<br>
       V....D vp8_vaapi            VP8 (VAAPI) (codec vp8)<br>
       V....D vp9_vaapi            VP9 (VAAPI) (codec vp9)<br>
      <br>
      <br>
      ffmpeg -hide_banner -h encoder=av1_vaapi | egrep
      'Supported|profile|main|high|professional'<br>
          Supported hardware devices: vaapi<br>
          Supported pixel formats: vaapi<br>
        -profile           <int>        E..V....... Set profile
      (seq_profile) (from -99 to 255) (default -99)<br>
           main            0            E..V.......<br>
           high            1            E..V.......<br>
           professional    2            E..V.......<br>
        -tier              <int>        E..V....... Set tier
      (seq_tier) (from 0 to 1) (default main)<br>
           main            0            E..V.......<br>
           high            1            E..V.......<br>
      <br>
      <br>
      ffmpeg -hide_banner -h encoder=hevc_vaapi | egrep
      'Supported|profile|main|high|professional'<br>
          Supported hardware devices: vaapi<br>
          Supported pixel formats: vaapi<br>
        -profile           <int>        E..V....... Set profile
      (general_profile_idc) (from -99 to 255) (default -99)<br>
           main            1            E..V.......<br>
           main10          2            E..V.......<br>
        -tier              <int>        E..V....... Set tier
      (general_tier_flag) (from 0 to 1) (default main)<br>
           main            0            E..V.......<br>
           high            1            E..V.......<br>
      <br>
      <br>
      ffmpeg -hide_banner -h encoder=h264_vaapi | egrep
      'Supported|profile|main|high|professional'<br>
          Supported hardware devices: vaapi<br>
          Supported pixel formats: vaapi<br>
        -quality           <int>        E..V....... Set encode
      quality (trades off against speed, higher is faster) (from -1 to
      INT_MAX) (default -1)<br>
        -profile           <int>        E..V....... Set profile
      (profile_idc and constraint_set*_flag) (from -99 to 65535)
      (default -99)<br>
           main            77           E..V.......<br>
           high            100          E..V.......<br>
           high10          110          E..V.......<br>
    </font><br>
    <br>
    Supported pixel formats tell just "vaapi" and not more info about
    them as corresponding QSV do.<br>
    <br>
    The libva implementation and tools give more detailed info about the
    available pixel formats for encoding:<br>
    <br>
    <font face="Courier New, Courier, monospace"> vainfo | grep
      VAEntrypointEncSlice<br>
      libva info: VA-API version 1.22.0<br>
      libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so<br>
      libva info: Found init function __vaDriverInit_1_22<br>
      libva info: va_openDriver() returns 0<br>
            VAProfileH264Main               :    VAEntrypointEncSliceLP<br>
            VAProfileH264High               :    VAEntrypointEncSliceLP<br>
            VAProfileH264ConstrainedBaseline:    VAEntrypointEncSliceLP<br>
            VAProfileHEVCMain               :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCMain10             :    VAEntrypointEncSliceLP<br>
            VAProfileVP9Profile0            :    VAEntrypointEncSliceLP<br>
            VAProfileVP9Profile1            :    VAEntrypointEncSliceLP<br>
            VAProfileVP9Profile2            :    VAEntrypointEncSliceLP<br>
            VAProfileVP9Profile3            :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCMain422_10         :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCMain444            :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCMain444_10         :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCSccMain            :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCSccMain10          :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCSccMain444         :    VAEntrypointEncSliceLP<br>
            VAProfileAV1Profile0            :    VAEntrypointEncSliceLP<br>
            VAProfileHEVCSccMain444_10      :    VAEntrypointEncSliceLP</font><br>
    <br>
    <br>
    Format p010le results in "just" 10bit yuv420p.<br>
    <br>
    The clue for hevc_vaapi to encode true 10bit 422p video, is found to
    use (trying this for av1_vaapi auto-switch to 8bit p010):<br>
    <font face="Courier New, Courier, monospace"><br>
               -vf 'format=y210,hwupload'<br>
      <br>
      After troubleshooting a useable profile, rendering went on by
      simply leaving profile out:<br>
      <br>
      <br>
      Example ffmpeg 7.1 simple code line for hevc_vaapi encoding
      (without audio):<br>
      <br>
      ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i
      cfhd01.mkv -vf 'format=y210,hwupload' -c:v hevc_vaapi
      cfhd01_hevc_vaapi_format_y210.mp4<br>
      <br>
      <br>
      yuv422p10le input file:<br>
      -----------------------<br>
      ffprobe -hide_banner cfhd01.mkv<br>
      Input #0, matroska,webm, from 'cfhd01.mkv':<br>
        Metadata:<br>
          ENCODER         : Lavf61.1.100<br>
        Duration: 00:01:11.24, start: 0.000000, bitrate: 393480 kb/s<br>
        Stream #0:0(eng): Video: cfhd (CFHD / 0x44484643),
      yuv422p10le(tv, bt709, top coded first (swapped)), 1920x1080, SAR
      1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)<br>
            Metadata:<br>
              HANDLER_NAME    : Apple Video Media Handler<br>
              VENDOR_ID       : appl<br>
              ENCODER         : Lavc61.3.100 cfhd<br>
              DURATION        : 00:01:11.240000000<br>
      <br>
      <br>
      yuv422p10le ourput file:<br>
      <br>
      ffprobe -hide_banner cfhd01_hevc_vaapi_format_y210.mp4<br>
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
      'cfhd01_hevc_vaapi_format_y210.mp4':<br>
        Metadata:<br>
          major_brand     : isom<br>
          minor_version   : 512<br>
          compatible_brands: isomiso2mp41<br>
          encoder         : Lavf61.7.100<br>
        Duration: 00:01:11.24, start: 0.000000, bitrate: 12129 kb/s<br>
        Stream #0:0[0x1](eng): Video: hevc (Rext) (hev1 / 0x31766568),
      yuv422p10le(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9],
      12127 kb/s, 25 fps, 25 tbr, 12800 tbn (default)<br>
            Metadata:<br>
              handler_name    : Apple Video Media Handler<br>
              vendor_id       : [0][0][0][0]<br>
              encoder         : Lavc61.19.100 hevc_vaapi<br>
      <br>
    </font>
    <blockquote type="cite"
cite="mid:CA+rFky4XYNhD3+Xfceo29FwqZyuzOE2F1u_BW62PFGbBaXfJsg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote">
          <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div dir="ltr">
              <div class="gmail_quote">
                <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div dir="auto">
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">yeahh ... probably need more 
                      debugging (seeing what pixel format goes into
                      ffmpeg vaapi interface at least).</div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">I only have decoding on nouveau, and
                      quite flaky at that - only 2 files so far worked
                      w,/o crashing, from around 2011/12.</div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">I tried to change two instances of
                      NV12 to P010LE and it  shows no visible effect, so
                      I assume it was supposed to  work with encoding
                      ...?</div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">it does not work even with qsv set
                      to p010 AND patch ?</div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">if so, I am afraid I only can put
                      this item on shelf ... for now. Look at mantis bug
                      database, if there is no entry about 10bit vaapi
                      deciding/encoding - add it please ....</div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">you can also test (at some point in
                      time ) this gpu_screen_recorder, it builds but
                      does not work for me due to "nouveau" driver.</div>
                    <div dir="auto"><br>
                    </div>
                  </div>
                </blockquote>
                <div><br>
                </div>
                <div><br>
                </div>
                <div>at least with another patch (attached) I can get
                  this:</div>
                <div><br>
                </div>
                <div>bash-5.1$ bin/cin  ~/6029.mp4<br>
                  Cinelerra Infinity - built: Oct 17 2024 16:18:31<br>
                  git://<a
href="http://git.cinelerra-gg.org/goodguy/cinelerra.git" target="_blank"
                    moz-do-not-send="true">git.cinelerra-gg.org/goodguy/cinelerra.git</a><br>
                  (c) 2006-2019 Heroine Virtual Ltd. by Adam Williams<br>
                  2007-2020 mods for Cinelerra-GG by W.P.Morrow aka
                  goodguy<br>
                  2003-2017 mods for Cinelerra-CV by CinelerraCV team<br>
                  2015-2024 mods for Cinelerra-GG by Cinelerra-GG team<br>
                  <br>
                  Libav version: Lavc61.3.100<br>
                  <br>
                  Cinelerra is free software, covered by the GNU General
                  Public License,<br>
                  and you are welcome to change it and/or distribute
                  copies of it under<br>
                  certain conditions. There is absolutely no warranty
                  for Cinelerra.<br>
                  <br>
                  RenderFarmClient::main_loop: client started<br>
                  [AVHWDeviceContext @ 0xf925c00] Trying to use DRM
                  render node for device 0.<br>
                  [AVHWDeviceContext @ 0xf925c00] libva: VA-API version
                  1.19.0<br>
                  [AVHWDeviceContext @ 0xf925c00] libva: Trying to open
                  /usr/lib/dri/nouveau_drv_video.so<br>
                  [AVHWDeviceContext @ 0xf925c00] libva: Found init
                  function __vaDriverInit_1_19<br>
                  [AVHWDeviceContext @ 0xf925c00] libva: va_openDriver()
                  returns 0<br>
                  [AVHWDeviceContext @ 0xf925c00] Initialised VAAPI
                  connection: version 1.19<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x3231564e
                  -> nv12.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x30313050
                  -> p010le.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x36313050
                  -> unknown.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x30323449
                  -> yuv420p.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x32315659
                  -> yuv420p.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x56595559
                  -> unknown.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x32595559
                  -> yuyv422.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x59565955
                  -> uyvy422.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x41524742
                  -> bgra.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x41424752
                  -> rgba.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x58524742
                  -> bgr0.<br>
                  [AVHWDeviceContext @ 0xf925c00] Format 0x58424752
                  -> rgb0.<br>
                  [AVHWDeviceContext @ 0xf925c00] VAAPI driver: Mesa
                  Gallium driver 22.1.7 for NV106.<br>
                  [AVHWDeviceContext @ 0xf925c00] Driver not found in
                  known nonstandard list, using standard behaviour.<br>
                  [AVHWFramesContext @ 0xea43980] Created surface 0x1.<br>
                  [AVHWFramesContext @ 0xea43980] Direct mapping
                  possible.<br>
                  [av1_vaapi @ 0xf978680] Input surface format is
                  p010le.<br>
                  [av1_vaapi @ 0xf978680] Compatible profile
                  VAProfileAV1Profile0 (32) is not supported by driver.<br>
                  [av1_vaapi @ 0xf978680] No usable encoding profile
                  found.<br>
                  FFMPEG::open_encoder  err: Function not implemented<br>
                  int FFMPEG::open_encoder(const char*, const char*):<br>
                  open failed
                  av1_vaapi:/dev/shm/yuv-test-reenc-rgba8-mpeg-range.webm<br>
                  Render::render_single: Session finished.<br>
                  Total excess of backups: -50<br>
                  [AVIOContext @ 0xeaf1aa40] Statistics: 4570842 bytes
                  read, 5 seeks<br>
                  [AVIOContext @ 0xeaf348c0] Statistics: 2997978 bytes
                  read, 2 seeks<br>
                  [AVIOContext @ 0xd7aa8900] Statistics: 4272574 bytes
                  read, 2 seeks<br>
                  [AVIOContext @ 0xd7954080] Statistics: 2997978 bytes
                  read, 2 seeks<br>
                  [AVIOContext @ 0xf40c2840] Statistics: 9351290 bytes
                  read, 18 seeks<br>
                  [AVIOContext @ 0xf4008a00] Statistics: 2997978 bytes
                  read, 2 seeks<br>
                  Session time: 0:00:48<br>
                  Cpu time: user: 0:00:09.659 sys: 0:00:03.077<br>
                </div>
                <div><br>
                </div>
                <div>so i guess it sets surface format now correctly,
                  just no encoder entrypoint (obviously on my hw)?<br>
                </div>
                <div> </div>
                <div>Terje, Andrea - can you test this hack ?<br>
                </div>
                <div><br>
                </div>
              </div>
            </div>
          </blockquote>
          <div><br>
          </div>
          <div>one more time, this time with env variable</div>
          <div><br>
          </div>
          <div> CIN_10BIT_ENC=1  bin/cin  ~/6029.mp4     <br>
          </div>
          <div><br>
          </div>
          <div>should enable P010LE input surface format ...but you
            probably need to set profile etc manually?<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>