{"id":7549,"date":"2017-04-02T19:54:40","date_gmt":"2017-04-02T23:54:40","guid":{"rendered":"http:\/\/www.useragentman.com\/blog\/?p=7549"},"modified":"2019-04-10T15:42:09","modified_gmt":"2019-04-10T19:42:09","slug":"using-peat-to-create-seizureless-web-animations","status":"publish","type":"post","link":"http:\/\/www.useragentman.com\/blog\/2017\/04\/02\/using-peat-to-create-seizureless-web-animations\/","title":{"rendered":"Using PEAT To Create Seizureless Web Animations"},"content":{"rendered":"\r\n<div class=\"image-container\">\r\n<!--\r\n  *\r\n  * Note: The widths here are a result of the two break points (360, 768),\r\n  * the desktop max-width of an image (835).  We then took all of these\r\n  * numbers and multiplied by two for a retina display.\r\n  * \r\n  * The conditional comments are there in case IE9 is visiting this site,\r\n  * since it has a problem with <picture>.\r\n  * \t\r\n  * We don't use picturefill, because all modern browsers can handle this\r\n  * (yay!)\r\n  * \r\n  * We removed the JXR renditions, because they weren\"t as good as the MOZ\r\n  * JPEG ones. \r\n  *\r\n  * Command that generated this page and assoicated images:\r\n  *  ..\/..\/bin\/html5ImageConverter.sh --jxr-nconvert --jpg-quals=70 --webp-quals=60 --jp2-rates=0.13 --sizes=360\/720\/768\/835\/1536\/1670 --no-png --use-mozjpeg --jxr-quals=30 epilepsy.png\r\n  *\r\n-->\r\n<picture class=\"alignnone size-full full-bleed full-width\">\r\n  <!--[if IE 9]><video style='display: none;'><![endif]-->\r\n  <source srcset='\/images\/7549\/epilepsy-360.jp2 360w, \/images\/7549\/epilepsy-720.jp2 720w, \/images\/7549\/epilepsy-768.jp2 768w, \/images\/7549\/epilepsy-835.jp2 835w, \/images\/7549\/epilepsy-1536.jp2 1536w, \/images\/7549\/epilepsy-1670.jp2 1670w' type='image\/jp2'>\r\n  <source srcset='\/images\/7549\/epilepsy-360.webp 360w, \/images\/7549\/epilepsy-720.webp 720w, \/images\/7549\/epilepsy-768.webp 768w, \/images\/7549\/epilepsy-835.webp 835w, \/images\/7549\/epilepsy-1536.webp 1536w, \/images\/7549\/epilepsy-1670.webp 1670w' type='image\/webp'>\r\n  <!--[if IE 9]><\/video><![endif]-->\r\n  <img class=\"full-bleed full-width\" srcset='\/images\/7549\/epilepsy-360.jpg 360w, \/images\/7549\/epilepsy-720.jpg 720w, \/images\/7549\/epilepsy-768.jpg 768w, \/images\/7549\/epilepsy-835.jpg 835w, \/images\/7549\/epilepsy-1536.jpg 1536w, \/images\/7549\/epilepsy-1670.jpg 1670w'  \/>\r\n<\/picture>\r\n<\/div>\r\n<p>Recently, an accessibility-savvy client asked me if one of the animations they were planning to place on their website could cause seizures with people who have <a href=\"https:\/\/en.wikipedia.org\/wiki\/Photosensitive_epilepsy\">Photosensitive Epilepsy<\/a>.  There are several examples of this happening in the real world, such as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Denn%C5%8D_Senshi_Porygon\">this Pok\u00e9mon episode that caused seizures in several Japanese children in 1997<\/a>, <a href=\"http:\/\/news.bbc.co.uk\/2\/hi\/uk_news\/england\/london\/6724245.stm\">this promotional video for the 2012 Olympic Games in London<\/a> and even a case of <a href=\"http:\/\/www.avclub.com\/article\/twitter-user-arrested-sending-seizure-inducing-gif-252311\">someone trying to induce a seizure in someone on purpose with an animated GIF<\/a>.  The avoid this from happening in accessible web applications, the W3C&#8217;s <a href=\"https:\/\/en.wikipedia.org\/wiki\/Web_Content_Accessibility_Guidelines\">Web Content Accessibility Guidelines<\/a> require that a web page cannot &#8220;contain anything that flashes more than three times in any one second period, or the flash is below the general flash and red flash thresholds&#8221; (this is known as the <a href=\"https:\/\/www.w3.org\/TR\/UNDERSTANDING-WCAG20\/seizure-does-not-violate.html\">Three Flashes or Below Threshold<\/a> requirement)<\/p>\n<p>Testing this requirement may seem a little daunting at first, but luckily there is a free tool called <a href=\"https:\/\/trace.umd.edu\/peat\">PEAT<\/a> that web developers can use to test if their animations and videos can cause an epileptic attack in those with Photosensitive Epilepsy.  The <a href=\"https:\/\/trace.umd.edu\/peat\/help#iHow_Seizure_Risk\">help files<\/a> for it are really good at explaining how the <a href=\"https:\/\/trace.umd.edu\/peat\/help#iHow_Seizure_Risk\">seizure risk is determined using the Harding Test<\/a> (and even what a general flash and a red flash is). However, when I installed it on my computer, I found that there were limitations:<\/p>\n<ol>\n<li>It is Windows-only (and my work computer is a Mac).<\/li>\n<li>While it states that you can capture the animation running on a web browser, I have found this difficult to get working, especially if you are running PEAT in a virtual machine such as VirtualBox (did I mention my work computer was a Mac?)<\/li>\n<li>A work around for the previous point is that you can give PEAT a video capture to analyze.  However, the video must be an uncompressed AVI (and most Mac tools deal primarily with MP4 or Quicktime Videos)<\/li>\n<\/ol>\n<p>In order to work around these issues, we need to produce a video capture, convert it to an uncompressed AVI, and then let PEAT analyze that. <\/p>\n<h2>Step 1: Producing a Video Capture of Your Web Browser<\/h2>\n<p>On a Mac, <a href=\"http:\/\/etc.usf.edu\/techease\/4all\/getting-started\/creating-screen-recordings-with-quicktime-player\/\">use Quicktime to capture the video of your animation<\/a>.  On Windows 10, you can use <a href=\"http:\/\/gizmodo.com\/windows-10-is-hiding-a-great-video-capture-tool-1719196149\">this built-in feature in Windows to capture video<\/a>, but since <a href=\"http:\/\/support.xbox.com\/en-US\/xbox-on-windows\/social\/troubleshoot-game-dvr-windows-10\">not all computers running Windows support it<\/a>, you may find <a href=\"http:\/\/camstudio.org\/\">CamStudio<\/a> a good alternative (Note: I have not used either Windows solution to capture video, so your mileage may vary).<\/p>\n<h2>Step 2: Convert the Video to Uncompressed AVI format<\/h2>\n<p>PEAT is guaranteed to analyze 25 frame-per-second <a href=\"https:\/\/forum.videohelp.com\/threads\/295571-What-is-uncompressed-AVI\">uncompressed AVIs<\/a>.  I have used <a href=\"https:\/\/ffmpeg.org\/\">FFmpeg<\/a> to convert other types of video content to this format.  Once you <a href=\"https:\/\/ffmpeg.org\/download.html\">download the program<\/a> (or install it with your favourite package manager like macports, brew, or cygwin), you can use the following command line recipe to do this:<\/p>\n<blockquote class=\"code\">\n<pre>\r\nffmpeg -i <em>input.mp4<\/em> -an -vcodec rawvideo -y -r 25 <em>output.avi<\/em>\r\n<\/pre>\n<\/blockquote>\n<p>For those who are interested: the <code>-an<\/code> removes the audio (since PEAT doesn&#8217;t need it to analyze the video), the <code>-vcodec rawvideo<\/code> converts the output to an uncompressed format, the <code>-y<\/code> will overwrite the video without asking, and the <code>-r 25<\/code> will ensure the output video has a framerate of 25 frames-per-second.  Note that even though I use an MPEG-4 as the input video in the command above, <a href=\"https:\/\/ffmpeg.org\/general.html#File-Formats\">FFmpeg can read and write a variety of other video formats<\/a>.<\/p>\n<p>Sometimes PEAT will fail to read the uncompressed video, or only analyze part of the video, because it&#8217;s too big.  In that case, you should resize the video using this ffmpeg recipe:<\/p>\n<blockquote class=\"code\">\n<pre>\r\nffmpeg -i <em>input.mp4<\/em> <span class=\"hilite\">-vf scale=640:-1<\/span> -an -vcodec rawvideo -y -r 25 <em>output.avi<\/em>\r\n<\/pre>\n<\/blockquote>\n<p>This will rescale the video to 640 pixels across without changing the aspect ratio.  This rescale is acceptable for seizure testing purposes.<\/p>\n<h2>Step 3: Get PEAT to analyze the video<\/h2>\n<p>You can now use PEAT to analyze the input file.  If you are using a Mac or Linux, use VirtualBox or another type of Virtual Machine software to run it on a copy of Windows (this can be done by <a href=\"https:\/\/developer.microsoft.com\/en-us\/microsoft-edge\/tools\/vms\/\"> downloading one of the modern.IE Windows 10 virtual machine images<\/a> from Microsoft&#8217;s developer website).  You can open the file using <strong>File &rarr; Open<\/strong> and then analyze the video using <strong>Analysis &rarr; Analyze Video<\/strong>.  To show how it works, let&#8217;s give PEAT a video capture of a game I have been developing in my spare time:<\/p>\n<blockquote class=\"instagram-media aligncenter\" data-instgrm-captioned data-instgrm-version=\"7\" style=\" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);\">\n<div style=\"padding:8px;\">\n<div style=\" background:#F8F8F8; line-height:0; margin-top:40px; padding:40.0% 0; text-align:center; width:100%;\">\n<div style=\" background:url(data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAABGdBTUEAALGPC\/xhBQAAAAFzUkdCAK7OHOkAAAAMUExURczMzPf399fX1+bm5mzY9AMAAADiSURBVDjLvZXbEsMgCES5\/P8\/t9FuRVCRmU73JWlzosgSIIZURCjo\/ad+EQJJB4Hv8BFt+IDpQoCx1wjOSBFhh2XssxEIYn3ulI\/6MNReE07UIWJEv8UEOWDS88LY97kqyTliJKKtuYBbruAyVh5wOHiXmpi5we58Ek028czwyuQdLKPG1Bkb4NnM+VeAnfHqn1k4+GPT6uGQcvu2h2OVuIf\/gWUFyy8OWEpdyZSa3aVCqpVoVvzZZ2VTnn2wU8qzVjDDetO90GSy9mVLqtgYSy231MxrY6I2gGqjrTY0L8fxCxfCBbhWrsYYAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;\"><\/div>\n<\/div>\n<p style=\" margin:8px 0 0 0; padding:0 4px;\"> <a href=\"https:\/\/www.instagram.com\/p\/BRjSzZ0gb04\/\" style=\" color:#000; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none; word-wrap:break-word;\" target=\"_blank\">Progress on my #html5 #JavaScript port of #KCMunchkin. Playable!<\/a><\/p>\n<p style=\" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;\">A post shared by Zoltan &#34;Du Lac&#34; Hawryluk (@zoltandulac) on <time style=\" font-family:Arial,sans-serif; font-size:14px; line-height:17px;\" datetime=\"2017-03-12T20:27:40+00:00\">Mar 12, 2017 at 1:27pm PDT<\/time><\/p>\n<\/div>\n<\/blockquote>\n<p>When I put this video through PEAT, it starts producing a graph like this:<\/p>\n<p><a href=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2017\/04\/kc-peat.png\"><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2017\/04\/kc-peat.png\" alt=\"PEAT analyzing video capture of a game I am making in my spare time.\"  class=\"full-bleed full-width size-full wp-image-7556\" \/><\/a><\/p>\n<p>As you can see from the graph, the animations used in the video are safe &mdash; the only times the graph starts spiking are when the monsters start flashing, but this flashing is well within acceptable levels (the tool shows some light luminance flash).<\/p>\n<p>To show how the tool behaves when it comes across a bad animation, I fed it a the seizure inducing scene from Pok\u00e9mon that I mentioned earlier. I do not link to the video, since I don&#8217;t want people getting seizures as a result of going to my blog (if you want to see it, search for it in YouTube), but here is what PEAT displays when it came across the seizure-inducing part of the show:<\/p>\n<p><a href=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2017\/04\/pokemon-peat.png\"><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2017\/04\/pokemon-peat.png\" alt=\"screenshot of PEAT analyzing a seizure inducing video.\" class=\"full-bleed full-width  size-full wp-image-7557\" \/><\/a><\/p>\n<p>Note that both luminance and red flash metrics are going off the charts.  Flashing saturated reds are especially bad for those who susceptible to seizures.<\/p>\n<h2>Further Reading<\/h2>\n<ul>\n<li>W3C page on WCAG requirement 2.3.1, <a href=\"https:\/\/www.w3.org\/TR\/UNDERSTANDING-WCAG20\/seizure-does-not-violate.html\">Three Flashes or Below Threshold: (Understanding SC 2.3.1)<\/a><\/li>\n<li><a href=\"https:\/\/trace.umd.edu\/peat\">PEAT download page<\/a><\/li>\n<li><a href=\"http:\/\/www.snopes.com\/radiotv\/tv\/seizure.asp\">Pokemon snopes article<\/a><\/li>\n<li><a href=\"http:\/\/www.avclub.com\/article\/twitter-user-arrested-sending-seizure-inducing-gif-252311\">Twitter user arrested for sending seizure-inducing GIF<\/a> on avclub.com.<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Harding_test\">Wikipedia article on the Harding Test<\/a><\/li>\n<\/ul>\n<h2>Acknowledgments<\/h2>\n<p>Header photo credit: <a href=\"https:\/\/pixabay.com\/en\/users\/geralt-9301\/\">Gerd Altmann<\/a>.<\/p>\n<p><script async defer src=\"\/\/platform.instagram.com\/en_US\/embeds.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2017\/04\/teaser.jpg\" \/> Photosensitive Epilepsy should be a concern to anyone creating any type of animated media. As a matter of fact, in order to pass WCAG Level A, a web page cannot &#8220;contain anything that flashes more than three times in any one second period, or the flash is below the general flash and red flash thresholds&#8221;. Testing this requirement may seem a little daunting at first, but luckily there is a free tool called PEAT that web developers can use to test if their animations and videos can cause an epileptic attack. This blog post talks about how to use PEAT, what it&#8217;s limitations are, and how to work around them.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[191,152,123,96,1],"tags":[192,228,220,231,233,232],"class_list":["post-7549","post","type-post","status-publish","format-standard","hentry","category-accessibility","category-animation-css3","category-color","category-cygwin","category-uncategorized","tag-a11y","tag-accessibility","tag-animation","tag-ffmpeg","tag-seizure","tag-video"],"_links":{"self":[{"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/7549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/comments?post=7549"}],"version-history":[{"count":45,"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/7549\/revisions"}],"predecessor-version":[{"id":7811,"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/7549\/revisions\/7811"}],"wp:attachment":[{"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/media?parent=7549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/categories?post=7549"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/tags?post=7549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}