Bug 396128

Summary: mp4 cannot be encoded if either of the frame dimensions is not divisable by 2
Product: [Applications] krita Reporter: wolthera <griffinvalley>
Component: AnimationAssignee: Emmet O'Neill <emmetoneill.pdx>
Status: RESOLVED FIXED    
Severity: normal CC: emmetoneill.pdx, scottpetrovic, tamtamy.tymona
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description wolthera 2018-07-03 13:19:54 UTC
Came across this when trying mp4. There's no warnings anywhere in the gui that this might be an issue.

Sadly, this does not seem to be the issue that the windows users have trouble with.
Comment 1 Scott Petrovic 2018-07-03 13:31:33 UTC
This is a problem that exists when we allow people to manually enter different dimensions for exporting. Some dimenions just won't be valid depending on what people enter. This is a situation with how ffmpeg works and ffmpeg doesn't seem to handle errors very well with it. Other programs like Blender handle it equally as bad (just errors without any message).

We might have to add custom validation logic before exporting to see if the dimensions are divisible by 2. Maybe we don't allow the export button to be pressed if it is invalid and show a label on the UI with a message.

Not sure if anyone else has ideas. I think we are going to have to do something though in Krita code...not something ffmpeg will be able to tell us.
Comment 2 wolthera 2018-07-03 18:05:04 UTC
It is not just custom dimensions, in my case the canvas itself had an even number of pixels for the width and an odd number for the height, which caused the error.
Comment 3 Scott Petrovic 2018-07-03 18:09:10 UTC
What dimensions is giving you the error? I wasn't aware of any issues with exporting out at a normal 100%
Comment 4 wolthera 2018-07-03 18:27:48 UTC
2690x2303 and the render animation dialog had 800x684 for width/height.
Comment 5 Scott Petrovic 2018-07-03 20:54:10 UTC
Does it give you an issue if you render it out at 2690x2303 (the original size)...or only if you change the dimensions in the render dialog?

Maybe we are both referring to different things when we say 'custom dimensions'. Custom dimensions to me means exporting a video at different size then your canvas size.
Comment 6 wolthera 2019-03-03 20:57:12 UTC
I think I can close this now.
Comment 7 Tiar 2019-12-06 14:35:23 UTC
Because ffmpeg complains also when just the canvas (frames images) are in uneven size, Krita should show an error in this case, too.

Steps to reproduce:
1. Make a canvas 480x529. 
2. Create a new frame on a layer.
3. In Render Animation dialog, choose size 480x530.

OBSERVED RESULTS:
4. It won't render and it will say "Unknown Error". In log_encode.log file it will complain about size being not even.

EXPECTED:
This situation should be impossible to reach. Krita should show an error instead of giving ffmpeg those values.

NOTE:
I'm not sure if ffmpeg should complain in this case, but latest version (4.2.1) complains, and last time I spent 1h on figuring out what went wrong, so please let's just make it into an error message. Maybe some time in the future it can be removed.
Comment 8 Tiar 2019-12-06 14:36:16 UTC
Also whoever is fixing this, please take note of bug 412599.
Comment 9 Emmet O'Neill 2020-05-06 21:53:16 UTC
Git commit f5ac73ca0e1a34a508ac74831afc7ea44bbf3a55 by Emmet O'Neill.
Committed on 06/05/2020 at 21:48.
Pushed by emmetoneill into branch 'master'.

Fix FFMPEG issue associated with even:odd anims.

Quick fix for a bug causing animations with one odd dimension
to fail to render and report an unkown error. FFMPEG requires
even render dimensions, and fixing that in even:odd cases creates
a minor shift in aspect ratio, causing animation rendering to fail
while preserve aspect ratio is set.

M  +25   -31   plugins/extensions/animationrenderer/AnimationRenderer.cpp
M  +3    -1    plugins/extensions/animationrenderer/AnimationRenderer.h
M  +0    -4    plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
M  +2    -4    plugins/extensions/animationrenderer/video_saver.cpp

https://invent.kde.org/kde/krita/commit/f5ac73ca0e1a34a508ac74831afc7ea44bbf3a55
Comment 10 Halla Rempt 2020-05-07 06:50:09 UTC
Git commit 61c79aacb81653527817157dd108c46d6d048c73 by Boudewijn Rempt, on behalf of Emmet O'Neill.
Committed on 07/05/2020 at 06:48.
Pushed by rempt into branch 'krita/4.3'.

Fix FFMPEG issue associated with even:odd anims.

Quick fix for a bug causing animations with one odd dimension
to fail to render and report an unkown error. FFMPEG requires
even render dimensions, and fixing that in even:odd cases creates
a minor shift in aspect ratio, causing animation rendering to fail
while preserve aspect ratio is set.
(cherry picked from commit f5ac73ca0e1a34a508ac74831afc7ea44bbf3a55)

M  +25   -31   plugins/extensions/animationrenderer/AnimationRenderer.cpp
M  +3    -1    plugins/extensions/animationrenderer/AnimationRenderer.h
M  +0    -4    plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
M  +2    -4    plugins/extensions/animationrenderer/video_saver.cpp

https://invent.kde.org/kde/krita/commit/61c79aacb81653527817157dd108c46d6d048c73