Announcement

Collapse
No announcement yet.

H.264 VA-API Encode Comes To Gallium3D

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by legume View Post
    Hmm, what does gstreamer say if you try to use it?
    Code:
    LC_ALL=C DRI_PRIME=1 LIBVA_DRIVER_NAME=radeonsi gst-launch-1.0 videotestsrc ! omxh264enc ! "video/x-h264,profile=high" ! h264parse ! matroskamux ! filesink location=output.mkv
    
    Setting pipeline to PAUSED ...
    OMX-could not load /usr/lib/bellagio/libomxvideosched.so ==> OMX.st.video.scheduler ==> OMX.st.video.scheduler: ==> 2 1,456192 1,304128: /usr/lib/bellagio/libomxvideosched.so ==> OMX.st.video.scheduler ==> OMX.st.video.scheduler: ==> 2 1,456192 1,304128: cannot open shared object file: No such file or directory
    Pipeline is PREROLLING ...
    OMX-In RM_getResource No resource to be handled
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    As I said, it tries to open the whole "/usr/lib/bellagio/libomxvideosched.so ==> OMX.st.video.scheduler ==> OMX.st.video.scheduler: ==> 2 1,456192 1,304128" thing as a filename, see the first line in my .omxregister.

    But I noticed it DOES produce an output file. It plays very slowly for some reason and mpv prints
    Invalid video timestamp: 1.633000 -> 1.567000
    every frame, but it seems to work otherwise.

    I suppose that it didn't really work earlier whenever I tried, because the color format was wrong. With I420 I really get a data flow error with omxh264enc.
    I just tried the equivalent:
    DRI_PRIME=1 gst-launch-1.0 ximagesrc display-name=:0 use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! queue ! videoconvert ! queue ! video/x-raw,format=NV12,framerate=30/1 ! omxh264enc ! "video/x-h264,profile=high" ! h264parse ! matroskamux ! filesink location=output.mkv
    and it produces this video:
    https://youtu.be/mbGDPtVIt9I
    25-30% CPU load and heavy artifacting, but it works.

    Comment


    • #32
      Ah, misread the question. Are you sure it copies right into the phoronix wysiwyg editor?
      With yours I get
      Code:
      LC_ALL=C DRI_PRIME=1 gst-launch-1.0 ximagesrc display-name=:0 use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! queue ! videoconvert ! queue ! video/x-raw,format=NV12,frame
      rate=30/1 ! omxh264enc ! "video/x-h264,profile=high" ! h264parse ! matroskamux ! filesink location=output.mkv
      Setting pipeline to PAUSED ...
      OMX-could not load ==> OMX.mesa.video_decoder ==> OMX.mesa.video_decoder.mpeg2:OMX.mesa.video_decoder.avc:: ==> OMX.mesa.video_decoder ==> OMX.mesa.video_decoder.mpeg2:OMX.mesa.video_decode
      r.avc:: cannot open shared object file: No such file or directory
      OMX-could not load ==> OMX.mesa.video_encoder ==> OMX.mesa.video_encoder.avc:: ==> OMX.mesa.video_encoder ==> OMX.mesa.video_encoder.avc:: cannot open shared object file: No such file or di
      rectory
      OMX-could not load ==> OMX.st.video.scheduler ==> OMX.st.video.scheduler: ==> 2 1,456192 1,304128: ==> OMX.st.video.scheduler ==> OMX.st.video.scheduler: ==> 2 1,456192 1,304128: cannot ope
      n shared object file: No such file or directory
      OMX-could not load ==> OMX.st.volume.component ==> OMX.st.volume.component: ==> 2 1,65536 1,32768: ==> OMX.st.volume.component ==> OMX.st.volume.component: ==> 2 1,65536 1,32768: cannot ope
      n shared object file: No such file or directory
      OMX-could not load ==> OMX.st.audio.mixer ==> OMX.st.audio.mixer: ==> 1 50,60000: ==> OMX.st.audio.mixer ==> OMX.st.audio.mixer: ==> 1 50,60000: cannot open shared object file: No such file
      or directory
      OMX-could not load ==> OMX.st.clocksrc ==> OMX.st.clocksrc:: ==> OMX.st.clocksrc ==> OMX.st.clocksrc:: cannot open shared object file: No such file or directory
      Pipeline is live and does not need PREROLL ...
      Setting pipeline to PLAYING ...
      New clock: GstSystemClock
      OMX-In RM_getResource No resource to be handled
      Also I think my previous post was not unapproved, but completely lost.
      Tl;dr was: I noticed it does indeed produce an output file and I think on my previous tries maybe it didn't because of the color format. I420 produces a data flow error, but converted to NV12 works. Here's a video: https://www.youtube.com/watch?v=mbGDPtVIt9I. 20-25% CPU usage and very artifact-y, but works.
      Last edited by haagch; 18 July 2016, 04:18 AM.

      Comment


      • #33
        Neither omx or vaapi currently do high - so try omitting the
        ! "video/x-h264,profile=high" ! It messes up my test with that command - though not in the same way as your vid = looked OK but very jerky + player moaning about invalid timestamps.

        Edit: forgot to say "20-25% CPU usage" is meaningless! Unless you know what freq it's running (assuming you use cpufreq)
        Last edited by legume; 18 July 2016, 05:58 AM.

        Comment


        • #34
          So it seems that both gstreamer screencap and bgr0 > nv12 conversion are faster that ffmpeg. So I can just cap at 1080p60 with omx. 68 fps seems to be my limit testing just cap /conversion like -

          time gst-launch-1.0 ximagesrc display-name=:0 num-buffers=600 use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! queue ! videoconvert ! queue ! video/x-raw,format=NV12,framerate=60/1 ! fakesink

          and increasing framerate + num-buffers=10*framerate and noting when time taken starts being > 10 seconds.

          To be fair to ffmpeg I don't know what either do in the conversion eg subsampling the chroma involves changing pixel positions and it could be the filter used is more complicated.
          Also I don't know what matrix gstreamer uses by default (should really check it's Rec.709 full -> limited as that's what players would tend to assume for the reverse for 1080p).

          By default omx will make fixed qp=28 though with the latest patches you can specify bitrates and it sort of works, though high fps can confuse things a bit.

          I don't know the capabilities of all VCE versions - I have a fast card = R9 285 Tonga. Though I can now do 1080p - I would still be constrained bu CPU capping if santa brought me a 2560x1440 oled monitor :-)

          FWIW benching from ramdisk 500 frames 2560x1440 raw nv12 with omx I get > 100fps conversion rate, so the GPU can do 1440p60 easily enough. (there's a bug which currently prevents testing 2160p).

          Here's the result of a test record to stress GL a bit + UVD as well as VCE with content that's not simple to encode, showing qp=28 may make big files as needed.

          The vid playing is roughly as high as h264 legally goes 2160p60 300mbit level 5.2 - I could never play that on CPU. vmp is just a bash alias for mpv which is doing an expensive hq scale down. (though ignore the colour quality as I messed up when making the master and was too lazy to do it all again).

          GPU + CPU set to perf everything cached in/going to ram.

          https://drive.google.com/file/d/0BxP...ew?usp=sharing


          Comment


          • #35
            Oh, I don't know where that came from. I copied stuff from the pipelines I used in earlier tries with omx and that must have snuck in there.

            Anyway, I tried
            gst-launch-1.0 ximagesrc display-name=:0 use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! queue ! videoconvert ! queue ! video/x-raw,format=NV12,framerate=30/1 ! omxh264enc ! h264parse ! matroskamux ! filesink location=output.mkv
            and it looks much better:
            https://youtu.be/Js4tviEMIQA

            It's a mobile Ivy Bridge i7 3632QM and its max clock speed is 3.2GHz with turbo boost. It wasn't meant as a very accurate measurement anyway, just that CPUs maybe 1/3 as powerful as mine should be able to handle it.

            If I just ignore the errors caused by my .omxregistry it works fine now.
            Thanks.

            Edit: The gstreamer-screenrecording is working fine too. And that definitely did not work when I last tried it.
            Edit: The colors look quote different from the intel vaapi recordings: https://www.youtube.com/watch?v=UA5PRrIrpVM. The green lines in the overlays noticeably brighter and the red is a lot more pale. But then it's fed with I420 to the intel encoder with vaapipostproc format=i420
            and converted to NV12 on the CPU for omx.
            Last edited by haagch; 18 July 2016, 11:41 AM.

            Comment


            • #36
              Strong green and red are the most noticeable difference between 601 and 709 mix ups. There's also the chance of some full range vs limited range difference.

              Not related to above as such, but do you have a sample made by intel h/w encode (that hasn't been recoded by youtube)? I am just curious what it looks like from an h264 point of view.

              Comment


              • #37
                vaapi: http://haagch.frickel.club/files/rec...-19_230813.mkv
                Code:
                gst-launch-1.0 -e ximagesrc display-name=:0 use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! multiqueue ! video/x-raw,format=BGRx,framerate=30/1 ! vaapipostproc format=i420 ! video/x-raw,format=I420,framerate=30/1 ! multiqueue ! vaapih264enc dct8x8=true ! h264parse ! multiqueue ! matroskamux name=muxer muxer. ! progressreport name=Rec_time ! filesink location=/home/chris/daten/rec_2016-07-19_230813.mkv
                omx: http://haagch.frickel.club/files/rec...-19_230855.mkv
                Code:
                gst-launch-1.0 -e ximagesrc display-name=:0 use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! multiqueue ! video/x-raw,format=BGRx,framerate=30/1 ! videoconvert ! video/x-raw,format=NV12,framerate=30/1 ! multiqueue ! omxh264enc ! h264parse ! multiqueue ! matroskamux name=muxer muxer. ! progressreport name=Rec_time ! filesink location=/home/chris/daten/rec_2016-07-19_230855.mkv
                Enjoy.

                Comment


                • #38
                  Thanks, so h264 is quite similar to omx, no b frames or cabac fixed qp, 26 for intel, 28 omx.

                  On the colors, looking at the yuv the intel is full range and by default players/vo will assume limited.

                  Correcting for that the colors are still different - so there some csc difference. The best way I could tell what's going on there is if you could set up the same "scene" and upload a screen shot made with -

                  xwd -root -out screenshot.xwd

                  TIA

                  Comment


                  • #39
                    I don't actually care that much. As far as I am concerned the GPU encoders aren't even trying to get a "faithful" encoding, just a very quick one. But if it's something in the setup, improvements are always nice.

                    Anyway, towards the end of both clips, both have a couple of seconds of the same view on the browser window. Yes, the mouse pointer and terminal window in the background may cause differences, but in general you can see the differences especially in the green colors and in the overall brightness of some colors, if you e.g. open them in two paused player windows, put them in fullscreen and switch between them.

                    Comment


                    • #40
                      Yea, I can clearly see the difference from pausing/overlaying in the first second, there are I guess other ways I can infer what matrix each is using, but by far the easiest would be if you could take a screenshot with xwd with the browser showing the content as it does at the start of the vids as I would then have the rgb values that were the starting point of the encode.

                      Correcting for intel using full range yuv brings the images close in some ways = the ramps and the border colors of the browser.

                      What you see may also vary depending on player and just to muddle things further, may also vary with the same player using different -vo methods.

                      mplayer tends not to use 709 unless you tell it with vdpau/gl but using pre glamor xv as vo would have got 709 as xv its self decided based on based on size (I am not sure if glamor xv does this).

                      In the absence of metadata mpv will choose based on size between 601 and 709.

                      Comment

                      Working...
                      X