Error generating screenshot - killing container

Hey folks, running into an interesting error, where the screenshot generation task kills the server/container. I’ve been able to reproduce it consistently, just wondering if anyone else is seeing this issue? Happy to open an issue if needed, and supply more logs. v0.28.1

Here’s a redacted version of the docker logs just before the crash.. Looks like ffmpeg is getting killed for some reason.

INFO[2025-07-21 16:47:41] Generate started with 2 parallel tasks
INFO[2025-07-21 16:47:41] Creating screenshot for /data/clips/foo/bar.mkv
INFO[2025-07-21 16:47:41] Generating 1 covers 1 sprites 1 previews 0 markers 1 phashes
INFO[2025-07-21 16:47:41] [generator] generating sprite image for /data/clips/foo/bar.mkv
ERRO[2025-07-21 16:47:41] error generating sprite: error running ffmpeg command <-v error -y -ss 0 -i /data/clips/foo/bar.mkv -frames:v 1 -vf scale=160:-2 -c:v bmp -f rawvideo ->: signal: killed
ERRO[2025-07-21 16:47:41] command stderr:
INFO[2025-07-21 16:47:41] [generator] generating video preview for /data/clips/foo/bar.mkv

Immediately afterwards the container dies; docker restarts it because restart: unless-stopped is set.

NFS permissions fixed, but issue not resolved.

ffmpeg is still getting a signal: killed

INFO[2025-07-22 16:30:43] Generating 1 covers 1 sprites 1 previews 0 markers 1 phashes
INFO[2025-07-22 16:30:43] Creating screenshot for /foo.bar.mkv
INFO[2025-07-22 16:30:43] [generator] generating sprite image for /foo.bar.mkv
INFO[2025-07-22 16:30:44] [generator] generating video preview for /foo/bar.mkv
WARN[2025-07-22 16:30:44] [generator] failed generating scene preview, trying fallback
INFO[2025-07-22 16:30:44] [generator] generating video preview for /foo.bar.mkv
ERRO[2025-07-22 16:30:44] error generating preview: error running ffmpeg command <-v error -y -i /foo.bar.mkv -t 0.75 -max_muxing_queue_size 1024 -c:v libx264 -vf scale=640:-2 -pix_fmt yuv420p -profile:v high -level 4.2 -preset slow -crf 21 -threads 4 -strict -2 -an /generated/tmp/3053288556.mp4>: signal: killed
ERRO[2025-07-22 16:30:44] command stderr:
INFO[2025-07-22 16:30:44] [generator] generating phash sprite for /foo/bar.mkv

Running the same command manually, from inside the container, works fine, without issue:

/ # ffmpeg -v error -y -ss 699.466 -i /data/clips/foo/bar.mkv" -frames:v 1 -q:v 2 -f image2 /genera
ted/tmp/1908328678.jpg
/ # ls /generated/tmp/
1908328678.jpg
/ #

Even with trace logging turned on, a generate command on a single file still results in signal: killed.

