0

This command, make videos to be padded first and then scale them afterwards. However, i want exactly the opposite, first to scale them and then to pad them. How I can do that?

rm a_*.mp4; for vids in *.mp4; do ffmpeg -hwaccel vaapi -hwaccel_output_format yuv420p -vaapi_device /dev/dri/renderD128 -i "$vids" -ss 0:00:00 -to 00:00:03  -vf  "format=nv12, pad=1080:1920:ow/2:oh/2:color=red, hwupload, scale_vaapi=w=1920:h=1080:format=nv12"  -c:v hevc_vaapi -video_track_timescale 90000 -rc_mode CQP -global_quality 20 -an "a_${vids/.*}.mp4"; done;

The error message is that:

Impossible to convert between the formats supported by the filter 'Parsed_scale_vaapi_2' and the filter 'auto_scale_1'

I tried this too but failed:

rm a_*.mp4; for vids in *.mp4; do ffmpeg -hwaccel vaapi -hwaccel_output_format yuv420p -vaapi_device /dev/dri/renderD128 -i "$vids" -ss 0:00:00 -to 00:00:03  -vf  "hwupload, scale_vaapi=w=1920:h=1080:format=nv12, hwdownload, pad=1080:1920:ow/2:oh/2:color=red"  -c:v hevc_vaapi -video_track_timescale 90000 -rc_mode CQP -global_quality 20 -an "a_${vids/.*}.mp4"; done;

UPDATE

I succeded with scale but not with scale_vaapi:

rm a_*.mp4; for vids in *.mp4; do ffmpeg -hwaccel vaapi -hwaccel_output_format yuv420p -vaapi_device /dev/dri/renderD128 -i "$vids" -ss 0:00:00 -to 00:00:03  -vf  "format=nv12, scale=height=1920:width=1080, pad=height=1920:width=1080:color=red,hwupload"  -c:v hevc_vaapi -video_track_timescale 90000 -rc_mode CQP -global_quality 20 -an "a_${vids/.*}.mp4"; done;
7
  • Try: ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i input.mp4 -ss 0:00:00 -to 00:00:03 -vf "scale_vaapi=w=1920:h=1080:format=nv12,hwdownload, pad=2048:1080:ow/2:oh/2:color=red,hwupload" -c:v hevc_vaapi -video_track_timescale 90000 -rc_mode CQP -global_quality 20 -an output.mp4. Try with the following input: ffmpeg -y -f lavfi -i testsrc=size=384x216:rate=1:duration=10 -pix_fmt yuv420p input.mp4. I can't test it because I am not running linux.
    – Rotem
    Commented Jun 4 at 19:01
  • Impossible to convert between the formats supported by the filter 'transpose' and the filter 'auto_scale_0' Commented Jun 4 at 19:06
  • Did you try it with input.mp4 that was created with ffmpeg -y -f lavfi -i testsrc=size=384x216:rate=1:duration=10 -pix_fmt yuv420p input.mp4? I can't test it...
    – Rotem
    Commented Jun 4 at 19:09
  • The idea is to use a single command, and not to rencode it twice. Otherwise, i know the solution. Commented Jun 4 at 19:51
  • I am not sure that there is one solution that fits all cases (that is because hardware accelerated transcoding has many limitations compared to software transcoding). The transpose filter for example, is added automatically because the rotation metadata is not zero. Possible solution is adding -noautorotate and copy the rotation metadata (we may also use transpose_vaapi, if we know that we have to rotate). We don't have your MP4 files, so we can't reproduce the issues. Without any information about the input files, I find your question to be too general.
    – Rotem
    Commented Jun 4 at 21:25

0

You must log in to answer this question.

Browse other questions tagged .