Herschel / Swivel

Adobe Flash SWF to video converter
https://newgrounds.com/swivel
GNU General Public License v3.0
166 stars 22 forks source link

SWFs using the Animate CC camera tool export with cropped video #1

Open Herschel opened 6 years ago

Herschel commented 6 years ago

Using the Camera tool in Adobe Animate CC will cause videos to export incorrectly.

Animate-CC-camera-sample.zip

Adobe Animate CC v 18.0 (build 107)

ninjamuffin99 commented 6 years ago

I think this might be a problem with the "Basic Layers" thing. According to insanetoons on Newgrounds, as long as Animate is in "Advanced Layers" mode, it'll export fine through Swivel. https://www.newgrounds.com/bbs/topic/1430342

I've tried it myself and it seems to work fine in Advanced Layer mode, while there are problems in Basic Layer mode. Not sure how new this Advanced Layer stuff is though

leovoel commented 6 years ago

the problem is that the animate camera is translating the parent's mask (if one is present) so that the mask's (0, 0) point matches with its center, and swivel does set a mask, so the animation gets cropped on output.

the camera avoids changing the mask position if "Advanced Layers" is enabled, which is why that happens to be a workaround for this.

a possible fix is to always reset the position of _mask to (0, 0) on every frame:

https://github.com/leovoel/Swivel/blob/aa364c0957994e4470c51c19dc6a1897e52f761c/src/com/newgrounds/swivel/swf/SWFRecorder.hx#L251-L254

i've tested that on these swfs, and they look okay (i took the liberty of adding a variant of the swf posted in this issue, modified so that it will trigger this problem. conversion results are also included).

i don't know if anything else should be set on the mask (e.g. rotation), but it doesn't look like it's needed if these samples are anything to go by.

also, this means that swivel won't properly convert swfs that use this procedure for masking, unless they set their mask on the second frame. i don't really know what would be a good way to fix that.

Herschel commented 6 years ago

Thank you for the very helpful info @leovoel! Resetting the mask position should definitely help in most cases.

I wonder if it's possible to tweak where in the display hierarchy Swivel sets the mask to avoid this issue entirely, or to only enable the mask for a moment while drawing the frame, and then disable it. I'm going to do a big brain dump about the mask here... It's been several years and I'd like to document it a bit before I forget!

Swivel masks the movie because there was an issue was with older style V-Cams. If the camera zoomed in, and there was a filter applied somewhere on the scene, it would cause the rendering to grind to a halt. When doing bitmapData.draw to render the frame, the Flash Player would try to apply the filter to the entire gigantic bounds of the zoomed-in clip. In the worst case, this would actually cause the player to crash.

After some fiddling, I found that masking the loader clip fixed the issue and forced the filter to only apply to the visible area. This sped up the rendering and avoided the crashes. I remember it being finicky, so it's possible that it only works when masking this particular clip and not other parent display objects. I believe I also tried using the clipRect of bitmapData.draw with no luck, etc.

The original movie that caused the issue was The Ballad of CrippleKane by Hans, in a scene where the camera zoomed in on a face and blurred the background.

Worst case, it'd be nice to add an "advanced options" box somewhere that allows the user to disable some of these settings if they cause problems with their SWF.