INFO[2025-07-23 09:28:36] Generate started with 2 parallel tasks
2025-07-23T09:28:36.648097907-06:00 INF Response: 200 OK httpRequest={"proto":"HTTP/1.1","remoteIP":"172.17.0.1:49502","requestID":"dbc2726f79c7/jdGh9PxH1P-001329","requestMethod":"POST","requestPath":"/graphql","requestURL":"http://foobar.local/graphql"} httpResponse={"bytes":56,"elapsed":1.420197,"status":200} service=stash
TRAC[2025-07-23 09:28:36] SQL [238.698µs]: SELECT `scenes`.*, `scenes_files`.`file_id` AS `primary_file_id`, `folders`.`path` AS `primary_file_folder_path`, `files`.`basename` AS `primary_file_basename`, `fingerprint_md5`.`fingerprint` AS `primary_file_checksum`, `fingerprint_oshash`.`fingerprint` AS `primary_file_oshash` FROM `scenes` LEFT JOIN `scenes_files` ON ((`scenes_files`.`scene_id` = `scenes`.`id`) AND (`scenes_files`.`primary` = ?)) LEFT JOIN `files` ON (`files`.`id` = `scenes_files`.`file_id`) LEFT JOIN `folders` ON (`folders`.`id` = `files`.`parent_folder_id`) LEFT JOIN `files_fingerprints` AS `fingerprint_md5` ON ((`fingerprint_md5`.`file_id` = `scenes_files`.`file_id`) AND (`fingerprint_md5`.`type` = ?)) LEFT JOIN `files_fingerprints` AS `fingerprint_oshash` ON ((`fingerprint_oshash`.`file_id` = `scenes_files`.`file_id`) AND (`fingerprint_oshash`.`type` = ?)) WHERE (`scenes`.`id` IN (?)), args: [1 md5 oshash 12772]
TRAC[2025-07-23 09:28:36] SQL [46.836µs]: SELECT file_id, `primary` from scenes_files WHERE scene_id = ?, args: [12772]
TRAC[2025-07-23 09:28:36] SQL [137.607µs]: SELECT `files`.`id` AS `file_id`, `files`.`basename`, `files`.`zip_file_id`, `files`.`parent_folder_id`, `files`.`size`, `files`.`mod_time`, `files`.`created_at` AS `file_created_at`, `files`.`updated_at` AS `file_updated_at`, `folders`.`path` AS `parent_folder_path`, `files_fingerprints`.`type` AS `fingerprint_type`, `files_fingerprints`.`fingerprint`, `zip_files`.`basename` AS `zip_basename`, `zip_files_folders`.`path` AS `zip_folder_path`, `zip_files`.`size` AS `zip_size`, `video_files`.`file_id` AS `file_id_video`, `video_files`.`format` AS `video_format`, `video_files`.`width` AS `video_width`, `video_files`.`height` AS `video_height`, `video_files`.`duration`, `video_files`.`video_codec`, `video_files`.`audio_codec`, `video_files`.`frame_rate`, `video_files`.`bit_rate`, `video_files`.`interactive`, `video_files`.`interactive_speed`, `image_files`.`format` AS `image_format`, `image_files`.`width` AS `image_width`, `image_files`.`height` AS `image_height` FROM `files` INNER JOIN `folders` ON (`files`.`parent_folder_id` = `folders`.`id`) LEFT JOIN `files_fingerprints` ON (`files`.`id` = `files_fingerprints`.`file_id`) LEFT JOIN `video_files` ON (`files`.`id` = `video_files`.`file_id`) LEFT JOIN `image_files` ON (`files`.`id` = `image_files`.`file_id`) LEFT JOIN `files` AS `zip_files` ON (`files`.`zip_file_id` = `zip_files`.`id`) LEFT JOIN `folders` AS `zip_files_folders` ON (`zip_files`.`parent_folder_id` = `zip_files_folders`.`id`) WHERE (`files`.`id` = 12797), args: []
TRAC[2025-07-23 09:28:36] SQL [50.075µs]:
                SELECT scene_markers.* FROM scene_markers
                WHERE scene_markers.scene_id = ?
                GROUP BY scene_markers.id
                ORDER BY scene_markers.seconds ASC
        , args: [12772]
