Bug 473603 - Exporting the time-lapse trough recorder gives "FFMPEG crashed" error and video is not exported (git 8bacaa0)
Summary: Exporting the time-lapse trough recorder gives "FFMPEG crashed" error and vid...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: * Unknown (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Emmet O'Neill
URL:
Keywords: release_blocker
Depends on:
Blocks:
 
Reported: 2023-08-21 14:55 UTC by Raghavendra kamath
Modified: 2023-09-21 13:17 UTC (History)
2 users (show)

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


Attachments
Attaching the error dialog when rednering via built in ffmpeg (70.58 KB, image/png)
2023-09-15 08:56 UTC, Raghavendra kamath
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raghavendra kamath 2023-08-21 14:55:48 UTC
SUMMARY
When rendering the timelapse recorded in krita ffmpeg gives error and doesn't export the video. I tried all the formats gif, mkv, webm mp4 all give ffmpeg crashed error. This might also affect animation export too. 

The ffmpeg path is mapped to "/tmp/.mount_krita-N1yWQW/usr/bin/ffmpeg"

STEPS TO REPRODUCE
1. Open latest nightly build and open a document to record a timelapse
2. Open recorder docker and set it up for recording, draw some strokes and stop recording
3. Export the recording using the default preset.

OBSERVED RESULT
Export doesn't happen and ffmpeg crash error dialog pops up.

EXPECTED RESULT
Export should happen as usual.
Comment 1 Emmet O'Neill 2023-08-23 22:28:22 UTC
Thanks for the report Raghu, marking this as a release blocker.
Comment 2 Dmitry Kazakov 2023-08-28 08:44:52 UTC
Hi, Emmet!

Can this bug be related to the following report https://bugs.kde.org/show_bug.cgi?id=473727 ?
Comment 3 sh_zam 2023-09-04 13:08:57 UTC
Git commit 155bbdea44cf556f952fbd6d89b7749526a9676f by Sharaf Zaman.
Committed on 04/09/2023 at 15:07.
Pushed by szaman into branch 'master'.

3rdparty: Fix a crash in ffmpeg caused by different struct definitions

A  +37   -0    3rdparty/ext_ffmpeg/0001-Copy-over-some-macros-from-libavutil-version.h.patch
M  +1    -0    3rdparty/ext_ffmpeg/CMakeLists.txt

https://invent.kde.org/graphics/krita/-/commit/155bbdea44cf556f952fbd6d89b7749526a9676f
Comment 4 Raghavendra kamath 2023-09-15 08:56:46 UTC
Created attachment 161629 [details]
Attaching the error dialog when rednering via built in ffmpeg

Sorry this bug is still present in the nightly appimage. The version shows  (git fe971a1) Attaching an image to show the error dialog.
Comment 5 Dmitry Kazakov 2023-09-15 08:58:31 UTC
Raghavendra reports it is not fixed.
Comment 6 Raghavendra kamath 2023-09-15 08:59:38 UTC
here is what the ffmpeg log file says



/tmp/.mount_krita-meSKCk/usr/bin/ffmpeg -hide_banner -y -framerate 30 -i /home/raghu/Desktop/recorder/20230915142113/%07d.jpg -framerate 30 -start_number 15-1 -i /home/raghu/Desktop/recorder/20230915142113/%07d.jpg -filter_complex 
 [0]loop=5*30:size=1:start=15[main1];
 [main1]scale=3500:3500[main2];
 [main2]loop=1:size=1:start=0[main3];
 [main3]setpts=PTS-STARTPTS[main4];
 [1]split [first1][transition1];
 [transition1]scale=3500:3500 [transition2];
 [transition2]loop='if(gte(2, 1), 1*30, 0)':size=1:start=1[transition3];
 [transition3]setpts=PTS-STARTPTS[transition4];
 [transition4][main4]xfade=transition=smoothright:duration=0.5:offset=0[v1];
 [v1]setpts=PTS-STARTPTS[v2];
 [v2]trim=start_frame=1[v3];
 [first1]loop='if(gte(2, 1), (2*30) - 0.5, 2*30)':size=1:start=1[preview1];
 [preview1]scale=3500:3500[preview2];
 [preview2]setpts=PTS-STARTPTS[preview3];
 [preview3][v3] concat [final1];
 [final1] setpts=PTS-STARTPTS[final2];
 [final2] trim=start_frame=1
 -c:v libx264 -r 30 -pix_fmt yuv420p /home/raghu/Desktop/recorder/1.mp4
=====================================================
[mjpeg @ 0x5585084dbec0] EOI missing, emulating
Input #0, image2, from '/home/raghu/Desktop/recorder/20230915142113/%07d.jpg':
  Duration: 00:00:00.50, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 3500x3500 [SAR 96:96 DAR 1:1], 30 fps, 30 tbr, 30 tbn, 30 tbc
Input #1, image2, from '/home/raghu/Desktop/recorder/20230915142113/%07d.jpg':
  Duration: 00:00:00.03, start: 0.000000, bitrate: N/A
  Stream #1:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 3500x3500 [SAR 96:96 DAR 1:1], 30 fps, 30 tbr, 30 tbn, 30 tbc
Unknown encoder 'libx264'
Comment 7 Raghavendra kamath 2023-09-15 09:09:30 UTC
I think this may be a different issue. Instead of a crash i think individual presets are bugging out like webm and mp4. Because mkv export worked
Comment 8 Raghavendra kamath 2023-09-15 09:12:48 UTC
Mp4 and mp4 with flash effect doesn't work as shown in the screenshot, webm also gives and error 

Export failed. FFmpeg message:

[vp8_v4l2m2m @ 0x56085c82a740] Could not find a valid device
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Comment 9 Dmitry Kazakov 2023-09-21 08:17:10 UTC
I think it is the same bug as bug 474559 and I think I have a fix for that :)

