SVG is not only vector graphics, but also 3 or even 4 meters of high-quality video ...
<image id="frame0" width="480" height="201" xlink:href="data:image/jpeg;base64,/9j//gAPTGF2YzU0Lj[...]"></image>
<svg version="1.1" baseProfile="tiny" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <image id='frame0' width="320" height="240" xlink:href="data:image/jpeg;base64,/9j//gAPTGF2YzU0Lj[...]" display='inline'> <set id="show1" attributeName="display" to="inline" begin="0s;show4.end" dur="1s" fill="freeze"/> <set id="hide1" attributeName="display" to="none" begin="show1.end" dur="0.01s" fill="freeze"/> </image> <image id='frame1' width="320" height="240" xlink:href="data:image/jpeg;base64,/9j//gAPTGF2YzU0Lj[...]" display='none'> <set id="show2" attributeName="display" to="inline" begin="show1.end" dur="1s" fill="freeze"/> <set id="hide2" attributeName="display" to="none" begin="show2.end" dur="0.01s" fill="freeze"/> </image> <image id='frame2' width="320" height="240" xlink:href="data:image/jpeg;base64,/9j//gAPTGF2YzU0Lj[...]" display='none'> <set id="show3" attributeName="display" to="inline" begin="show2.end" dur="1s" fill="freeze"/> <set id="hide3" attributeName="display" to="none" begin="show3.end" dur="0.01s" fill="freeze"/> </image> <image id='frame3' width="320" height="240" xlink:href="data:image/jpeg;base64,/9j//gAPTGF2YzU0Lj[...]" display='none'> <set id="show4" attributeName="display" to="inline" begin="show3.end" dur="1s" fill="freeze"/> <set id="hide4" attributeName="display" to="none" begin="show4.end" dur="0.01s" fill="freeze"/> </image> </svg>
<svg> [....] <script type="text/ecmascript"><![CDATA[ var svgDoc; var desiredFramesPerSecond=12; var msPerFrame = 1000/desiredFramesPerSecond; var numFrames = 4; var frameCt=0; svgDoc = document.getElementsByTagName("svg")[0]; setTimeout("AnimateEm()",msPerFrame); function AnimateEm(){ if (frameCt==0) startTime = new Date(); setTimeout("AnimateEm()",msPerFrame); svgDoc.getElementById('frame'+frameCt.toString()).style.display='none'; frameCt=(frameCt+1)%numFrames; svgDoc.getElementById('frame'+frameCt.toString()).style.display='inline'; } ]]></script> </svg>
ffmpeg -i "atari.avi" -r 12 -y -qscale 5 -vf scale=480:-1 -f image2 atari%%03d.jpg
php -q convert.php >convert.svg
<svg version="1.1" baseProfile="tiny" id="svg-root" width="100%" height="100%" viewBox="0 0 480 201" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <? $numFrames = 217; $FPS = 12; for($i=0;$i<=$numFrames-1;$i++) { ?> <image id="frame<?=$i?>" width="480" height="201" xlink:href="data:image/jpeg;base64,<?=base64_encode(file_get_contents("atari".str_pad(($i+1),3,"0",STR_PAD_LEFT).".jpg"))?>" display="<?=($i==0)?"inline":"none"?>"> <set id="show<?=$i?>" attributeName="display" to="inline" begin="<?=($i==0?"0s;":"")?>show<?=($i+$numFrames-1)%$numFrames?>.end" dur="<?=1/$FPS?>s" fill="freeze"/> <set id="hide<?=$i?>" attributeName="display" to="none" begin="show<?=$i?>.end" dur="0.01s" fill="freeze"/> </image> <? } ?> </svg>
Source: https://habr.com/ru/post/158197/
All Articles