Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.17
-
None
-
None
-
Batik 1.17; Java 17; Windows 10
Description
I have a small (3 sec) SVG animation I'm tryng to render the individual frames of as bitmaps, like:
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)); } }
I'm noticing with this specific animation (wait.svg) one of the frames is "broken":
Frame #46 |
---|
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 |
---|---|---|
At 45 and 50 fps I'm not observing broken frames. At 60 fps I'm observing one broken frame:
Frame #136 |
---|
I'm noticing some magic numbers here:
46 (1-based) = 45 (0-based) 91 - 46 = 45 136 - 91 = 45
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:
java -cp <batik-dist>/lib/* SVGAnimTest.java
- 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:
java -cp <batik-dist>/lib/* SVGAnimTest.java [fps]
f.e.:
java -cp <batik-dist>/lib/* SVGAnimTest.java 40
—
Disclaimer: The original wait.svg is from the Bibata_Cursor project.
Attachments
Attachments
Issue Links
- links to