nicknsy / jellyscrub

Smooth mouse-over video scrubbing previews for Jellyfin.
MIT License
668 stars 27 forks source link

I want to know why the speed of generating bif is so slow? #53

Closed shanyan-wcx closed 1 year ago

shanyan-wcx commented 1 year ago

I have about 150 1080p movies and 40 1080p dramas/animes. However, after two days and two nights, only 20% of them have been generated.

nicknsy commented 1 year ago

Likely because you are in slow hardware. With an 8 core i7 cpu it takes me about 1-2 min for a 2 hr movie, and on an older 6 core cpu it takes me about 5 minutes. If you're on something slower it could easily take 20-30+ minutes for a single bif file, which means 50-75+ hours for 150 movies. Also, if you have 40 tv series and each of those is an hour long an episode, that adds a significant amount of time.

NeuroDawg commented 1 year ago

Will you be introducing hardware acceleration for this plugin, for those of use with slow(er) CPUs but shiny, fast GPUs?

gaming09 commented 1 year ago

I am on a ryzen 9 5900x and its been 3 hours and im at .2%

set the threads to 12 in the settings (which should be 24 total since its *2) IE 0

[2023-01-03 13:10:17.111 -08:00] [INF] [44] Nick.Plugin.Jellyscrub.Drawing.OldMediaEncoder: /usr/lib/jellyfin-ffmpeg/ffmpeg -f matroska,webm -threads 0 -i file:"/JFMOVIES/MOVIENAMEREDACTED (2022)/MOVIENAMEREDACTED (2022) -1080p 5.1.mkv" -threads 0 -v quiet -filter:v fps=1/10,scale=min(iw\,320):trunc(ow/dar/2)*2 -f image2 "/cache/temp/0a7399c51516442fa9a1c155f4b1feb0/img%08d.jpg"

gaming09 commented 1 year ago

image

nicknsy commented 1 year ago

How much media is in your library? .2% of 10000 for instance isn't bad. Look at the log and see what time the generation starts and ends for a single movie--on that cpu I would expect it to go through about an hour of content per minute or so granted that ffmpeg is maxing it out. You could also verify with something like top that the ffmpeg process is actually using all available cores.

nicknsy commented 1 year ago

Will you be introducing hardware acceleration for this plugin, for those of use with slow(er) CPUs but shiny, fast GPUs?

Yes, I'm still looking into it. Development is just a slow since GPU acceleration isn't personally make or break for me so I haven't had a ton of motivation to implement it.

gaming09 commented 1 year ago

How much media is in your library? .2% of 10000 for instance isn't bad. Look at the log and see what time the generation starts and ends for a single movie--on that cpu I would expect it to go through about an hour of content per minute or so granted that ffmpeg is maxing it out. You could also verify with something like top that the ffmpeg process is actually using all available cores.

6,161 Total Media Items:

2hr 42min runtime Start: [2023-01-03 15:58:23.254 -08:00]

Finish: [2023-01-03 16:08:42.815 -08:00]

You're right that's not terrible ill stfu. Can I buy you a cup of coffee? Donate to your project?

nicknsy commented 1 year ago

How much media is in your library? .2% of 10000 for instance isn't bad. Look at the log and see what time the generation starts and ends for a single movie--on that cpu I would expect it to go through about an hour of content per minute or so granted that ffmpeg is maxing it out. You could also verify with something like top that the ffmpeg process is actually using all available cores.

6,161 Total Media Items:

2hr 42min runtime Start: [2023-01-03 15:58:23.254 -08:00]

Finish: [2023-01-03 16:08:42.815 -08:00]

You're right that's not terrible ill stfu. Can I buy you a cup of coffee? Donate to your project?

Hmm... 10 minutes for a 3 hour movie seems very long given your cpu. Just tested with an i7-8700k and a 1hr 30m video took exactly 1m30s to complete the extraction of images. I wonder if something like the video codec could make it take much longer to decode with the cpu. Are most of your videos hevc? Even then, I don't know if that would increase time by a factor of 3.

Also, I really appreciate the offer of a donation, but I have nothing setup up to accept stuff like that. I think jellyfin itself has a contribution page if you'd want to take a look at that.

gaming09 commented 1 year ago

How much media is in your library? .2% of 10000 for instance isn't bad. Look at the log and see what time the generation starts and ends for a single movie--on that cpu I would expect it to go through about an hour of content per minute or so granted that ffmpeg is maxing it out. You could also verify with something like top that the ffmpeg process is actually using all available cores.

6,161 Total Media Items: 2hr 42min runtime Start: [2023-01-03 15:58:23.254 -08:00] Finish: [2023-01-03 16:08:42.815 -08:00] You're right that's not terrible ill stfu. Can I buy you a cup of coffee? Donate to your project?

Hmm... 10 minutes for a 3 hour movie seems very long given your cpu. Just tested with an i7-8700k and a 1hr 30m video took exactly 1m30s to complete the extraction of images. I wonder if something like the video codec could make it take much longer to decode with the cpu. Are most of your videos hevc? Even then, I don't know if that would increase time by a factor of 3.

Also, I really appreciate the offer of a donation, but I have nothing setup up to accept stuff like that. I think jellyfin itself has a contribution page if you'd want to take a look at that.

100% of my non 4k(4k theres only about 8 videos) videos are MPEG-H Part2/HEVC (H.265) (hevc)

