<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Skylake GPU HANG while gstreamer H264 vaapi encoding from MJPEG vaapi decode on drm-tip"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=110394#c31">Comment # 31</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Skylake GPU HANG while gstreamer H264 vaapi encoding from MJPEG vaapi decode on drm-tip"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=110394">bug 110394</a>
              from <span class="vcard"><a class="email" href="mailto:andy.nicholas@shield.ai" title="Andy Nicholas <andy.nicholas@shield.ai>"> <span class="fn">Andy Nicholas</span></a>
</span></b>
        <pre>(In reply to Andy Nicholas from <a href="show_bug.cgi?id=110394#c30">comment #30</a>)
<span class="quote">> Created <span class=""><a href="attachment.cgi?id=143979" name="attach_143979" title="MJPEG - hand-carry video camera outside my house">attachment 143979</a> <a href="attachment.cgi?id=143979&action=edit" title="MJPEG - hand-carry video camera outside my house">[details]</a></span>
> MJPEG - hand-carry video camera outside my house

> Enclosed is 1 file for the recipe. This file needs to be transcoded from its
> format of MJPEG into H.264 on the compute stick using vaapi using gstreamer
> on Ubuntu 18.04 Server.

> Complete recipe coming after this large upload.</span >


Complete recipe from "No OS":


(1) Install Ubuntu 18.04.2 Server onto compute stick. I used a USB stick to do
this. Select volume manager in settings and SSH enable. Choose to make 52GB of
the compute stick into the large boot partition.


(2) Install these to get current gstreamer and ffmpeg test facilities:

    sudo apt install -y libgstreamer1.0-0 gstreamer1.0-plugins-base
gstreamer1.0-plugins-good
    sudo apt install -y gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
gstreamer1.0-libav
    sudo apt install -y gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x
gstreamer1.0-alsa
    sudo apt install -y gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5
gstreamer1.0-pulseaudio

    sudo apt install -y ffmpeg
    sudo apt install -y gstreamer1.0-vaapi
    sudo apt install -y vainfo
    sudo apt install -y xserver-xorg-hwe-18.04
    sudo apt-get update
    sudo apt-get upgrade



(3) Add the line below to /etc/fstab to point /tmp to tmpfs so we are routinely
saving to ram instead of flash:

tmpfs /tmp tmpfs defaults,noatime,nodiratime 0 0



(4) Save the following script to ~/setup-gpu.sh


#!/usr/bin/env bash

echo "This script must be run from sudo su prompt #"

set -ex

echo 500 | tee /sys/class/drm/card0/gt_min_freq_mhz
echo 500 | tee /sys/class/drm/card0/gt_max_freq_mhz
echo 500 | tee /sys/class/drm/card0/gt_boost_freq_mhz

cat /sys/class/drm/card0/gt_min_freq_mhz
cat /sys/class/drm/card0/gt_max_freq_mhz
cat /sys/class/drm/card0/gt_boost_freq_mhz

echo "Intel GPU Frequencies Locked"

echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor

echo "Intel CPUs set to performance governor"



(5) Save the following script to ~/mjpeg-to-h264.sh:

#!/usr/bin/env bash

set -ex

tcount=0
while true; do
        echo "Transcode: iteration $tcount" | tee tcount.txt

        # remove old output
        rm -f /tmp/transcode-output.mp4

        # transcode big-buck-bunny.mp4 using gstreamer
        time gst-launch-1.0 filesrc location=
andy-movies/mjpeg-outside-640x480.mkv ! matroskademux ! vaapijpegdec !
vaapih264enc ! qtmux ! filesink location=/tmp/gst-output.mp4

        tcount=$((tcount+1))    
done



(6) Save the MJPEG movie from this bug reply #30 to:

    ~/andy-movies/mjpeg-outside-640x480.mkv



(7) Switch to root: 

    $ sudo su
    # ./setup-gpu.sh
    <ctrl-D> to exit from root
    $./mjpeg-to-h264.sh


Once the compute stick is configured, the last Step #7 is what I do over and
over after rebooting.

NOTE: It's highly possible that this configuration will not reproduce the
issue, even when updated with the drm-tip kernel. We have only been successful
when using the image which was running on compute stick .38 and .36.

andy</pre>
        </div>
      </p>


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

      <ul>
          <li>You are on the CC list for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>