<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - ffmpeg using radeonsi vaapi on Polaris21 RX560 creates h264 steams not playable by gstreamer & hw players"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=105277">105277</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ffmpeg using radeonsi vaapi on Polaris21 RX560 creates h264 steams not playable by gstreamer & hw players
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/Gallium/radeonsi
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hojuruku@gmail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=137664" name="attach_137664" title="Royalty free big buck bunny 30 second video file corrupted by mesa-git ;)">attachment 137664</a> <a href="attachment.cgi?id=137664&action=edit" title="Royalty free big buck bunny 30 second video file corrupted by mesa-git ;)">[details]</a></span>
Royalty free big buck bunny 30 second video file corrupted by mesa-git ;)

This ticket relates to a comment on a closed bug:
<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED NOTABUG - Broken hardware video encoding with vaapi/ffmpeg"
   href="show_bug.cgi?id=104920#c3">https://bugs.freedesktop.org/show_bug.cgi?id=104920#c3</a>

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:
<a href="https://download.blender.org/peach/bigbuckbunny_movies/">https://download.blender.org/peach/bigbuckbunny_movies/</a>

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
---
<span class="quote">> is_avc=false
> nal_length_size=0</span >
37c37
< bit_rate=2142956
---
<span class="quote">> bit_rate=2153505</span >
102c102
< filename=x264test.mp4
---
<span class="quote">> filename=vaapitest.mp4</span >
109,110c109,110
< size=8535782
< bit_rate=2274540
---
<span class="quote">> size=8575301
> bit_rate=2285071</span >

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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>