<p>I've been using ffmpeg on my laptop for some time and I could have sworn that <code>scale_vaapi</code> 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.</p>

<p>My attempted command is the following:</p>

<pre><code>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"
</code></pre>

<p>However this ends up giving me the following error:</p>

<p><code>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!
</code></p>

<p>Removing <code>flags=nearest</code> 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?</p>

CC BY-SA 4.0
2019-05-01T18:40:32.020Z
The VAAPI scaler does not have a neighbor/point mode. The [scale_npp](https://ffmpeg.org/ffmpeg-filters.html#scale_005fnpp) filter does.
Gyan
CC BY-SA 4.0
2019-05-01T18:43:11.280Z
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
CC BY-SA 4.0
2019-05-01T19:01:46.460Z
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
CC BY-SA 4.0
2019-05-01T19:24:59.653Z
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
CC BY-SA 4.0
2019-05-02T04:46:11.713Z
Encoding a hi-res video certainly benefits from h/w accel provided you are satisfied with the quality.
Gyan
<ffmpeg><libav>
ffmpeg: VAAPI can't do nearest neighbor scaling?
Mike_IronFist
# ffmpeg: VAAPI can't do nearest neighbor scaling?

(Asked by: username_0 on 2019-05-01)

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?

**Tags:** ffmpeg, libav

> **Comments:**
> **username_1**: The VAAPI scaler does not have a neighbor/point mode. The [scale_npp](https://ffmpeg.org/ffmpeg-filters.html#scale_005fnpp) filter does.  
> **username_0**: 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?  
> **username_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.  
> **username_0**: 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?  
> **username_1**: Encoding a hi-res video certainly benefits from h/w accel provided you are satisfied with the quality.  

---

## 0 answers