gaming09 commented 1 year ago

How much media is in your library? .2% of 10000 for instance isn't bad. Look at the log and see what time the generation starts and ends for a single movie--on that cpu I would expect it to go through about an hour of content per minute or so granted that ffmpeg is maxing it out. You could also verify with something like top that the ffmpeg process is actually using all available cores.

6,161 Total Media Items: 2hr 42min runtime Start: [2023-01-03 15:58:23.254 -08:00] Finish: [2023-01-03 16:08:42.815 -08:00] You're right that's not terrible ill stfu. Can I buy you a cup of coffee? Donate to your project?

Hmm... 10 minutes for a 3 hour movie seems very long given your cpu. Just tested with an i7-8700k and a 1hr 30m video took exactly 1m30s to complete the extraction of images. I wonder if something like the video codec could make it take much longer to decode with the cpu. Are most of your videos hevc? Even then, I don't know if that would increase time by a factor of 3.

Also, I really appreciate the offer of a donation, but I have nothing setup up to accept stuff like that. I think jellyfin itself has a contribution page if you'd want to take a look at that.

Run time 2h7m

2023-01-04 11:37:49.054 -08:00] [INF] [37] Nick.Plugin.Jellyscrub.Drawing.VideoProcessor: Creating trickplay files at 320 width, for "/JF_MOVIES/movie (2012)/movie (2012) HDTV-2160p 7.1.mkv" [ID: 708eef80-8c7d-2290-b61f-37dbd6f68ef0]

fps=1/10,scale=min(iw\,320):trunc(ow/dar/2)*2,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0:peak=100,zscale=t=bt709:m=bt709,format=yuv420p -f image2 "/cache/temp/9821fbe3ae5649e7b5db776559b9906e/img_%08d.jpg"

[2023-01-04 12:11:44.342 -08:00] [INF] [40] Nick.Plugin.Jellyscrub.Drawing.VideoProcessor: Finished creation of trickplay file "/JF_MOVIES/movie(2012)/trickplay/movie (2012) HDTV-2160p 7.1-320.bif"

thats a long time, Im doing it in Unraid so i cant set the CPU priority but nothing else is really running

nicknsy commented 1 year ago

How much media is in your library? .2% of 10000 for instance isn't bad. Look at the log and see what time the generation starts and ends for a single movie--on that cpu I would expect it to go through about an hour of content per minute or so granted that ffmpeg is maxing it out. You could also verify with something like top that the ffmpeg process is actually using all available cores.

6,161 Total Media Items: 2hr 42min runtime Start: [2023-01-03 15:58:23.254 -08:00] Finish: [2023-01-03 16:08:42.815 -08:00] You're right that's not terrible ill stfu. Can I buy you a cup of coffee? Donate to your project?

Hmm... 10 minutes for a 3 hour movie seems very long given your cpu. Just tested with an i7-8700k and a 1hr 30m video took exactly 1m30s to complete the extraction of images. I wonder if something like the video codec could make it take much longer to decode with the cpu. Are most of your videos hevc? Even then, I don't know if that would increase time by a factor of 3. Also, I really appreciate the offer of a donation, but I have nothing setup up to accept stuff like that. I think jellyfin itself has a contribution page if you'd want to take a look at that.

Run time 2h7m

2023-01-04 11:37:49.054 -08:00] [INF] [37] Nick.Plugin.Jellyscrub.Drawing.VideoProcessor: Creating trickplay files at 320 width, for "/JF_MOVIES/movie (2012)/movie (2012) HDTV-2160p 7.1.mkv" [ID: 708eef80-8c7d-2290-b61f-37dbd6f68ef0]

fps=1/10,scale=min(iw,320):trunc(ow/dar/2)*2,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0:peak=100,zscale=t=bt709:m=bt709,format=yuv420p -f image2 "/cache/temp/9821fbe3ae5649e7b5db776559b9906e/img_%08d.jpg"

[2023-01-04 12:11:44.342 -08:00] [INF] [40] Nick.Plugin.Jellyscrub.Drawing.VideoProcessor: Finished creation of trickplay file "/JF_MOVIES/movie(2012)/trickplay/movie (2012) HDTV-2160p 7.1-320.bif"

thats a long time, Im doing it in Unraid so i cant set the CPU priority but nothing else is really running

Yeah if there's nothing else happening and nothing restricting cpu usage in unraid then it might just be that slow. Especially with 4k & hevc content which would take longer to decode and probably longer to scale in software. I personally don't have any 4k content to test with, but that's my best guess.

memehammad commented 1 year ago

i'm using a ryzen 9 5900x and ffmpeg is only using 30-40% of my cpu. ive set the threads to 24, but that doesnt seem to change anything. any ideas on how i can make it use 100%?

solemgar commented 1 year ago

@nicknsy Confirming here that with a NUC with a J4005 without hw acceleration takes a long time to create a bif file. Hope it can be implemented soon!

I see the plugin structure is basically a dll? Is there a way we can play with the ffmpeg params ourselves to try to set hw acceleration ? I really appreciate your work on the plugin, it is really cool!

I am not super expert in coding, but if I want to do some experiments, is ok if I fork the project? Which version of visual studio are you using for the sln?

nicknsy commented 1 year ago

I believe I use VS2022, though I've just added hardware acceleration so hopefully that helps. I'll be closing this for now but feel free to create another issue if something comes up.