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
[guilib] Add animated image/texture support via ffmpeg. #8937
Conversation
Hi @ace20022 thx much. Currently ill and not that fit. Can check over the weekend. Android keeps me busy currently. |
@fritsch np. Get well soon! |
😢 libgif can die now 😢 |
7d1b960
to
fe7af97
Compare
personally want to thank you guys for finally bringing ANPG support to Kodi. Willing to test this if you create a test build - either way look forward to enjoying this at some future point in Kodi. Many thanks again for all your hard work! 😄 |
Which platform do you need @mgonzales71 ? @ace20022 i have not forgotten to review but still busy with AudioTrack - sorry for that! |
@fritsch using Kodi on Win 10 x64 Pro mainly here, also occassionally on Android (ARM) so can test both if needed. |
np, I'm still hunting a mem leak, hoping that it's not in ffmepg's png decoder (Valgrind indicates that) @fritsch @mgonzales71 don't use a build of the pr in this state! A build is only useful without the two leak check commits. |
@ace20022 I am fine with waiting once you squash mem leak(s) FYI - a great collection of APNG resource info - http://littlesvr.ca/apng/ for the interested |
@fritsch thx for the review, found two leaks, an old one and a new one ;) jenkins build this please |
On Pi (RPi2) and also x86, with this PR the pngs ( Were you expecting animation? It could be an OpenELEC issue, although I added Looking in the texture cache, the cached version of the 20MB+ |
@ace20022 could you show me the leaks that you fixed? |
@@ -395,6 +474,7 @@ bool CFFmpegImage::Decode(unsigned char * const pixels, unsigned int width, unsi | |||
} | |||
pictureRGB->data[0] = nullptr; | |||
avpicture_free(pictureRGB); | |||
av_free(pictureRGB); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@MilhouseVH sorry, should have been more precise. They work as (skin) textures, like posters, background, etc. Simplest test is to set it as background in confluence (somewhere in the skin settings). |
Heh, seems to be working on the RPi2. I've set the Confluence "custom background" path to one of the apng's and I now have animated skiing ostriches as my backdrop... Total CPU load is pretty reasonable, about 4-5% on a 1GHz ARM RPi2 (~20% on one core) for the skiing ostriches apng. It has used a fairly large chunk of GPU memory to load the apng - from 240MB free to only 140MB free. The size of this file is 15MB. Falling snow consumes only about 10MB GPU RAM, presumably as this is a much smaller apng (fewer frames? lower resolution?) weighing in at only 637KB. However HQ animated pixel art landscape, a 17MB apng, consumes all available GPU memory (from 240MB free to 1MB free) yet almost 600MB of non-GPU RAM remains available. Unsurprisingly Kodi becomes unusable with this png as a background. Animated pngs seem to be working, but are likely to cause memory issues on systems with limited GPU memory. Is there any reason why GPU memory is being used in favour of non-GPU RAM - if it's loading as a texture that might explain it. |
Sorry for my ignorance with the workings of Jenkins but from what I can gather from http://jenkins.kodi.tv/job/BuildMulti-PR/4321/ the Windows test build of the PR failed? Well marked "unstable" actually... but regardless - not sure of where to download a test binary other then mirrors.kodi.tv /nightlies or /test-builds when one is available to download and test. Apologies if I missed an obvious download location for the Kodi Win Setup that the PR test build console output says is located at c:\jenkins\slave\workspace\WIN-32\project\Win32BuildSetup\KodiSetup-20160128-df84916-HEAD.exe 😀 Thanks :) |
Nearly :-) Currently the whole mirror is down. 2016-01-29 7:10 GMT+01:00 Anton Fedchin notifications@github.com:
Fingerprint: 4606 DA19 EC2E 9A0B 0157 C81B DA07 CF63 1A99 5A9B |
@fritsch it works for me. |
Nice - @kib also fixed it for the whole world some minutes ago. 2016-01-29 7:55 GMT+01:00 Anton Fedchin notifications@github.com:
Fingerprint: 4606 DA19 EC2E 9A0B 0157 C81B DA07 CF63 1A99 5A9B |
@MilhouseVH that one https://i.imgur.com/q2SSe9S.png (probably the biggest one) needs almost 3gb ram for decoding, after some seconds it's only 16 mb or so for the kodi process, overall is still high. I have no clue how windows handles that. The gpu mem is almost completely used. This apng has 91 frames á 3840x2160 pixels, i.e. 91*33mb = 3003 mb. The only thing I could do is to add an upper bound for the memory to be used and limit the number of frames accordingly. Until I'm in the mood to implement on demand frame extraction/caching. |
It seems quite easy for an animated png to exhaust texture memory and potentially kill kodi (if it doesn't crash immediately any subsequent gui elements will fail to allocate and so not be visible making kodi pretty much unusable). On demand extraction sounds like a better solution. q2SSe9S.png is only 10MB as a png, but seems to expand 30 times when decoded. On-demand extraction may increase CPU usage significantly, but that still seems like a better solution (at least for files larger than some threshold). High cpu seems better than exhausted memory and unusable kodi. |
@ace20022 Thanks for the link - also the png ( https://i.imgur.com/q2SSe9S.png ) brings Firefox to it knees even on Windows but like others have noted apngs seems to eat up texture mem quickly. For what it's worth the use I see for apng's in Kodi are obviously for skin's - add-on icons, clearart, clearlogo, character art, home tile/menu graphics and various skin elements (progress, buttons, weather icon, fanart, controls, etc) I would expect these uses to be small to modest in size but could be numerous. The other use would be backgrounds and that is where things could get ugly - depends on the apng.. badly created/pooly optimized images being the most likely flame for that fire. silly question as I am sure that all the options were looked into but is ffmpeg's the best implementation of apng support for Kodi? I will keep testing and provide feedback of any problems I run into on Windows.. thanks for finally adding apng support - kudos to all the devs for all your hard works. it's apprecited very much. |
Do you know a better solution that works on all platforms we run? Adding no overhead to the code we maintain? If you find one, let us know. |
@fritsch meant no disrespect I hope that wasn't how that Q came across. Apologies if I did. I have nothing but praise for all your hard work. My go to link for APNG info has been http://littlesvr.ca/apng/ and that has been mostly from a user standpoint - they do have a dev section but I am not qualified to determine suitable criteria for potential use in Kodi. |
The problem is not ffmpeg, but the raw decoded buffers we keep in memory at once, when decoding the whole apng. |
APNG's(like animated gifs) are absolutely not designed for large backgrounds or textures. Those kind of effects should be done using the video player just like machines like the PS3 do. Far better suited to small images like buttons or thumbnails. Saying that, it would be nice for it to fail gracefully. |
@popcornmix are you okay, with a limit of 12 full hd frames, approx. 8 mb each, till I have the motivation to implement the on demand loading? btw currently I have limited gifs to 10 full hd frames. |
To prevent confusion in things like the animated thumbnail posters thread, could it be made equal to gifs? |
…coded list for image selection.
Added a limit of 12 full hd frames, memory-wise. Any objections? jenkins build this please |
standard win32 addon failure. I'll merge it tonight. |
Jep, go for it. Btw. we can sit together afterwards and see how we can adjust the work to the upcoming ffmpeg API, which deprecates a whole lot of methods we actively use. Some easy to replace others a bit more problematic. |
maybe stupid question. giflib is still (conditionaly) used in imagefactory. is this supposed to be cleaned up ? (I'll do if you say so @ace20022) EDIT: yep. if giflib is present, the ffmpeg code path is not used. here it is: stefansaraev@b8c6876 (force pushed) |
Thx, I already had that, https://github.com/ace20022/xbmc/commits/remove_giflib . It' s still needed by the texture packer... |
yep, texturepacker needs giflib-native. dont bother picking if it breaks build, I'll take care of it later. |
[guilib] Add animated image/texture support via ffmpeg.
Warning: In its current state, this pr can cause memleaks and out of memory crashes.