Bug 443105 - FFMPEG: Frame rendering will include files outside of intended frame range when using the same file name.
Summary: FFMPEG: Frame rendering will include files outside of intended frame range wh...
Status: CONFIRMED
Alias: None
Product: krita
Classification: Applications
Component: Animation (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR minor
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-29 06:37 UTC by healer.harie
Modified: 2022-12-29 23:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Progress bar. (28.66 KB, image/jpeg)
2021-09-29 06:37 UTC, healer.harie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description healer.harie 2021-09-29 06:37:10 UTC
Created attachment 142001 [details]
Progress bar.

SUMMARY
If an existing png frames existed in the directory with range 0-970, and you specified Krita to render a new animation from frame 0-100, Krita would overwrite the existing png frames from 0-100; The frames from 101-970 still exist. This would result into a concatenation of the new frame 0-100 and old frame 101-970, and a progress bar like in the attachment. This old frame of 0-970 should have been automatically deleted by Krita after the video is exported, but it's possible to postpone it by cancelling the saving of png frames, or by manually saving it as png frames.

STEPS TO REPRODUCE
1. At frame 0, draw a "0". at frame 24, draw a "24". at frame 60, draw a "60".
2. Render animation as png frames with range 0-100.
3. Render animation as video with range 0-30.

OBSERVED RESULT
Two different frames are concatenated.

EXPECTED RESULT
Krita renders video from range 0-30.

SOFTWARE/OS VERSIONS
Windows: 10
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Krita

 Version: 5.0.0-beta1 (git 0986afa)
 Languages: en_US, en
 Hidpi: false

Qt

  Version (compiled): 5.12.11
  Version (loaded): 5.12.11

OS Information

  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 10.0.15063
  Pretty Productname: Windows 10 (10.0)
  Product Type: windows
  Product Version: 10

OpenGL Info
 
  Vendor:  "Google Inc." 
  Renderer:  "ANGLE (Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0)" 
  Version:  "OpenGL ES 3.0 (ANGLE 2.1.0.57ea533f79a7)" 
  Shading language:  "OpenGL ES GLSL ES 3.00 (ANGLE 2.1.0.57ea533f79a7)" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile) 
     Version: 3.0
     Supports deprecated functions false 
     is OpenGL ES: true 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsAngleD3D11: true 
  isQtPreferAngle: true 

Hardware Information

  GPU Acceleration: auto
  Memory: 1946 Mb
  Number of Cores: 4
  Swap Location: C:/Users/User6/AppData/Local/Temp

Current Settings

  Current Swap Location: C:/Users/User6/AppData/Local/Temp
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 30
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Disable Vector Optimizations: false
  Disable AVX Optimizations: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 900
  Use Backup Files: true
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Backup Location writable: false
  Use Win8 Pointer Input: false
  Use RightMiddleTabletButton Workaround: false
  Levels of Detail Enabled: false
  Use Zip64: false


Display Information
Number of screens: 1
	Screen: 0
		Name: \\.\DISPLAY1
		Depth: 32
		Scale: 1
		Resolution in pixels: 1280x800
		Manufacturer: 
		Model: 
		Refresh Rate: 60
