Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some files aren't generating thumbnails, FFMPEG error -22 #61

Open
breath-prime opened this issue Feb 13, 2025 · 9 comments
Open

Some files aren't generating thumbnails, FFMPEG error -22 #61

breath-prime opened this issue Feb 13, 2025 · 9 comments

Comments

@breath-prime
Copy link

Hi,

Thank you for the time you and everyone have spent creating and supporting this script.

Current Issue:
I'm currently rebuilding my thumbnails after a fresh rebuild of plex. When I let the script run, some files error out with a -22 error from FFMPEG. When this occurs, no thumbnails are generated and plex just shows black thumbnails for the affected file. It also does not seem to retry with the files so I'd have to delete all thumbnails and try regenerating the whole library again.

Environment:

  • Single VM w/ Docker stack setup for plex/plex_generate_vid_previews.
  • Plex media library shared as SMB share from NAS
  • All other folders are local VHD (SSD) on the VM
  • GPU encoding temporarily disabled on plex_generate_vid_previews as it wasn't playing well when also shared with plex docker in same stack.

Example Error:
2025/02/13 18:15:54 | ❌ - [' Terminating thread with return code -22 (Invalid argument)', ' Nothing was written into output file, because at least one of its streams received no packets.', 'frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A ', 'Conversion failed!', ''] 2025/02/13 18:15:54 | ❌ - Problem trying to ffmpeg images for /media/Anime/Aoashi/Season 1/Aoashi - S01E20 - The Truly Weak One.mkv 2025/02/13 18:15:54 | 🐞 - FFMPEG Command output 2025/02/13 18:15:54 | 🐞 - b'' 2025/02/13 18:15:54 | ℹ️ - Generated Video Preview for /media/Anime/Aoashi/Season 1/Aoashi - S01E20 - The Truly Weak One.mkv HW=False TIME=1.4seconds SPEED=[]x

I've attached a sanitized docker compose file, and would appreciate any help with this. I can provide any other logs or output you may need.

Thank you!

plex_stack_compose.txt

@stevezau
Copy link
Owner

Hi @breath-prime , I'm not sure why this is happening. We will need debug logs tho.

Can you set env var LOG_LEVEL=debug and rerun and then share the logs here?

In the meantime, I've got some questions.

  1. Is this happening with all files or just some?
  2. You said "GPU encoding temporarily disabled on plex_generate_vid_previews as it wasn't playing well when also shared with plex docker in same stack." - what was the issue/error you were seeing? it should work
  3. Can you share your docker settings? mainly the folder mappings I'm interested in.

Thanks

@breath-prime
Copy link
Author

Hi @stevezau,

Sure thing. LOG_LEVEL=debug was already set. Is there a specific location to pull the log files from outside of what's generated in the console? I'm afraid I'm not seeing that location in the documentation unless I'm just blind.

  1. Just some files.
  2. GPU encoding works fine. The problem I had here was trying to share a single vGPU between two containers in the same docker stack. I think I just messed up a setting somewhere in my docker compose or I may need to carve up more vGPU's and assign them to specific containers. For troubleshooting purposes though, I disabled GPU threads for now just to eliminate one potential issue.
  3. I've shared my full docker compose file in the main post which has all unique folder mappings. Any other folders are the defaults generated per container.
    Here's my env variables and volumes for the plex_generate_vid_previews container:
    environment:
    • PLEX_URL=https://XXXXXXXX:32400
    • PLEX_TOKEN=XXXXXXXXXXX
    • PLEX_BIF_FRAME_INTERVAL=10
    • THUMBNAIL_QUALITY=4
    • PLEX_LOCAL_MEDIA_PATH=/plexmedia
    • TMP_FOLDER=/tmp/previews
    • PLEX_TIMEOUT=120
    • GPU_THREADS=0
    • CPU_THREADS=20
    • LOG_LEVEL=debug
      volumes:
    • /data/plex/config/Library/Application Support/Plex Media Server/Media/:/plexmedia
    • /mnt/media:/media

I just cleared one of my library thumbnails and I'm regenerating them now. Will update with some more console output soon.

Thanks for your time/help!

@breath-prime
Copy link
Author

breath-prime commented Feb 18, 2025

I already found one thing I need to change: I set TMP_FOLDER to a unique folder instead of leaving it in /dev/shm/XXXXX or assigning a tmpfs volume. For now I'm leaving it as is, unless you recommend otherwise. I'm fairly new to docker setups so sorry for any starter mistakes here.

I've attached some console output here with some of the errors.

_plex_previews_logs(7).txt

@breath-prime
Copy link
Author

I just noticed some interesting, intermittent behavior. In my original post, I listed one example error on a library file. This time around, it generated the thumbnails correctly on the same file, while others are having issues.

@planetrocky
Copy link

planetrocky commented Feb 20, 2025

I know what this might be.

Can you tell me the version of FFMPEG please?

ffmpeg -version

@breath-prime
Copy link
Author

