[FFmpeg-devel] Specifying crop parameters while encoding using vaapi

Mark Thompson sw at jkqxz.net
Mon Jul 27 17:54:14 EEST 2020


On 27/07/2020 00:55, Satyajit Sahu wrote:
> Hi,
> 
> 
> 
> I am facing issue with cropping parameters while transcoding. The cropping
> parameters are ignored if both the way vaapi hw acceleration is used (for
> decoding and encoding). But if sw decoding is used the cropping parameters
> are working fine.
> 
> 
> 
> For below command cropping parameters are ignored.
> 
> ffmpeg -y -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device
> /dev/dri/renderD128 -i 480p.mkv -vf "fps=23.976,crop=640:400:0:139" -bf 0
> -c:v h264_vaapi -b:v 6706k -pass 1 -an -f mp4 test.mp4
> 
> 
> 
> Warning message : “[h264_vaapi @ 0x5617a44844c0] Cropping information on
> input frames ignored due to lack of API support."
> 
> 
> 
> But when sw decoding is used cropping works properly
> 
> ffmpeg -vaapi_device /dev/dri/renderD128 -i 480p.mkv -vf
> 'format=nv12,fps=23.97,crop=640:400:0:139,hwupload' -c:v h264_vaapi test.mp4
> 
> 
> 
> Also able to encode with cropping parameters from raw yuv file using vaapi
> hw encode.
> 
> Is this some limitation from ffmpeg or the command is not proper?

VAAPI does not support cropping applied to the input surface of an encoder like this, but it does for filtering.

So, you can insert a scale filter (not actually doing any scaling) to make a surface suitable for encoding input with the cropping applied.

-vf "fps=23.976,crop=640:400:0:139,scale_vaapi=640:400"

- Mark

PS:  Please direct any future questions about using ffmpeg to the ffmpeg-user mailing list.  This the development list.


More information about the ffmpeg-devel mailing list