Announcement

Collapse
No announcement yet.

AMD VCE + FFMPEG + OBS Studio

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

  • AMD VCE + FFMPEG + OBS Studio

    Hey Guys,

    is there a way to...

    * Make use of VCE in it's current state under Linux?
    * Use VCE with FFMPEG to encode Screen Recording with a hardware codec to h.264 codec?
    * Use this setup with OBS Studio?

    Thanks,
    cRaZy
    Last edited by cRaZy-bisCuiT; 12-12-2016, 12:51 PM.

  • #2
    VCE (H.264 encode hw) is currently exposed via openmax and vaapi.
    Last edited by agd5f; 12-12-2016, 03:52 PM. Reason: clarify

    Comment


    • #3
      Well, thank you! Do you know if it's possible to make advantage of this by using FFMPEG?

      Comment


      • #4
        Actually it's working for me:

        Code:
        ffmpeg -vaapi_device /dev/dri/card1 -i input.mp4 -vf 'format=nv12,hwupload' -c:v h264_vaapi output.mkv
        Now I do wonder how to use this in OBS. There's a possibility to set "Custom Output (FFmpeg)". I set "Container Format" to "flv" and "Video Encoder" to "h264_vaapi (libx264). Unfortunately I get the following error message:

        warning: Failed to open video codec: Invalid argument
        warning: ffmpeg_data_init failed
        Any ideas?

        I also have the possibility to set "Video Encoder settings (if any)" - but I have no idea what to specify over there....

        Comment


        • #5
          I can't get it to work on my 480 with the software versions I have. Could you share your installed versions?

          Mine are: libdrm-amdgpu1 2.4.74; xserver-xorg-video-amdgpu 1.2.0; mesa 13.0.2; libva 1.7.3 (va-api 0.39.4); ffmpeg 3.2.2. All on debian testing.

          The issue is that ffmpeg doesn't find the driver and when I override it, it fails to init:
          Code:
          libva info: va_getDriverName() returns -1
          libva info: User requested driver 'radeonsi'
          libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
          libva info: Found init function __vaDriverInit_0_39
          amdgpu: amdgpu_device_initialize failed.
          do_winsys_init: DRM version is 3.3.0 but this driver is only compatible with 2.12.0 (kernel 3.2) or later.
          After init fails, it then goes on to try radeon instead of amdgpu which fails.

          vainfo is working:
          Code:
          libva info: VA-API version 0.39.4
          libva info: va_getDriverName() returns 0
          libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
          libva info: Found init function __vaDriverInit_0_39
          libva info: va_openDriver() returns 0
          vainfo: VA-API version: 0.39 (libva 1.7.3)
          vainfo: Driver version: mesa gallium vaapi
          vainfo: Supported profile and entrypoints
               VAProfileMPEG2Simple            : VAEntrypointVLD
               VAProfileMPEG2Main              : VAEntrypointVLD
               VAProfileVC1Simple              : VAEntrypointVLD
               VAProfileVC1Main                : VAEntrypointVLD
               VAProfileVC1Advanced            : VAEntrypointVLD
               VAProfileH264ConstrainedBaseline: VAEntrypointVLD
               VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
               VAProfileH264Main               : VAEntrypointVLD
               VAProfileH264Main               : VAEntrypointEncSlice
               VAProfileH264High               : VAEntrypointVLD
               VAProfileH264High               : VAEntrypointEncSlice
               VAProfileHEVCMain               : VAEntrypointVLD
               VAProfileHEVCMain10             : VAEntrypointVLD
               VAProfileNone                   : VAEntrypointVideoProc



          Comment


          • #6
            Hi RemcoL,

            I do use Manjaro Unstable (= Arch Stable). I'm not at home right now but you could check those packages [0] by yourself if you like. I could also give you those information later.

            Anyway, did you try to use the same command as I did? I remember I had the same trouble, I'm just not quite sure what I did do to fix it. I'm still thinking about it. I also did not try diffent options regarding profiles, quality, bitrate, file size etc. - I do just see this as a prove that it should work.

            Do you have any idea how to make use of that by using OBS? If I do use software encoding my 3570k is busy with at least 25 % with "very fast".

            [0] https://www.archlinux.org/packages/

            Comment


            • #7
              Alright, so I tried some other things. Most important difference is that I have to use /dev/dri/renderD128. Also I get output that says that b-frames are not supported so I had to add -bf 0. With that the command becomes:
              Code:
              LIBVA_DRIVER_NAME=radeonsi ffmpeg -loglevel debug -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -vcodec h264_vaapi -bf 0 output.mp4
              That goes on to do a lot of things, but after some frames it hangs on "ioctl(5, DRM_IOCTL_AMDGPU_WAIT_CS" (from strace). Full ffmpeg log is at http://pastebin.com/iq8febXN (which the pastebin mangled, but oh well)

              What's worse is that the first time I tried to kill the process, it hung the X server and I had to reboot. On second try a SIGABRT worked, but a third try locked the X server again. So unfortunately it doesn't work for me

              As for using it with OBS, you might be able to use the recording output to use the h264_vaapi encoder and then sending it to twitch manually. Otherwise you'll need to patch OBS to have it available in the streaming encoder dropdown. Also https://wiki.archlinux.org/index.php...mpeg_solutions uses ffmpeg directly for streaming, which you might be able to use for hints for the OBS setup.

              Comment


              • #8
                I don't have any ideas how to fix your setup, thanks!

                Mhhh even for recording I'm not sure how to configure OBS to get it working recording my videos with h264_vaapi ...

                Comment


                • #9
                  Originally posted by RemcoL View Post
                  Alright, so I tried some other things. Most important difference is that I have to use /dev/dri/renderD128. Also I get output that says that b-frames are not supported so I had to add -bf 0. With that the command becomes:
                  Code:
                  LIBVA_DRIVER_NAME=radeonsi ffmpeg -loglevel debug -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -vcodec h264_vaapi -bf 0 output.mp4
                  That goes on to do a lot of things, but after some frames it hangs on "ioctl(5, DRM_IOCTL_AMDGPU_WAIT_CS" (from strace). Full ffmpeg log is at http://pastebin.com/iq8febXN (which the pastebin mangled, but oh well)

                  What's worse is that the first time I tried to kill the process, it hung the X server and I had to reboot. On second try a SIGABRT worked, but a third try locked the X server again. So unfortunately it doesn't work for me
                  I was trying to do something very similar on Debian testing recently, and it just hangs. Trying to kill it doesn't work and after that I can't even reboot the system properly. Here is what I did:

                  Code:
                  LIBVA_DRIVER_NAME=radeonsi ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -framerate 30 -video_size 1920x1200 -f x11grab -i :0.0 -f pulse -ac 2 -i 1 -vf 'format=nv12,hwupload' -threads 8 -vcodec h264_vaapi -bf 0 -acodec pcm_s16le output.mkv
                  Is it a bug in Mesa? If so, I can report it.

                  Comment


                  • #10
                    Recently I found out that if I set VLC to decode using "VA-API video decoder via DRM" it wouldn't work, while the one with "via X11" works fine. So I suspect that ffmpeg uses the DRM method to encode as well and that's why it fails.

                    On the other side, I was pointed to https://github.com/ChristophHaag/scr...er/vorecord.sh which uses gstreamer. And that works fine for me. Quality kinda sucks and bitrate controls are horrible, but it works. If someone has the time (and knowledge) to find out exactly what is going on, that would be awesome since ffmpeg is integrated in so many places nowadays. That's not me however.

                    Comment

                    Working...
                    X