Hi @planetrocky,

Looks like version 7.0.1 in the container:
I have no name!@505241cadcb3:/app$ ffmpeg -version ffmpeg version 7.0.1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13 (Ubuntu 13.2.0-23ubuntu4) configuration: --disable-debug --disable-doc --disable-ffplay --enable-alsa --enable-cuvid --enable-ffprobe --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libfdk_aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libplacebo --enable-librav1e --enable-librist --enable-libshaderc --enable-libsrt --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nonfree --enable-nvdec --enable-nvenc --enable-cuda-llvm --enable-opencl --enable-openssl --enable-stripping --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100

Thank you!

@stevezau
Copy link
Owner

stevezau commented Feb 20, 2025

Hmm, looking at the logs, it works for some files but not others. That’s odd—I’m not sure what’s going on.

@breath-prime, do you think this could be a known issue with 7.0.1? I’ve locked it to 7.0.1 for now, but I can upgrade if needed.

Also, I see you changed the tmp path. Does it consistently fail on the same files?

By the way, are you familiar with Docker? I might ask you to jump into the container and run ffmpeg manually to check the debug output.

So first start the container but drop into a shell command
docker run -it --entrypoint /bin/bash stevezzau/plex_generate_vid_previews:latest

Then within the container run the below which failed in your previous run.
/usr/local/bin/ffmpeg -loglevel info -skip_frame:v nokey -threads:0 1 -i "/media/Anime/86 Eighty Six/Season 1/86 Eighty Six - S01E15- Welcome Back.mkv" -an -sn -dn -q:v 4 -vf fps=fps=0.1:round=up,scale=w=320:h=240:force_original_aspect_ratio=decrease /tmp/previews/22865b72ec1417ab5ddb79d60b463505dade1024/img-%06d.jpg

@planetrocky
Copy link

planetrocky commented Feb 20, 2025

In all my experience (months of testing), FFMPEG will terminate very quickly and you will see the exact error you have. I actually thought I had a bug in my code for a very long time!

This is a crash internally in the FFMPEG HEVC packet processor.

For example, using this build of ffmpeg version 2025-02-13-git-19a2d26177-full_build-www.gyan.dev will fail on certain types of HEVC files.

Extracting the errors from FFMPEG log, will yield this at the very start of the file.

[vist#0:0/hevc @ 00000278013f9640] [dec:hevc @ 00000278013f08c0] Error processing packet in decoder: File exists
[vist#0:0/hevc @ 00000278013f9640] [dec:hevc @ 00000278013f08c0] Task finished with error code: -17 (File exists)
[vist#0:0/hevc @ 00000278013f9640] [dec:hevc @ 00000278013f08c0] Terminating thread with return code -17 (File exists)
[vost#0:0/mjpeg @ 00000278061a3180] [enc:mjpeg @ 0000027810c91a00] Could not open encoder before EOF
[vost#0:0/mjpeg @ 00000278061a3180] Task finished with error code: -22 (Invalid argument)
[vost#0:0/mjpeg @ 00000278061a3180] Terminating thread with return code -22 (Invalid argument)
[out#0/image2 @ 00000278050954c0] Nothing was written into output file, because at least one of its streams received no packets.

@planetrocky
Copy link

planetrocky commented Feb 20, 2025

Hi @planetrocky,

Looks like version 7.0.1 in the container: I have no name!@505241cadcb3:/app$ ffmpeg -version ffmpeg version 7.0.1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13 (Ubuntu 13.2.0-23ubuntu4) configuration: --disable-debug --disable-doc --disable-ffplay --enable-alsa --enable-cuvid --enable-ffprobe --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libfdk_aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libplacebo --enable-librav1e --enable-librist --enable-libshaderc --enable-libsrt --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nonfree --enable-nvdec --enable-nvenc --enable-cuda-llvm --enable-opencl --enable-openssl --enable-stripping --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100

Thank you!

FFMPEG Version

It does depend upon the CODEC and container that is causing FFMPEG to terminate. I've a broad range of test-material, and have found different bugs across a range of different FFMPEG versions.

Please try ffmpeg version 7.1 (some of my test cases succeed in 7.01, but not all)

However don't try any nightly builds from January 2025 onwards, as they will fail a lot on HEVC video.

Last known good nightly build of FFMPEG

The last known good version I have is:

ffmpeg-2025-01-08-git-251de1791e.exe -version
ffmpeg version 2025-01-08-git-251de1791e-full_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 14.2.0 (Rev1, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-lcms2 --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1 --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-liblc3 --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil      59. 54.101 / 59. 54.101
libavcodec     61. 31.100 / 61. 31.100
libavformat    61.  9.104 / 61.  9.104
libavdevice    61.  4.100 / 61.  4.100
libavfilter    10.  6.101 / 10.  6.101
libswscale      8. 13.100 /  8. 13.100
libswresample   5.  4.100 /  5.  4.100
libpostproc    58.  4.100 / 58.  4.100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants