Bug 468480

Summary: Crash when playing fourth video
Product: [Applications] digikam Reporter: nucleo <nucleo>
Component: Preview-VideoAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: a.narendiran, bollen.w, caulier.gilles, evorster, fritigerngothly, herrlauch, j.straight-kde, martin.marmsoler, metzpinguin, mirko
Priority: NOR    
Version: 8.0.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 8.1.0
Sentry Crash Report:
Attachments: backtrace
new backtrace
new 4 backtraces

Description nucleo 2023-04-13 19:56:50 UTC
Created attachment 158079 [details]
backtrace

SUMMARY
Digikam crashes when playing fourth video.


STEPS TO REPRODUCE
1.  Select video to start playing it.
2.  Click on Forward button four times.

OBSERVED RESULT
Crash after three videos played and then clicking on Forward.  


SOFTWARE/OS VERSIONS
Fedora 37
FFmpeg 5.1.3
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
digiKam 7.10 in Fedora repo built with disabled MediaPlayer.
But 8.0.0 version failed to built with disabled MediaPlayer.
I enabled MediaPlayer for digiKam 8.0.0 (ffmpeg 5.1.3 now available in Fedora 37 repository, so it is possible to enable MediaPlayer).
After replacing Fedora ffmpeg with limited number of codecs with full ffmpeg from RPM Fusion it is possible to play h264 videos, so I tested MediaPlayer on such videos.
Comment 1 Maik Qualmann 2023-04-13 20:26:34 UTC
Could be a problem with your FFmpeg packages. Before it crashes:

digikam.qtav.warn: [FFmpeg:?] Codec 0xf5a16d60 is not in the full list.
QString::arg: Argument missing: No codec could be found for: , unknown_codec
digikam.qtav.warn: "No codec could be found for: "


Please check the digiKam-8.0.0 AppImage first, if the problem can be reproduced, from here:

https://files.kde.org/digikam/

Maik
Comment 2 nucleo 2023-04-13 21:13:29 UTC
No any issues with ffmpeg package from RPM Fusion repository and other programms.
And in digiKam all videos played fine but when opened no more than three videos in a row.
I never used AppImage. I try to build digiKam 8.0.0 for Fedora repository and now I found crash, so  using AppImage is not solution for me.
Comment 3 nucleo 2023-04-13 22:24:44 UTC
No crash in appimage but there used older version of ffmpeg.
Comment 4 nucleo 2023-04-13 22:38:12 UTC
I found difference betwen my build log and appimage.
In appimage
-- MediaPlayer will use FFMpeg 5 API                    : no
In my log
-- MediaPlayer will use FFMpeg 5 API                    : yes
CMake Warning at core/cmake/rules/RulesMediaPlayer.cmake:91 (message):
  FFMPEG API version 5 detected: support is under developement and not yet
  finalized! Please install lasted FFMPEG API version 4 LTS instead for a
  better video experience...  More info at https://ffmpeg.org/download.html

Maybe this can lead to crash?
Unfortunately, only ffmpeg version 5 is in our repository.
Comment 5 nucleo 2023-04-14 09:59:41 UTC
No crash in my local build with ffmpeg 4, so crash is ffmpeg 5 related.
But for Fedora repository possible only  build with ffmpeg 5.
Comment 6 Maik Qualmann 2023-04-14 18:10:41 UTC
Git commit 5e9d91e717a6447e7863627d39ed7d1f05c5f79b by Maik Qualmann.
Committed on 14/04/2023 at 18:09.
Pushed by mqualmann into branch 'master'.

this should fix the crash with FFmpeg5

M  +1    -1    core/libs/video/qtav/codec/AVDecoder.cpp

https://invent.kde.org/graphics/digikam/commit/5e9d91e717a6447e7863627d39ed7d1f05c5f79b
Comment 7 nucleo 2023-04-14 23:19:34 UTC
Created attachment 158117 [details]
new backtrace

After applying patch digiKam crashes with ffmpeg 5 at end of playing video .
Comment 8 Maik Qualmann 2023-04-15 05:58:05 UTC
Git commit cb8b56c68e9bf3efe7b9ff34706c5fad86949b1c by Maik Qualmann.
Committed on 15/04/2023 at 05:57.
Pushed by mqualmann into branch 'master'.

next try to fix the crash with FFmpeg5

M  +6    -3    core/libs/video/qtav/codec/AVDecoder.cpp

https://invent.kde.org/graphics/digikam/commit/cb8b56c68e9bf3efe7b9ff34706c5fad86949b1c
Comment 9 nucleo 2023-04-15 13:00:29 UTC
Created attachment 158126 [details]
new 4 backtraces

No crash at end of playing but unfortunately still crashes when going to next video.
Comment 10 Maik Qualmann 2023-04-15 15:37:34 UTC
Git commit f01c3bc23a04fe5f8fc1d80cd683418297072ecf by Maik Qualmann.
Committed on 15/04/2023 at 15:36.
Pushed by mqualmann into branch 'master'.

