keijiro / KlakHap

HAP video player plugin for Unity
Other
341 stars 27 forks source link

Videos encoded with the -chunks flag in ffmpeg cause Unity to silently crash on play #2

Closed kkukshtel closed 5 years ago

kkukshtel commented 5 years ago

Just tested out the HAP player. Was using this command to encode videos: ffmpeg -i "C:\Users\kyle\Desktop\working folder\keijiro-dk-test\Assets\Depthkit\Examples\Clips\Julianne\Julianne.mp4" -codec:v hap -format hap -chunks 8 "C:\Users\kyle\Desktop\working folder\keijiro-dk-test\Assets\StreamingAssets\Julianne.mov"

Unity kept crashing on start. I traced the issue to the DLL but obviously couldn't peek inside of it. I tried different encode presets and eventually found that the same command worked as long as I didn't specify chunk amount:

ffmpeg -i "C:\Users\kyle\Desktop\working folder\keijiro-dk-test\Assets\Depthkit\Examples\Clips\Julianne\Julianne.mp4" -codec:v hap -format hap "C:\Users\kyle\Desktop\working folder\keijiro-dk-test\Assets\StreamingAssets\Julianne1.mov"

Would love chunk support as to better control video decoding!

keijiro commented 5 years ago

Thank you for reporting the issue. Actually, I have never used the chunk feature with HAP. So I'm not sure what happened in it... I think it's related to the threaded uncompressing method that hasn't been implemented for the plugin yet.

I'll look into it. At least I should fix the crash.

Just curious, what's the motivation for using the chunk feature? Is it actually effective in some applications?

keijiro commented 5 years ago

I tried fixing the issue. Please replace KlakHap.dll in your project directory with the following file and check if it works.

KlakHap.dll.zip

Although the issue was fixed, it hasn't been threaded yet. There is no merit for using chunks at the moment.

kkukshtel commented 5 years ago

Thanks for getting back! I'll try this fix out today.

With regards to chunks, we needed them for a project that we used HAP on and needed to render ~12 2K videos at a time. Setting a chunk amount resulted in a more performant scene for us vs. non-chunked encodes.

For this reason we used AVProVideo, as it currently supports this (Section 4.6.3). Would definitely love to see your player support it as well!

keijiro commented 5 years ago

KlakHap uses one thread per one decoder. So if you're playing 12 2K videos at a time, it utilizes multiple cores up to 12 cores. If you have more than 12 cores on your system, it might be better to use chunks.

kkukshtel commented 5 years ago

Oh interesting. I'm assuming here one decoder = one Monobehavior component? I haven't stress tested KlakHap against AVPro considering this — would be interesting to see!

keijiro commented 5 years ago

The fix was merged in the latest release.

https://github.com/keijiro/KlakHap/releases/tag/v0.1.4

keijiro commented 5 years ago

I'm closing this issue. Please feel free to reopen for further issues or questions.