K22R8CT 25 Posted July 19, 2023 Posted July 19, 2023 As I've re-encoded my library to HEVC I've noticed extremely slow thumbnail generation - a single one takes 15-20 minutes. Running the command (from the logs) manually these are the kinds of speeds I see: Skip-Option - SKIP output: skip_pos:0 input_pts_time:0 rebased:0 Skip-Option - Write output: pkt_pts_time:0 pkt_dts_time:0 input_pts_time:10.448=N/A throttle=off speed= 0x Skip-Option - Write output: pkt_pts_time:10 pkt_dts_time:10 input_pts_time:20.875/A dup=0 drop=1 throttle=off speed= 0x Skip-Option - Write output: pkt_pts_time:20 pkt_dts_time:20 input_pts_time:31.302/A dup=0 drop=1 throttle=off speed=0.542x Skip-Option - Write output: pkt_pts_time:30 pkt_dts_time:30 input_pts_time:41.729/A dup=0 drop=1 throttle=off speed=0.793x elapsed=00:00:27.11 frame= 4 fps=0.1 q=1.6 Lsize=N/A time=00:00:30.00 bitrate=N/A dup=0 drop=1 throttle=off speed=1.11x It appears this part is the culprit: select='eq(pict_type,PICT_TYPE_I)' If I remove it speed goes to more than 30x Apparently an equivalent for selecting iframes is: -skip_frame nointra With that (and no "select") speed is about 150x My questions are: 1. Are they equivalent or close enough? 2. Is there some way I can hack it in? As is, it'd take months to generate thumbnails for all my media, effectively unusable.
Luke 42081 Posted July 19, 2023 Posted July 19, 2023 Hi, can you please attach a log file example? thanks. 1
rbjtech 5284 Posted July 19, 2023 Posted July 19, 2023 8 hours ago, K22R8CT said: 2. Is there some way I can hack it in? Yes - install the 'Emby Diagnostics' plugin - and then use the 'Parameter Adjustment' to 'search and replace' the syntax you want to try. This works for any ffmpeg command. But ideally - try and provide the logs to get it fixed. I have not noticed any performance issues with HEVC files. 1
K22R8CT 25 Posted July 19, 2023 Author Posted July 19, 2023 1 hour ago, rbjtech said: install the 'Emby Diagnostics' plugin - and then use the 'Parameter Adjustment' to 'search and replace' the syntax you want to try. Either I've done something wrong or it doesn't apply to thumbnail-generation: Resultant command (no "skip_frame") 2023-07-19 07:48:25.340 Info App: ProcessRun 'quick-extract-imageseries' Execute: /bin/ffmpeg -f mp4 -threads 1 -skip_interval 10 -copyts -i file:"/media/Movies/Default/Movie.mp4" -an -sn -vf "select='eq(pict_type,PICT_TYPE_I)',scale=w=320:h=180" -vsync cfr -r 0.1 -f image2 "/config/cache/temp/a8a64408e49d4e2da992f967c7231ee0/img_%05d.jpg" 1 hour ago, rbjtech said: But ideally - try and provide the logs to get it fixed. Aside from entries like the one above I don't see anything thumbnail-related in the logs. Are they in another log? Do I have to increase the log level? I've played around some and it looks like the slowness is video-specific. HEVCs I've encoded myself (8 bit) seem fine. The common element with the problem files is yuv420p10le Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, bt709, progressive) But I'll test more to confirm. 1
rbjtech 5284 Posted July 19, 2023 Posted July 19, 2023 If you turn on debug logging - you should get a seperate 'quick-extract-imageseries-x' log It's been a while since I modified the ffmpeg for the thumbs (cheesegeezer and I eventually put it in a plugin, now in the core) but I may have been mistaken and this not work via the Parameter Adjustment - it may just be for transcoding. Let me double check. An example file is below - you can just extract the command line - and run it manually. If you get 100's of images in the folder specified (or specify a temp folder) - then you can see if it works quickly vs what emby is doing. quick-extract-imageseries 2023-07-19 12:37:39.979 Application version: 4.8.0.39 C:\Emby-Server\system\ffmpeg.exe -f matroska -threads 1 -skip_interval 10 -copyts -i file:"\\media\YouTube\Subscriptions\securitynow\Security Now\001 - Satellite Insecurity, Part 1 - Kaspersky on MS flaw, WormGPT, Bitcoin addresses, Twitter DM change.mkv" -an -sn -vf "scale=w=320:h=180" -vsync cfr -r 0.1 -f image2 "O:\Emby\cache\temp\4493ba42def5476385f2dcf7480c0431\img_%05d.jpg" ffmpeg version 5.1-emby_2023_04_28 Copyright (c) 2000-2022 the FFmpeg developers and softworkz for Emby LLC built with gcc 12.2.0 (Rev10, Built by MSYS2 project) .................. Adding @softworkz as he was involved with the HDR BIF discussions and should be able to provide some assistance for this HEVC pixel/profile.
K22R8CT 25 Posted July 19, 2023 Author Posted July 19, 2023 2 hours ago, rbjtech said: An example file is below - you can just extract the command line - and run it manually. If you get 100's of images in the folder specified (or specify a temp folder) - then you can see if it works quickly vs what emby is doing. Maybe I'm misreading your comment but I've run the commands manually to experiment with parameters. Running them exactly as they are in the log gets the same poor performance. 2 hours ago, rbjtech said: If you turn on debug logging - you should get a seperate 'quick-extract-imageseries-x' log That did it, thanks. Attached. If the measurement fps=0.3 is analogous to transcoding speed that seems very bad. quick-extract-imageseries-6e4503e0-4901-4b6e-b884-a8d575b6def3_1.txt.zip 1
softworkz 5072 Posted July 20, 2023 Posted July 20, 2023 12 hours ago, K22R8CT said: If the measurement fps=0.3 is analogous to transcoding speed that seems very bad. Well - that's the fps of the frames being output, i.e. your thumbnail images. The speed is 2.9x and the framerate 24 fps, that makes a processing speed of 70 fps (input frames). The pict_type filter is only applied when the container is MP4. The reason is that with MP4 there are problems with keyframe seeking. I don't remember whether this was generally with MP4 or just with certain MP4 files, but even in the latter case - we can't know this in advance and so we have to apply this filter always for MP4 files. Using -skip_frame might be faster, but I'm almost certain that you won't get accurate results this way (first compare the number of images output, then compare the images at certain positions). My recommendation is: Use MKV as container Encode the video with keyframes at a constant frequency (3 or 6 seconds), even when the files get a bit larger. 1 1
softworkz 5072 Posted July 20, 2023 Posted July 20, 2023 18 hours ago, rbjtech said: Yes - install the 'Emby Diagnostics' plugin - and then use the 'Parameter Adjustment' to 'search and replace' the syntax you want to try. This works for any ffmpeg command. It doesn't work for image extraction... 1
K22R8CT 25 Posted July 20, 2023 Author Posted July 20, 2023 8 hours ago, softworkz said: My recommendation is: Use MKV as container I wish I'd known that weeks ago before I began converting my whole library to mp4 But it's an apple environment so at least for streaming purposes mp4 is defensible. 8 hours ago, softworkz said: Using -skip_frame might be faster, but I'm almost certain that you won't get accurate results this way (first compare the number of images output, then compare the images at certain positions). Will do. Assuming I find a good-enough fix is there some undocumented method to customize thumbnail generation?
roaku 842 Posted July 20, 2023 Posted July 20, 2023 1 hour ago, K22R8CT said: I wish I'd known that weeks ago before I began converting my whole library to mp4 But it's an apple environment so at least for streaming purposes mp4 is defensible. By the way, MKVToolnix can make the conversion to mkv pretty quick and painless. You don't need to re-rip or reencode anything. It can just copy the contents of an mp4 to a new mkv container. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now