[ 
https://issues.apache.org/jira/browse/BATIK-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stanimir Stamenkov updated BATIK-1361:
--------------------------------------
    Attachment: wait-0.5375.png
                wait-0.5625@.png
                wait-0.5875.png

> Few broken animation frames using certain frame rates
> -----------------------------------------------------
>
>                 Key: BATIK-1361
>                 URL: https://issues.apache.org/jira/browse/BATIK-1361
>             Project: Batik
>          Issue Type: Bug
>    Affects Versions: 1.17
>         Environment: Batik 1.17; Java 17; Windows 10
>            Reporter: Stanimir Stamenkov
>            Priority: Major
>         Attachments: SVGAnimTest.java, SVGAnimTest2.java, 
> left_ptr_watch-20fps-046.png, left_ptr_watch.svg, wait-0.5375.png, 
> wait-0.5625@.png, wait-0.5875.png, wait-1.1000.png, wait-1.1250@.png, 
> wait-1.1500.png, wait-20fps-046.png, wait-40fps-046.png, wait-40fps-091.png, 
> wait-40fps-106.png, wait-60fps-136.png, wait.svg
>
>
> I have a small (3 sec) SVG animation I'm tryng to render the individual 
> frames of as bitmaps, like:
> {code:java}
> import java.nio.file.Path;
> import org.w3c.dom.Document;
> import org.apache.batik.transcoder.SVGAbstractTranscoder;
> import org.apache.batik.transcoder.TranscoderInput;
> import org.apache.batik.transcoder.TranscoderOutput;
> import org.apache.batik.transcoder.image.ImageTranscoder;
> import org.apache.batik.transcoder.image.PNGTranscoder;
>         Path framesDir;
>         Document svgDoc;
>         ...
>         TranscoderInput svg = new TranscoderInput(svgDoc);
>         final float duration = 3.0f;
>         final float frameRate = 20;
>         ImageTranscoder transcoder = new PNGTranscoder();
>         transcoder.addTranscodingHint(
>                 SVGAbstractTranscoder.KEY_EXECUTE_ONLOAD, true);
>         float animTime = 0;
>         for (int frame = 1; animTime < duration; animTime = frame++ / 
> frameRate) {
>             transcoder.addTranscodingHint(
>                     SVGAbstractTranscoder.KEY_SNAPSHOT_TIME, animTime);
>             Path frameFile = framesDir.resolve(BASE_NAME + "-" + frame + 
> ".png");
>             try (OutputStream fout = Files.newOutputStream(frameFile)) {
>                 transcoder.transcode(svg, new TranscoderOutput(fout));
>             }
>         }
> {code}
> I'm noticing with this specific animation ({{wait.svg}}) one of the frames is 
> "broken":
> || Frame #46 ||
> | !wait-20fps-046.png! |
> This appears when I'm rendering 20 fps for a total of 60 frames (3 seconds).  
> I've tried 15 fps and 30 fps, and I'm not observing such broken frames.  Then 
> I've tried 40 fps and I'm seeing few more broken frames:
> || Frame #46 || Frame #91 || Frame #106 ||
> | !wait-40fps-046.png! | !wait-40fps-091.png! | !wait-40fps-106.png! |
> At 45 and 50 fps I'm not observing broken frames.  At 60 fps I'm observing 
> one broken frame:
> || Frame #136 ||
> | !wait-60fps-136.png! |
> I'm noticing some magic numbers here: 
> {noformat}
> 46 (1-based) = 45 (0-based)
> 91 - 46 = 45
> 136 - 91 = 45
> {noformat}
> Not sure how and if *#106* fits in here... but {{136 - 106 = 20}} - the 
> common 20, 40, 60 (fps) denominator 🤪.
> *Steps to Reproduce*
> # Save [^wait.svg] and [^SVGAnimTest.java] into a single directory;
> # From the same directory execute:
> {noformat}
> java -cp <batik-dist>/lib/* SVGAnimTest.java
> {noformat}
> # Observe the animation frames in the output {{wait-20fps}} directory.
> *Actual Results*
> Frame {{wait-20fps-046.png}} is broken.
> *Expected Results*
> All frames should be fine.
> *Details*
> To experiment with different frame rates use:
> {noformat}
> java -cp <batik-dist>/lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp <batik-dist>/lib/* SVGAnimTest.java 40
> {noformat}
> ---
> _Disclaimer:_ The original 
> [wait.svg|https://github.com/ful1e5/Bibata_Cursor/blob/v2.0.4/svg/original/wait.svg]
>  is from the [Bibata_Cursor|https://github.com/ful1e5/Bibata_Cursor] project.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-h...@xmlgraphics.apache.org

Reply via email to