*** This bug has been marked as a duplicate of bug 474559 ***
Comment 10 Dmitry Kazakov 2023-09-21 08:42:25 UTC
Okay, my fix doesn't actually fix the issue.
Comment 11 Dmitry Kazakov 2023-09-21 10:35:40 UTC
The bug should be fixed in https://invent.kde.org/graphics/krita/-/commit/dce681672a5ae22d4be4ee19eb8e964e0fe743a1
Comment 12 Dmitry Kazakov 2023-09-21 12:51:06 UTC
Hi, Raghavendra!

Could you please check this build when it is finished? I think I have fixed this bug:

https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/1993/
Comment 13 Dmitry Kazakov 2023-09-21 13:17:47 UTC
Git commit dce681672a5ae22d4be4ee19eb8e964e0fe743a1 by Dmitry Kazakov.
Committed on 21/09/2023 at 12:22.
Pushed by dkazakov into branch 'master'.

Fix external ffmpeg not working on Linux due to clash in LD_LIBRARY_PATH

We embed a dynamically linked ffmpeg into our appimage and add that
into the environment with a LD_LIBRARY_PATH variable. If the user
tries to use a system-provided dynamically-linked ffmped, then there
will be a clash and ffmpeg will crash.

Hence we should detect if a non-embedded ffmpeg is running and remove
the variable from its environment.

M  +47   -1    libs/ui/animation/KisFFMpegWrapper.cpp
M  +2    -0    libs/ui/animation/KisFFMpegWrapper.h

https://invent.kde.org/graphics/krita/-/commit/dce681672a5ae22d4be4ee19eb8e964e0fe743a1
Comment 14 Dmitry Kazakov 2023-09-21 13:17:49 UTC
Git commit 4cc1ab5a659cb6b1f5229a44b5c92890779d09e1 by Dmitry Kazakov.
Committed on 21/09/2023 at 12:33.
Pushed by dkazakov into branch 'krita/5.2'.

Fix external ffmpeg not working on Linux due to clash in LD_LIBRARY_PATH

We embed a dynamically linked ffmpeg into our appimage and add that
into the environment with a LD_LIBRARY_PATH variable. If the user
tries to use a system-provided dynamically-linked ffmped, then there
will be a clash and ffmpeg will crash.

Hence we should detect if a non-embedded ffmpeg is running and remove
the variable from its environment.

M  +47   -1    libs/ui/animation/KisFFMpegWrapper.cpp
M  +2    -0    libs/ui/animation/KisFFMpegWrapper.h

https://invent.kde.org/graphics/krita/-/commit/4cc1ab5a659cb6b1f5229a44b5c92890779d09e1