Comment 1 Halla Rempt 2022-07-12 13:38:38 UTC
I can confirm the issue. Even though Krita says it's going to delete existing frames, that does not happen. Eoin, can you take a look?
Comment 2 Eoin O'Neill 2022-07-20 23:20:54 UTC
(In reply to Halla Rempt from comment #1)
> I can confirm the issue. Even though Krita says it's going to delete
> existing frames, that does not happen. Eoin, can you take a look?

Yeah I'll take a look at this.
Comment 3 Eoin O'Neill 2022-07-28 02:02:28 UTC
Git commit c290356ae92125b25d73d115a5b6fa5a153ca620 by Eoin O'Neill.
Committed on 28/07/2022 at 02:00.
Pushed by eoinoneill into branch 'master'.

Improve logic for cleaning up files for unique frames only and only
video exports.

M  +10   -11   libs/ui/animation/KisAnimationRender.cpp
M  +12   -1    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
M  +1    -0    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.h

https://invent.kde.org/graphics/krita/commit/c290356ae92125b25d73d115a5b6fa5a153ca620
Comment 4 Eoin O'Neill 2022-07-28 02:02:36 UTC
Git commit e1b1c7070f03280b11a99bd87d74b62be99b8fab by Eoin O'Neill.
Committed on 28/07/2022 at 01:14.
Pushed by eoinoneill into branch 'master'.

AnimExport: Clean up files when user cancels exporting of frames or when failure
occurs.

Should cause less circumstances where files exist that should not,
causing ffmpeg to render out incorrectly.

M  +1    -0    libs/ui/animation/KisAnimationRender.cpp
M  +1    -1    libs/ui/animation/KisFFMpegWrapper.h
M  +29   -1    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
M  +1    -0    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.h

https://invent.kde.org/graphics/krita/commit/e1b1c7070f03280b11a99bd87d74b62be99b8fab
Comment 5 Eoin O'Neill 2022-07-28 02:16:57 UTC
So there are some improvements I've made here that I will try to get into 5.1's branch.

Canceling the frame export will now properly clean up any files that were made during the progress of exporting. Additionally, there have been improvements made to the unique frames and frame sequence deletion properties that should make this bug less likely to occur. 

The key word is less likely though since changing the number offset will still occasionally causes this issue. In order to fix this, we will need to migrate some of our FFMpeg calls to use the "concatenate" codec where we specify files in a text file, which will take some time and probably won't make 5.1. 

If you do a lot of "Start numbering at" value changes, which is admittedly better suited for image sequence only export circumstances, my recommendation for now would be to change the sequence "Base name" entry for circumstances where you want to export the same file multiple times with different time offsets while also needing a video of said frames. 

I'll let you know when there are any updates. For now, I've updated the title of this bug to better reflect the current problem.
Comment 6 Eoin O'Neill 2022-07-28 20:49:11 UTC
Git commit abe0d509ef1cc9a4d0266b8558eacc7a858185b6 by Eoin O'Neill.
Committed on 28/07/2022 at 20:49.
Pushed by eoinoneill into branch 'krita/5.1'.

AnimExport: Clean up files when user cancels exporting of frames or when failure
occurs.

Should cause less circumstances where files exist that should not,
causing ffmpeg to render out incorrectly.


(cherry picked from commit e1b1c7070f03280b11a99bd87d74b62be99b8fab)

M  +1    -0    libs/ui/animation/KisAnimationRender.cpp
M  +1    -1    libs/ui/animation/KisFFMpegWrapper.h
M  +29   -1    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
M  +1    -0    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.h

https://invent.kde.org/graphics/krita/commit/abe0d509ef1cc9a4d0266b8558eacc7a858185b6
Comment 7 Eoin O'Neill 2022-07-28 20:50:01 UTC
Git commit ebe74faf98c4b0ba5607e99596f64dcbfaeaf6a3 by Eoin O'Neill.
Committed on 28/07/2022 at 20:49.
Pushed by eoinoneill into branch 'cherry-pick-c290356a'.

Improve logic for cleaning up files for unique frames only and only
video exports.


(cherry picked from commit c290356ae92125b25d73d115a5b6fa5a153ca620)

M  +10   -11   libs/ui/animation/KisAnimationRender.cpp
M  +12   -1    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
M  +1    -0    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.h

https://invent.kde.org/graphics/krita/commit/ebe74faf98c4b0ba5607e99596f64dcbfaeaf6a3
Comment 8 Eoin O'Neill 2022-07-28 20:54:35 UTC
Git commit 124c22c45387f01f0fb08a4d5db941d91d9b908d by Eoin O'Neill.
Committed on 28/07/2022 at 20:54.
Pushed by eoinoneill into branch 'krita/5.1'.

Improve logic for cleaning up files for unique frames only and only
video exports.


(cherry picked from commit c290356ae92125b25d73d115a5b6fa5a153ca620)

M  +10   -11   libs/ui/animation/KisAnimationRender.cpp
M  +12   -1    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
M  +1    -0    libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.h

https://invent.kde.org/graphics/krita/commit/124c22c45387f01f0fb08a4d5db941d91d9b908d