fix crash in FFmpeg5 avcodec_free_context()
FIXED-IN: 8.1.0

M  +2    -1    NEWS
M  +9    -6    core/libs/video/qtav/codec/AVDecoder.cpp

https://invent.kde.org/graphics/digikam/commit/f01c3bc23a04fe5f8fc1d80cd683418297072ecf
Comment 11 nucleo 2023-04-15 18:04:19 UTC
No crash after last commit.
Thanks.
Comment 12 Maik Qualmann 2023-04-24 19:22:05 UTC
*** Bug 468918 has been marked as a duplicate of this bug. ***
Comment 13 Maik Qualmann 2023-04-27 09:57:03 UTC
*** Bug 469042 has been marked as a duplicate of this bug. ***
Comment 14 Maik Qualmann 2023-06-02 11:10:52 UTC
*** Bug 470551 has been marked as a duplicate of this bug. ***
Comment 15 Maik Qualmann 2023-06-02 11:12:17 UTC
*** Bug 464319 has been marked as a duplicate of this bug. ***
Comment 16 Maik Qualmann 2023-06-02 11:12:38 UTC
*** Bug 464187 has been marked as a duplicate of this bug. ***
Comment 17 Maik Qualmann 2023-06-19 19:10:10 UTC
*** Bug 471231 has been marked as a duplicate of this bug. ***
Comment 18 herrlauch 2023-06-23 11:31:13 UTC
I still have digikam crashing on videos (version 8.0.0-4 on Arch Linux). It crashes right when opening the video (either clicking on it to open in the preview, or by going to the next video). Sometimes the same video plays and sometimes it crashes,  with varying messages on stdout/stderr:

> digikam.qtav.warn: Invalid plane! Valid range is [0, 0)
> digikam.qtav.warn: Invalid plane! Valid range is [0, 0)
> digikam.qtav.warn: Invalid plane! Valid range is [0, 0)
> digikam.qtav.warn: Can not copy codec properties when it's open
> digikam.qtav.warn: Can not copy codec properties when it's open
> digikam.qtav.warn: invalid index 0 ( valid is 0 ~ 0 ) for stream type 2
> [1]    1648904 segmentation fault (core dumped)  digikam

Or,
> digikam.qtav.warn: invalid video frame from decoder. undecoded data size: 0
> digikam.qtav.warn: invalid video frame from decoder. undecoded data size: 0
> digikam.qtav.warn: invalid video frame from decoder. undecoded data size: 0
> digikam.qtav.warn: invalid video frame from decoder. undecoded data size: 0
> digikam.qtav.warn: invalid video frame from decoder. undecoded data size: 0
> digikam.qtav.warn: invalid video frame from decoder. undecoded data size: 0
> corrupted double-linked list
> [1]    1646759 IOT instruction (core dumped)  QT_QPA_PLATFORM=wayland digikam

Note that I saw the warning about invalid video frames from the decoder also when a video played without crashing.
Comment 19 herrlauch 2023-06-23 11:35:23 UTC
And another output after crash:

digikam.qtav.warn: src audio parameters 'channel layout(or channels),sample rate and sample format must be set before initialize resampler
QString::arg: Argument missing: No codec could be found for: , none
digikam.qtav.warn: "No codec could be found for: "
double free or corruption (!prev)
[1]    1650223 killed     digikam
Comment 20 Maik Qualmann 2023-06-23 11:57:44 UTC
The problem is fixed in digiKam-8.1.0, not in digiKam.8.0.0. I can't say whether Arch has patched digiKam-8.0.0. Since everyone has confirmed so far that the problem has been fixed in digiKam-8.1.0, I close the bug again.

Maik
Comment 21 herrlauch 2023-06-23 13:52:32 UTC
(In reply to Maik Qualmann from comment #20)
> The problem is fixed in digiKam-8.1.0, not in digiKam.8.0.0. I can't say
> whether Arch has patched digiKam-8.0.0. Since everyone has confirmed so far
> that the problem has been fixed in digiKam-8.1.0, I close the bug again.
> 
> Maik

Oh. As the Arch package was updated in June, I assumed it were on the newest version. I'll check out 8.1.0, then. Thanks!
Comment 22 caulier.gilles 2023-06-23 14:34:35 UTC
8.1.0 is not yet released officially, but you can try the AppImage bundle as pre-release. Look here :

https://files.kde.org/digikam/

Gilles Caulier
Comment 23 Jason Straight 2023-07-11 21:34:50 UTC
Mine was crashing all the time. I tried the 8.1.0 appimage and it was also doing it, until I did two things, and I don't know which of the two, or both?, made the difference. Now I'm trying to crash it on videos and can't.

What I think fixed it was going to settings in video and removing all the codecs for video, restarting digikam, then enabling ffmpeg again and restarting it again.

The other thing I did before that, but it was still doing it after, was to remove the digikam thumbnails files in my Pictures folder.