From 68075ea9c50c6f314a56f45698e86fdf68640cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 9 Nov 2025 15:31:40 +0100 Subject: [PATCH] Fixed: #2551 Showing too wide video tags in Flash player producing ValueTooLarge exception. Also truncated video length. --- CHANGELOG.md | 3 +++ .../flash/exporters/PreviewExporter.java | 20 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd9b7d3d2..4f1b46a1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ All notable changes to this project will be documented in this file. - [#2547] SVG import - improper linearGradient with userSpaceOnUse gradient units - [#2545] FLA export - normalize font em square - [#2552] Open with FFDec explorer menu shrinking sidebar +- [#2551] Showing too wide video tags in Flash player producing ValueTooLarge + exception. Also truncated video length. ## [24.1.0] - 2025-09-28 ### Added @@ -4035,6 +4037,7 @@ Major version of SWF to XML export changed to 2. [#2547]: https://www.free-decompiler.com/flash/issues/2547 [#2545]: https://www.free-decompiler.com/flash/issues/2545 [#2552]: https://www.free-decompiler.com/flash/issues/2552 +[#2551]: https://www.free-decompiler.com/flash/issues/2551 [#2477]: https://www.free-decompiler.com/flash/issues/2477 [#2478]: https://www.free-decompiler.com/flash/issues/2478 [#2485]: https://www.free-decompiler.com/flash/issues/2485 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java index 21a710ef1..136ac2422 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/PreviewExporter.java @@ -105,11 +105,14 @@ public class PreviewExporter { public static final int MORPH_SHAPE_ANIMATION_LENGTH = 2; public static final int MORPH_SHAPE_ANIMATION_FRAME_RATE = 30; + + private static final double WIDTH_DIVISOR = 1000; + private void updateProgressBar(int xmin, int ymin, SWF swf, SWFOutputStream sos2, int width, int height, int progressBarHeight, int currentFrame, int totalFrames) throws IOException { Matrix m = new Matrix(); m.translate(xmin, ymin + height - progressBarHeight * 20); - m.scale(width * currentFrame / totalFrames, progressBarHeight * 20); + m.scale(width / WIDTH_DIVISOR * currentFrame / totalFrames, progressBarHeight * 20); new PlaceObject2Tag(swf, true, 2, -1, m.toMATRIX(), null, -1, null, -1, null).writeTag(sos2); } @@ -117,10 +120,10 @@ public class PreviewExporter { int progressBarShapeId = swf.getNextCharacterId(); int overVideoButtonId = progressBarShapeId + 1; int progressBarButtonId = overVideoButtonId + 1; - + Color progressBarColor = Color.red; DefineShapeTag dsh = new DefineShapeTag(swf); - dsh.shapeBounds = new RECT(0, 20, 0, 20 * progressBarHeight); + dsh.shapeBounds = new RECT(0, (int) Math.round(WIDTH_DIVISOR * 20), 0, 20 * progressBarHeight); dsh.shapeId = progressBarShapeId; dsh.shapes.fillStyles.fillStyles = new FILLSTYLE[1]; dsh.shapes.fillStyles.fillStyles[0] = new FILLSTYLE(); @@ -140,14 +143,14 @@ public class PreviewExporter { ser.deltaY = 1; dsh.shapes.shapeRecords.add(ser); ser = new StraightEdgeRecord(); - ser.deltaX = 1; + ser.deltaX = (int) Math.round(WIDTH_DIVISOR * 1); dsh.shapes.shapeRecords.add(ser); ser = new StraightEdgeRecord(); ser.vertLineFlag = true; ser.deltaY = -1; dsh.shapes.shapeRecords.add(ser); ser = new StraightEdgeRecord(); - ser.deltaX = -1; + ser.deltaX = (int) Math.round(-1 * WIDTH_DIVISOR); dsh.shapes.shapeRecords.add(ser); dsh.shapes.shapeRecords.add(new EndShapeRecord()); @@ -226,13 +229,13 @@ public class PreviewExporter { new PlaceObject2Tag(swf, false, 2, progressBarShapeId, m.toMATRIX(), null, -1, null, -1, null).writeTag(sos2); m = new Matrix(); - m.scale(width, height - progressBarHeight * 20); + m.scale(width / WIDTH_DIVISOR, height - progressBarHeight * 20); new PlaceObject2Tag(swf, false, 3, overVideoButtonId, m.toMATRIX(), null, -1, null, -1, null).writeTag(sos2); m = new Matrix(); m.translate(xmin, ymin + height - progressBarHeight * 20); - m.scale(width, progressBarHeight * 20); + m.scale(width / WIDTH_DIVISOR, progressBarHeight * 20); new PlaceObject2Tag(swf, false, 4, progressBarButtonId, m.toMATRIX(), null, -1, null, -1, null).writeTag(sos2); @@ -612,6 +615,7 @@ public class PreviewExporter { doa.writeTag(sos2); new ShowFrameTag(swf).writeTag(sos2); } else if (treeItem instanceof DefineVideoStreamTag) { + DefineVideoStreamTag dv = (DefineVideoStreamTag) treeItem; List frs = new ArrayList<>(videoFrames.values()); Collections.sort(frs, new Comparator() { @Override @@ -627,7 +631,7 @@ public class PreviewExporter { int ratio = 0; for (VideoFrameTag f : frs) { if (!first) { - ratio++; + ratio = f.frameNum; new PlaceObject2Tag(swf, true, 1, -1, null, null, ratio, null, -1, null).writeTag(sos2); if (showControls) { updateProgressBar(rxmin, rymin, swf, sos2, width, height, progressBarHeight, ratio, videoFrames.size());