0

I've been using ffmpeg on my laptop for some time and I could have sworn that scale_vaapi had an option to set the flags to nearest neighbor. I need nearest neighbor scaling because I'm converting low-res direct capture video game footage and need to preserve the sharpness of the pixels.

My attempted command is the following:

ffmpeg -hide_banner -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i "/home/mike/Videos/CAPTURE.mp4" -n -c:v h264_vaapi -b:v 14M -vf format=nv12,hwupload,scale_vaapi=iw*3:ih*3:flags=nearest "/home/mike/Desktop/CAPTURE.converted.mp4"

However this ends up giving me the following error:

Parsed_scale_vaapi_2 @ 0x557e347c5500] Option 'flags' not found [AVFilterGraph @ 0x557e34b3b780] Error initializing filter 'scale_vaapi' with args 'iw*3:ih*3:flags=nearest' Error reinitializing filters! Failed to inject frame into filter network: Option not found Error while processing the decoded data for stream #0:0 [aac @ 0x557e347a7640] Qavg: 171.142 [aac @ 0x557e347a7640] 2 frames left in the queue on closing Conversion failed!

Removing flags=nearest will allow it to run the conversion just fine but it won't force nearest neighbor scaling and I really want to avoid billinnear filtered pixels for my retro game footage without having to wait ten years for software rendering to complete. Any ideas?

  • 1
    The VAAPI scaler does not have a neighbor/point mode. The scale_npp filter does. – Gyan May 1 '19 at 18:40
  • Thank you. So, to follow up: if I don't have access to my desktop machine and end up stuck with my laptop (which only has Intel integrated graphics) what are my options? If I have to use software scaling, what's the most efficient way to include it in the transcoding process? – Mike_IronFist May 1 '19 at 18:43
  • 1
    ffmpeg's s/w scaler with flags=neighbor benches around 210 fps for me from 720p to 2160p on an old CPU - Ivy bridge. It will likely not be the bottleneck or at least not a major one. – Gyan May 1 '19 at 19:01
  • Thanks again for the info, that sounds good. Is it possible to use the software scaler alongside VAAPI or would it be more efficient to just do the whole thing in software if I'm scaling it on my CPU anyway? – Mike_IronFist May 1 '19 at 19:24
  • Encoding a hi-res video certainly benefits from h/w accel provided you are satisfied with the quality. – Gyan May 2 '19 at 4:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.