ffmpeg using radeonsi vaapi on Polaris21 RX560 creates h264 steams not playable by gstreamer & hw players
Submitted by Luke McKee
Assigned to Default DRI bug account
Link to original bug (#105277)
Description
Created attachment 137664 Royalty free big buck bunny 30 second video file corrupted by mesa-git ;)
This ticket relates to a comment on a closed bug: https://bugs.freedesktop.org/show_bug.cgi?id=104920#c3
Hardware required to replicate: RX560, sys-kernel/linux-firmware-20180213::gentoo, ATOM BIOS: 113-C98121-M01, amd-staging latest kernel & mesa-git.
There is some corruption when creating mkv,mp4 or any container in ffmpeg/ffmpeg-git using vaapi to encode. When I used libx264 with exactly the same settings as the encoder (no bframes, constrained baseline etc) the content is playable on hardware players and gstreamer, however when vaapi is used to use the encoding the content is scrambled on hardware players (TCL TV) and gstreamer's qtdemux can not parse the stream. vlc's player always skips the first two frames too.
The error exists regardless of the scale filter, I was originally testing on much higher bitrate source material.
Sample video file used: https://download.blender.org/peach/bigbuckbunny_movies/
What works with gstreamer/totem & hw players (x264 not relating to mesa) ffmpeg-git -hwaccel vaapi -hwaccel_output_format vaapi -t 30 -i big_buck_bunny_720p_surround.avi -vf scale_vaapi=w=1366:h=768,hwdownload,format=nv12 -c:v libx264 -b:v 2000k -coder:v 0 -bf 0 -profile:v baseline -level 3.1 -c:a aac -ac 2 -b:a 128k -ar 48000 -movflags +faststart -x264-params opencl x264test.mp4
What doesn't:
ffmpeg-git -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -t 30 -i big_buck_bunny_720p_surround.avi -vf scale_vaapi=w=1366:h=768 -c:v h264_vaapi -b:v 2000k -qp 20 -bf 0 -profile:v constrained_baseline -movflags +faststart -quality:v 0 -level:v 3.1 -coder:v cavlc -c:a aac -ab 128k -ar 48000 -ac 2 vaapitest.mp4
Comparing the output of ffprobe -show_format -show_streams shows the files are nearly identical.
diff x264test.txt vaapitest.txt 27,28c27,28 < is_avc=true < nal_length_size=4
is_avc=false nal_length_size=0 37c37 < bit_rate=2142956
bit_rate=2153505 102c102 < filename=x264test.mp4
filename=vaapitest.mp4 109,110c109,110 < size=8535782 < bit_rate=2274540
size=8575301 bit_rate=2285071
I am using amd-gpu-staging-next from 2 days ago 4.15-rc4 after the old powerplay cleanup commit, and mesa-git from today.
Attachment 137664, "Royalty free big buck bunny 30 second video file corrupted by mesa-git ;)":
vaapitest
Version: git