[FFmpeg-user] H264 VAAPI Encoder

On 13/05/16 20:43, Armin K. wrote: > I noticed that recently a VAAPI based H264 encoder was added to ffmpeg. > I built ffmpeg from git and now I have h264_vaapi listed in ffmpeg -encoders > output. > > However, when I try to use ffmpeg ... -vcodec h264_vaapi I get the following > error: > > Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto-inserted scaler 0' > > The command I use is: > > ffmpeg -hwaccel vaapi -i <inputfile> -vcodec h264_vaapi <outfile>.mkv Short answer: ffmpeg -vaapi_device /dev/dri/renderD128 -i <inputfile> -vf 'format=nv12,hwupload' -c:v h264_vaapi <outfile>.mkv Longer answer: It's somewhat awkward to use because it only accepts input as VAAPI surfaces (AV_PIX_FMT_VAAPI), with underlying format depending on the particular hardware. "-vaapi_device" sets the hardware device to use. It takes either a DRI device (ideally a render node, as above) or an X11 display name (only if you are actually in X). Then we use libavfilter to get the input into the right form: "format=nv12" forces software conversion to NV12, which is the underlying format required by the Intel driver. "hwupload" uploads that software image into a VAAPI surface, which can then be fed into the encoder. You need a bit more trickiness to do a pure hardware transcode, see <https://wiki.libav.org/Hardware/vaapi> for additional explanation. - Mark