Error creating thumbnail for gallery video clips

Hello :waving_hand:

I have a few galleries that have .mp4 / .mov files inside them and set the option for Scan Video Extensions as Image Clip to enabled.

Inside those galleries I can see the video files and can look at them but the thumbnail sometimes doesn’t work, so I’ve deleted all my thumbnails and when it was working I saw a lot of error like this (this is 2 error messages which are generated at the same time):

stderr: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x559807f576c0] stream 0, offset 0x30: partial file
    Last message repeated 1 times
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x559807f57400] Error during demuxing: Invalid data found when processing input
Cannot determine format of input 0:0 after EOF
[vf#0:0 @ 0x559807f70a40] Task finished with error code: -1094995529 (Invalid data found when processing input)
[vf#0:0 @ 0x559807f70a40] Terminating thread with return code -1094995529 (Invalid data found when processing input)
[vost#0:0/mjpeg @ 0x559807f5fec0] Could not open encoder before EOF
[vost#0:0/mjpeg @ 0x559807f5fec0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/mjpeg @ 0x559807f5fec0] Terminating thread with return code -22 (Invalid argument)
[out#0/image2pipe @ 0x559807f591c0] Nothing was written into output file, because at least one of its streams received no packets.

Error   error generating thumbnail for /data/<folders>/46.mp4: error running ffmpeg command <-hide_banner -v error -y -i - -vf scale=640:640:force_original_aspect_ratio=decrease -c:v mjpeg -frames:v 1 -q:v 5 -f image2pipe - -f mjpeg>: exit status 183

I am running the nerethos/stash-jellyfin-ffmpeg docker image which simply install jellyfin ffmpeg and then download the stash release from github to be run, which shouldn’t impact this since no edit is done to the release file.

I’ve also tried to do it on another computer by running it locally and got the same error (using the same files).

The files have no problem playing in my browser / video player, and also run fine in stash player.

If there’s something else I can give to help find what is the problem, please let me know.

Most likely your files has some corruption that prevents the ffmpeg from proccesing it correctly.
Most media players simply ignore the errors during playback (even if it encounter missing data chunks, hence you can get choppy video or audio glitches sometimes), but since the purpose here is to generate a new file from existing one, Stash can’t do that.

Few possible solutions would be:

  • Remuxing the video.
  • Fully reencoding the video.

Thanks for the response since then I’ve clone the repository and done some changes.

I tried the same command on another computer and it worked fine but when doing it inside the container it would fail so I think it has something to do with the file (and/or the version of ffmpeg used)

I was able to fix this on my stash by editing the following function from

func (e *ThumbnailEncoder) ffmpegImageThumbnail(image *bytes.Buffer, maxSize int) ([]byte, error) {
	args := transcoder.ImageThumbnail("-", transcoder.ImageThumbnailOptions{
		OutputFormat:  ffmpeg.ImageFormatJpeg,
		OutputPath:    "-",
		MaxDimensions: maxSize,
		Quality:       ffmpegImageQuality,
	})

	return e.FFMpeg.GenerateOutput(context.TODO(), args, image)
}

to

func (e *ThumbnailEncoder) ffmpegImageThumbnail(inPath string, image *bytes.Buffer, maxSize int) ([]byte, error) {
	args := transcoder.ImageThumbnail(inPath, transcoder.ImageThumbnailOptions{
		OutputFormat:  ffmpeg.ImageFormatJpeg,
		OutputPath:    "-",
		MaxDimensions: maxSize,
		Quality:       ffmpegImageQuality,
	})

	return e.FFMpeg.GenerateOutput(context.TODO(), args, image)
}

This function is only used where we have access to the path of the file and by giving it the file directly rather than a buffer, it was able to work. I dont think this is a perfect fix but in my case it was worked the best since I dont want to edit my ffmpeg installation in my docker compose.

1 Like