Page 1 of 1

Video Thumbnail Generation Crashing XnView

Posted: Sun Apr 06, 2025 5:30 pm
by Akira98
XnView: 1.8.7 64-bit (Linux) - Libformat 7.220
OS: Linux 64 bit

Effect: Hanging of thread related to thumbnail generation (for videos).

To reproduce: Difficult to do individually, occurs randomly on different video files. Which video file does not appear to make a difference, it will crash in the same directory on a different video each time, while videos that previously caused the crash may generate thumbnails just fine.

Actual behaviour (bug): <Current wrong behaviour of XnView> :bug: Part of the program hangs when a video thumbnail fails to generate.

When this crash occurs, the last lines in output will look like this for the video that crashed it:

Code: Select all

BLOB length 75 
==> daawiolewzlo1.mp4 0 
  MDK ==> 51767  0
decoded @0.000000. out size: 1280x720, stride: 5120, format: 10
  MDK2 ==> 51767  0
==> isdolfasop2.mp4 25 
  MDK ==> 51767  12941
decoded @12.500000. out size: 1280x720, stride: 5120, format: 10
  MDK2 ==> 51767  0
Once this occurs, the entire program does not crash immediately, only thumbnail generation stops at the video file.
Most UI elements still function, but certain subsequent actions after the thumbnail fails to generate will cause the entire program to crash (stopped responding):
- Using Ctrl+1, Ctrl+2, etc... To Add a rating. Adding a rating from the context menu does not cause XnView to crash
- Navigating to any other folder
- Refreshing current folder
- Renaming, moving, deleting a file or folder

After any of these actions, right before the crash this will be outputted to the console:

Code: Select all

ThumbLoaderThread :: stop()
Usually a few hundred thumbnails will be generated before one crashes. No videos in particular seem to cause this, it is only random. Mostly seen it occur on .mp4 format but I believe it also occurred on a .webm video.

If I try to generate thumbnails for the folder in Settings -> Catalog, eventually a random video will cause it to hang indefinitely and crash the program, likely same error. With thousands of videos it's not feasible to upload this folder.

Expected behaviour: All thumbnails generate correctly or if not, ensure stability of program. (Create a generic "error" thumbnail and continue generating thumbnails?)

Re: Video Thumbnail Generation Crashing XnView

Posted: Mon Apr 07, 2025 6:45 am
by xnview
you had not this problem with previous version?

Re: Video Thumbnail Generation Crashing XnView

Posted: Mon Apr 07, 2025 5:47 pm
by Akira98
I don't believe so because previously I had thumbnails for all of these videos generated. Only after I upgraded to 1.8.7 did I end up needing to rebuild all of my thumbnails, but I don't remember what version I had before that.

The video files themselves don't appear to be the issue, because it's random which one it crashes on.
Is there any other type of logging I can provide?


I tried a fresh install, deleting all user files and it still occurs (after I enable thumbnail generation for videos).

Re: Video Thumbnail Generation Crashing XnView

Posted: Tue Apr 08, 2025 6:26 am
by xnview
you can change debug=2, and start XnView from a terminal

Re: Video Thumbnail Generation Crashing XnView

Posted: Wed Apr 09, 2025 5:05 pm
by Akira98
Debug=2 did not add any extra info.

After testing on windows, this crash seems to only occur on Linux Debian 64 bit. All thumbnails generated fine on windows 11 64 bit (same xnview version).

Code: Select all

==> TEST/9DP1Ttz3Z3O6.mp4 0 
  MDK ==> 1000  0
decoded @0.000000. out size: 1280x1024, stride: 5120, format: 10
  MDK2 ==> 1000  0
LOADED & CREATED
BLOB length 75 
==> TEST/9pWT0yfYFVSZ.mp4 0 
  MDK ==> 14000  0
decoded @0.000000. out size: 1280x1024, stride: 5120, format: 10
  MDK2 ==> 14000  0
LOADED & CREATED
BLOB length 75 
==> TEST/9TbjIRMWUPDO.mp4 0 
  MDK ==> 15000  0
decoded @0.000000. out size: 1280x1024, stride: 5120, format: 10
  MDK2 ==> 15000  0
LOADED & CREATED
BLOB length 75 
==> TEST/62PJ4YQwcLVS.mp4 0 
  MDK ==> 20000  0
decoded @0.000000. out size: 640x480, stride: 2560, format: 10
  MDK2 ==> 20000  0
On that last file in this output log "62PJ4YQwcLVS.mp4", it never gets to the "LOADED & CREATED" part. This is where it crashes.

Once I do certain operations, such as navigating to another folder,

Code: Select all

ThumbLoaderThread :: stop()
will be the last line and then it crashes the whole program.


Here in this screenshot, in another instance, the video that crashes it is "AG1yyU1...". It's a random video each time, after about 15 or so thumbnail generations.
1.png
1.png (116.43 KiB) Viewed 199 times

Since I can't upload an entire video folder, I used ChatGPT to make this code to generate random videos, which are used in this test case (100% reproducible on Linux with video thumbnails turned on)

Code: Select all

import cv2 # pip install opencv-python
import numpy as np
import random
import os

random_name = lambda x: "".join((random.choice("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890") for i in range(x)))

RANDOM_RESOLUTIONS = (
	(640, 480),
	(1280, 1024),
	(1920, 1080)
)

def Generate_MP4(width, height, length_in_seconds, output_path):
	fps = 30
	num_frames = int(length_in_seconds*fps)
	random_color = (random.randrange(0, 255), random.randrange(0, 255), random.randrange(0, 255))

	# Use H.264 encoding. 'avc1' is a common FourCC for H.264
	fourcc = cv2.VideoWriter_fourcc(*'avc1')

	writer = cv2.VideoWriter(output_path, fourcc, fps, (width, height))

	if not writer.isOpened():
		raise RuntimeError("Failed to open video writer. Your system might not support 'avc1' (H.264).")

	for i in range(num_frames):
		if random.random() >= 0.95:
			frame = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
		else:
			frame = np.full((height, width, 3), random_color, dtype=np.uint8)
		
		writer.write(frame)

	writer.release()
	print(f"Video saved to {output_path}")

for index in range(150):
	name = random_name(12) + ".mp4"
	res = random.choice(RANDOM_RESOLUTIONS)
	length = random.choice(range(1, 25))
	
	print("%s: %dx%d %d sec" % (name, res[0], res[1], length))
	
	try:
		Generate_MP4(res[0], res[1], length, name)
	except:
		os.unlink(name)

This bug seems to have also caused my entire thumbnail DB to become corrupt at least once.


Hope this helps, thanks for your time

Re: Video Thumbnail Generation Crashing XnView

Posted: Thu Apr 10, 2025 9:04 am
by xnview
i've tried on Kubuntu 24, with 50 mp4 and no crash here