Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8376 closed defect (invalid)

hevc_vaapi loses aspect ratio during encoding

Reported by: Evren Yurtesen Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

I am using ffmpeg version 4.1.4-1build2 with Radeon RX570 which supports HEVC encoding through VAAPI. I can test a more recent build if required.

When VAAPI is used the aspect ratio setting is lost. 720x576 (AR 16:9) video enters and output is only 720x576. So the players show it with wrong aspect ratio.

Using --aspect option does not seem to have any effect output file.

libva info: VA-API version 1.5.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_5
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.5 (libva 2.5.0)
vainfo: Driver version: Mesa Gallium driver 19.2.1 for Radeon RX 570 Series (POLARIS10, DRM 3.33.0, 5.3.0-19-generic, LLVM 9.0.0)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

Here is a 6MB test file (720x576 (AR 16:9)) (~6mb)
https://drive.google.com/file/d/1-IDAYhfj93aPJPizWKttpfGV-KVPKKSx/view

The output file ends up as (720x576) only without AR setting. (~1mb)
https://drive.google.com/file/d/1mHbzcrAbN2zHVCgEkUTlqTDyCyC6yvPw/view

How to reproduce:

/usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -i yks.ts -vf 'yadif,format=nv12,hwupload' -c:v h264_vaapi -c:a copy out.ts
ffmpeg version 4.1.4-1build2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.2.1-4ubuntu1)
  configuration: --prefix=/usr --extra-version=1build2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mpegts @ 0x560df48a61c0] PES packet size mismatch
Input #0, mpegts, from 'yks.ts':
  Duration: 00:00:10.85, start: 31818.542544, bitrate: 5027 kb/s
  Program 1
    Metadata:
      service_name    : Liv
      service_provider: Nelonen
    Stream #0:0[0x204]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt470bg, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x2b2](fin): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
File 'out.ts' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264_vaapi @ 0x560df48adc80] Driver does not support some wanted packed headers (wanted 0xd, found 0).
Output #0, mpegts, to 'out.ts':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (h264_vaapi) (High), vaapi_vld, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.35.100 h264_vaapi
    Stream #0:1(fin): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
[mpegts @ 0x560df48a61c0] PES packet size mismatch:00:10.52 bitrate=2790.9kbits/s speed=6.98x
frame=  261 fps=168 q=-0.0 Lsize=    3942kB time=00:00:10.80 bitrate=2990.2kbits/s speed=6.95x
video:3372kB audio:248kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.896013%

Attachments (2)

yks.ts (1.0 MB ) - added by Evren Yurtesen 4 years ago.
Original file
out.ts (985.0 KB ) - added by Evren Yurtesen 4 years ago.
VAAPI encoded file

Download all attachments as: .zip

Change History (11)

by Evren Yurtesen, 4 years ago

Attachment: yks.ts added

Original file

by Evren Yurtesen, 4 years ago

Attachment: out.ts added

VAAPI encoded file

comment:1 by Evren Yurtesen, 4 years ago

Looks like I put wrong output to original post. Here is the output with files attached to the bugreport

$ /usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -i yks.ts -vf 'format=nv12,hwupload' -c:v hevc_vaapi -qp 30 -c:a copy out.ts
ffmpeg version 4.1.4-1build2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.2.1-4ubuntu1)
  configuration: --prefix=/usr --extra-version=1build2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mpegts, from 'yks.ts':
  Duration: 00:00:10.84, start: 1.400000, bitrate: 776 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 25 tbc
    Stream #0:1[0x101](fin): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_vaapi))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hevc_vaapi @ 0x561daf05c740] Driver does not support some wanted packed headers (wanted 0xd, found 0).
Output #0, mpegts, to 'out.ts':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: hevc (hevc_vaapi) (Main), vaapi_vld, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.35.100 hevc_vaapi
    Stream #0:1(fin): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
frame=  261 fps=0.0 q=-0.0 Lsize=     985kB time=00:00:10.80 bitrate= 747.1kbits/s speed=17.4x
video:634kB audio:248kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 11.766870%

