Opened 2 years ago

Last modified 5 months ago

#6276 new defect

h264_vaapi & nvenc do not preserve aspect ratio changes

Reported by: Tom_B Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: vaapi nvenc aspect
Cc: zhuqingliang Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

ffmpeg output:

ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers

built with gcc 6.3.1 (GCC) 20170109
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

Command:

ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i input.ts -y -g 30 -vf 'format=nv12,hwupload' -c:v h264_vaapi -qp 20 -sn out.ts

The input file is available at https://r.je/tmp/input.ts (apologies this is a 900mb file) with a change in aspect ratio from 16:9 to 4:3 at 3:28

When using h264_vaapi as the codec, it doens't maintain the aspect ratio change, however the aspect ratio change is maintained if using libx264

Using libx264, the aspect change is copied into the output file.

Note: The same bug happens when using h264_nvenc.

Attachments (1)

aspect_ratio_change_cut.ts (2.4 MB) - added by cehoyos 7 months ago.
Sample from ticket #3631

Change History (8)

comment:1 Changed 7 months ago by zhuqingliang

I try to reproduce this issue on my platform , but can't download https://r.je/tmp/input.ts , can you upload it again?

comment:2 follow-up: Changed 7 months ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords ratio removed

Looks a little invalid as two bugs are reported, neither against current FFmpeg git head...

Changed 7 months ago by cehoyos

Sample from ticket #3631

comment:3 in reply to: ↑ 2 ; follow-up: Changed 7 months ago by zhuqingliang

Replying to cehoyos:

I test with

ffmpeg  -i aspect_ratio_change_cut.ts -vf fps=1 out_%3d.jpeg

and the out_0001.jpeg out_0002.jpeg out_0003.jpeg out_0004.jpeg is 720x576 , is it means this issue persists in master?

comment:4 in reply to: ↑ 3 ; follow-up: Changed 7 months ago by cehoyos

Replying to zhuqingliang:

Replying to cehoyos:

I test with

ffmpeg  -i aspect_ratio_change_cut.ts -vf fps=1 out_%3d.jpeg

The command line above looks different, what are you trying to test?

comment:5 in reply to: ↑ 4 Changed 7 months ago by zhuqingliang

I try to reproduce this issue: "h264_vaapi & nvenc do not preserve aspect ratio changes".

comment:6 follow-up: Changed 6 months ago by cehoyos

  • Cc zhuqingliang added
  • Component changed from undetermined to avcodec

Then why did you test with a different command line?

comment:7 in reply to: ↑ 6 Changed 5 months ago by zhuqingliang

Replying to cehoyos:

Then why did you test with a different command line?

because when I tried with

ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i aspect_ratio_change_cut.ts -y -g 30 -vf 'format=nv12,hwupload' -c:v h264_vaapi -qp 20 -sn out.ts 

failed with error message

[AVHWFramesContext @ 0x556ae298be00] Failed to sync surface 0x4: 23 (internal decoding error).
[mpeg2video @ 0x556ae2707440] Failed to transfer data to output frame: -5.
Note: See TracTickets for help on using tickets.