ros-misc-utilities / ffmpeg_image_transport

ROS2 image transport plugin for encoding/decoding with h264 codec
Apache License 2.0
65 stars 22 forks source link

h264_vaapi #13

Closed fferroni closed 11 months ago

fferroni commented 11 months ago

Hi, Have you ever tried using h264_vaapi as an encoder? It doesn't seem to accept preset options. https://trac.ffmpeg.org/wiki/Hardware/VAAPI#Mappingoptionsfromlibx264

berndpfrommer commented 11 months ago

I have never tried vaapi. What error are you getting? From looking at the code, it should continue even if setting the preset returns an error. What's not working?

fferroni commented 11 months ago

It complains that it does not accept preset as a parameter. With h264_vaapi the ffmpeg commands usually look like

ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12|vaapi,hwupload' -vcodec h264_vaapi -rc vbr -cq 50 output.mp4

since it uses Intel hw accelerators

berndpfrommer commented 11 months ago

The encoding looks quite different from what worked for nvenc. Here is an example of vaapi encoding: https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/vaapi_encode.c

berndpfrommer commented 11 months ago

I added support for VAAPI. Tested on AMD laptop.