comment:2 by Evren Yurtesen, 4 years ago

Version: 4.1.4git-master

Tested with git-master and same problem exists (using same test file):

 ./ffmpeg -vaapi_device /dev/dri/renderD128 -i yks.ts -vf 'format=nv12,hwupload' -c:v hevc_vaapi -qp 30 -c:a copy out.ts
ffmpeg version N-95710-gb25b6432a7 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-23ubuntu2)
  configuration: --enable-vaapi
  libavutil      56. 35.101 / 56. 35.101
  libavcodec     58. 61.100 / 58. 61.100
  libavformat    58. 34.101 / 58. 34.101
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 66.100 /  7. 66.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
Input #0, mpegts, from 'yks.ts':
  Duration: 00:00:10.84, start: 1.400000, bitrate: 776 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 25 tbc
    Stream #0:1[0x101](fin): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_vaapi))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hevc_vaapi @ 0x55980faa94c0] Driver does not support some wanted packed headers (wanted 0xd, found 0).
Output #0, mpegts, to 'out.ts':
  Metadata:
    encoder         : Lavf58.34.101
    Stream #0:0: Video: hevc (hevc_vaapi) (Main), vaapi_vld, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.61.100 hevc_vaapi
    Stream #0:1(fin): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
frame=  261 fps=0.0 q=-0.0 Lsize=     969kB time=00:00:10.80 bitrate= 735.3kbits/s speed=16.2x
video:634kB audio:248kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.996099%

Last edited 4 years ago by Evren Yurtesen (previous) (diff)

comment:3 by Carl Eugen Hoyos, 4 years ago

Keywords: amd hevc mesa radeon removed

How is this ticket different than #6276?

in reply to:  3 comment:4 by Evren Yurtesen, 4 years ago

Replying to cehoyos:

How is this ticket different than #6276?

Simply because the issues look similar but could be different because I am running ffmpeg with AMD hardware and the owner of ticket #6276 was using Nvidia hardware.

This issue happened on AMD hardware only with VAAPI and it has nothing to do with nvenc

As AMD's implementation may have differences, fixing this issue may or may not effect the issue on Nvidia hardware.

In addition, I have tested this issue on latest master. That ticket was on 3.x version and not tested since then. It may even be possible that ticket #6276 is fixed. We do not know.

comment:5 by Carl Eugen Hoyos, 4 years ago

Keywords: vaapi aspect removed
Resolution: duplicate
Status: newclosed

in reply to:  5 comment:6 by Evren Yurtesen, 4 years ago

Replying to cehoyos:
Why is this ticket duplicate? Can you explain it? Isn't it a valid assumption that VAAPI on AMD Platform may be having different quirks?

I am here right now, I provided smaller test files. As a matter of fact, the test file in ticket #6276 is not even reachable right now. So there is not even possibility of testing the issue in exact same environment.

That ticket was opened against a very old version of FFMPEG and it should be closed at least due to that reason. Also the owner of the ticket does not seem to respond anymore.

So I believe the correct decision would have been closing the old ticket and proceeding with this ticket which has newer information.

Last edited 4 years ago by Evren Yurtesen (previous) (diff)

in reply to:  5 comment:7 by tvsht, 4 years ago

Replying to cehoyos:

Linked duplicated bug is for variable ratio video files, where ratio changes during. This bug is for constant radio video.

I have same bug but ended posting in the "duplicate" one

comment:8 by jkqxz, 4 years ago

Isn't the problem here the lack of packed headers in the Mesa driver?

The message

[hevc_vaapi @ 0x55980faa94c0] Driver does not support some wanted packed headers (wanted 0xd, found 0).

is basically telling you that libavcodec not going to be able to write any header metadata, and that means you don't get any VUI aspect ratio information (among other things).

comment:9 by Carl Eugen Hoyos, 4 years ago

Resolution: duplicateinvalid
Note: See TracTickets for help on using tickets.