INFO[2025-07-23 09:28:36] Generating 1 covers 1 sprites 1 previews 0 markers 1 phashes
DEBU[2025-07-23 09:28:36] Creating screenshot for /data/clips/foo/bar.mkv
INFO[2025-07-23 09:28:36] Creating screenshot for /data/clips/foo/bar.mkv
INFO[2025-07-23 09:28:36] [generator] generating sprite image for /data/clips/foo/bar.mkv
ERRO[2025-07-23 09:28:36] Error generating screenshot: error running ffmpeg command <-v error -y -ss 699.466 -i /data/clips/foo/bar.mkv -frames:v 1 -q:v 2 -f image2 /generated/tmp/3101093139.jpg>: signal: killed
ERRO[2025-07-23 09:28:36] command stderr:
INFO[2025-07-23 09:28:37] [generator] generating video preview for /data/clips/foo/bar.mkv
WARN[2025-07-23 09:28:37] [generator] failed generating scene preview, trying fallback
INFO[2025-07-23 09:28:37] [generator] generating video preview for /data/clips/foo/bar.mkv
ERRO[2025-07-23 09:28:40] error generating sprite: error running ffmpeg command <-v error -y -ss 518.1229629629629 -i /data/clips/foo/bar.mkv -frames:v 1 -vf scale=160:-2 -c:v bmp -f rawvideo ->: signal: killed
ERRO[2025-07-23 09:28:40] command stderr:
INFO[2025-07-23 09:28:40] [generator] generating phash sprite for /data/clips/foo/bar.mkv
ERRO[2025-07-23 09:28:40] error generating preview: error running ffmpeg command <-v error -y -ss 562.8883333333333 -i /data/clips/foo/bar.mkv -ss 20 -t 0.75 -max_muxing_queue_size 1024 -c:v libx264 -vf scale=640:-2 -pix_fmt yuv420p -profile:v high -level 4.2 -preset slow -crf 21 -threads 4 -strict -2 -an /generated/tmp/3048483593.mp4>: signal: killed
ERRO[2025-07-23 09:28:40] command stderr:
TRAC[2025-07-23 09:28:50] SQL: UPDATE `files` SET `basename`=?,`created_at`=?,`id`=?,`mod_time`=?,`parent_folder_id`=?,`size`=?,`updated_at`=?,`zip_file_id`=? WHERE (`files`.`id` = ?) [[Nympho - 2019-07-14 - Sexual Chemistry with Scarlett [WEBDL-1080p].mkv 2025-07-23T09:12:00-06:00 12797 2025-07-22T22:16:08-06:00 2932 1459560636 2025-07-23T09:12:00-06:00 <nil> 12797]]
TRAC[2025-07-23 09:28:50] SQL [39.768µs]: SELECT COUNT(*) FROM `video_files` WHERE (`video_files`.`file_id` = 12797), args: []
TRAC[2025-07-23 09:28:50] SQL: UPDATE `video_files` SET `audio_codec`=?,`bit_rate`=?,`duration`=?,`file_id`=?,`format`=?,`frame_rate`=?,`height`=?,`interactive`=?,`interactive_speed`=?,`video_codec`=?,`width`=? WHERE (`video_files`.`file_id` = ?) [[aac 3338687 3497.33 12797 matroska 29.97 1080 false <nil> hevc 1920 12797]]
TRAC[2025-07-23 09:28:50] SQL [50.617µs]: DELETE FROM files_fingerprints WHERE file_id = ?, args: [12797]
TRAC[2025-07-23 09:28:50] SQL: INSERT INTO `files_fingerprints` (`file_id`, `type`, `fingerprint`) VALUES (12797, 'oshash', 'a2da9154e3750fcc') [[]]
TRAC[2025-07-23 09:28:50] SQL: INSERT INTO `files_fingerprints` (`file_id`, `type`, `fingerprint`) VALUES (12797, 'phash', -2554173474903241998) [[]]
INFO[2025-07-23 09:28:50] Generate finished (13.580103322s)

Fixed my own issue; ffmpeg was being killed by the kernel’s OOM killer. Although the server running stash had more than enough memory, the container was configured to limit the amount of memory used with mem_limit: 512m. So whenever the ffmpeg command ran, and used more than 512mb or ram, OOM killed the ffmpeg process.

For those interested, and running stash in a container, you can limit how much resources stash uses, also makes it a lot easier to prevent a rogue container from consuming all resources on your server, and crashing it (can and has happened to me).

Here’s a stash container health check, and some sensible container restristions; you can tune and tweak these as needed for your performance/server.

  stash:
    container_name: stash
    image: stashapp/stash:latest
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "sh", "-c", "wget http://localhost:9999/healthz -qO /dev/null || exit 1"]
      interval: 5m00s
      timeout: 10s
      retries: 2
      start_period: 30s
    stop_signal: SIGTERM
    stop_grace_period: 10s
    mem_limit: 2048m  # limiting memory usage to 2gb
    cpu_shares: 256  # lower cpu priority over other containers, default 1024
    ulimits:  # Prevent resource exhaustion
      nofile:  # number of open files
        soft: 1024
        hard: 4096
    network_mode: bridge
    environment:
...

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.