ATV2 with subtitles enabled causes lag
#31
So I'll come right out and qualify my next question, I'm no expert on jailbreaking. I know how to follow the process so I might be asking about something obvious.

How does xbmc play video and subtitles on the atv2? I thought (probably incorrectly) that it would take the stream and subtitle file, feed it through ffmpeg to generate video and then finally to the dvdplayer application to display the video.

If that isn't the case, maybe someone can do a brief "how do subtitles work" so we can get a bit better base of understanding and maybe come up with some ideas.
Reply
#32
tarjan Wrote:So I'll come right out and qualify my next question, I'm no expert on jailbreaking. I know how to follow the process so I might be asking about something obvious.

How does xbmc play video and subtitles on the atv2? I thought (probably incorrectly) that it would take the stream and subtitle file, feed it through ffmpeg to generate video and then finally to the dvdplayer application to display the video.

If that isn't the case, maybe someone can do a brief "how do subtitles work" so we can get a bit better base of understanding and maybe come up with some ideas.

Depends on the video format and type of subtitle. What you ask is in the source code. There are many code paths and it's the same code paths as for desktop with the exception that h264 decoding is handled by vtb for ios/atv2.
Reply
#33
tarjan Wrote:So I'll come right out and qualify my next question, I'm no expert on jailbreaking. I know how to follow the process so I might be asking about something obvious.

How does xbmc play video and subtitles on the atv2? I thought (probably incorrectly) that it would take the stream and subtitle file, feed it through ffmpeg to generate video and then finally to the dvdplayer application to display the video.

If that isn't the case, maybe someone can do a brief "how do subtitles work" so we can get a bit better base of understanding and maybe come up with some ideas.

See the render methods in this class (this is the lowlevel render function which renders the subtitle overlay onto the video frame when called from dvdplayer):

https://github.com/xbmc/xbmc/blob/master...nderer.cpp

And work yourself through into the upper layers for getting an understanding. See https://github.com/xbmc/xbmc/tree/master.../dvdplayer for the complete dvdplayer code used for all movies.

Your ffmpeg theory is wrong.

If you think you can help (which would be appreciated alot) - you should be able to dig into the code yourself. Everything else is a waste of our (devs) time.

Writing this post already took me 10 minutes. So please be fair and at least try something with it.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#34
Memphiz, while I am no developer my job does have me work with many development resources. I understand and greatly appreciate the responses and will see what I can see.

I'm sure someone who really understands the underlying will see this and be able to take a deeper look than I now that we have a clear starting point, so I don't think it was a waste of your time.
Reply
#35
Hi guys, I can assure this is not only happening on the ATV2 but also on an iPad2 running iOS 5.0.1 (Apple TV Second Generation: 4.4.4 Based on iOS 5.0.1 wikipedia).
I found it really surprising since it all worked on the 4.3.3 JB. I never updated until a few weeks ago when 5.0.1 got jailbroken so I could install XBMC immediately.
This is kind of weird and I also think it has something to do with iOS itself.

First of all, it is noticable that I don't use twitter/facebook/w/e in my notification center. I even removed ALL apps from the notification center except for the calendar app.

Secondly, I have all location services turned off, no 3G and bluetooth turned off if that should cause any performance issue. Mail app is not used so doesn't fetch anything and iCloud is not used. Facetime is also turned off.
This would leave only SBSettings that's running constantly in the background with Activator I guess.

Then the video I am trying to playback is this:
http://pastebin.com/bdjzBqMu (mediainfo log)
http://dl.dropbox.com/u/40617370/%5BTh3a...0D7%5D.mkv
The video is played on the device itself (I'm kind of against streaming because you can just play on the PC itself that you stream on. Why stream if the iPad2 is capable of doing things itself and enjoy everything on the go?)

This video used to play smoothly without any lags with the subtitles turned on on 4.3.3 on the nightlies since november till Eden 11b1. (Later releases were released when I went over to iOS 5.0.1)

Some findings about this video:
The xbmc.log:
http://pastebin.com/6z5UsibD

The video would lag somewhere around 00:30 (mmConfuseds)
The xbmc.log would then show the warning

11:55:29 T:804790272 WARNING: CRenderManager::FlipPage - timeout waiting for previous frame
11:55:29 T:71880704 WARNING: Previous line repeats 1 times.
11:55:29 T:71880704 ERROR: Get - failed to get stream

Note that when this video is played, you clearly see the grey color buffer ahead of the playback, so this shouldn't be an issue.

I also experimented:

- Rebooting iOS (I thought there were some weird issues)

- Restore -> Re-jailbreak -> reinstall XBMC (because I was afraid there were some failures of the CPU because of iOS or so)

- Turning the subtitles off, and that would play the video flawlessly. Unfortunately, I can't understand japanese :p.

- Playing the video with another fansubber's subtitles. This was quite interesting because it would lag around another time.

- Switching the mkv container into an m4v container and changed the FLAC audio into ALAC with external subs. This unfortunately shows the same symptoms as the original mkv file. Although the m4v CAN be played outside XBMC (i.e. iFile/GoodReader/web viewer).

- Use an advancedgui.xml to turn on skiploopfilter (tried values 8, 16 and 32) in the hope that some frames might be skipped to get normal playback again. This only causes XBMC to buffer faster which is good, but for some reason playback is still laggy.


I don't know if this is supposed to show, but when you go to Settings -> System info -> Hardware the CPU is blank at it doesn't really show whether it has a second CPU or not. When debug logging is enabled however it says:
CPU: CPU0: 0.0% CPU1: 0.0% (CPU-XBMC XX.YY%) so this also shouldn't be the issue.

I also have all addons disabled in XBMC (by removing all metadata involving addons in XBMC.app/XBMCData/XBMCHome/addons/) so XBMC wouldn't load anything unnecessary to only view videos.
The skin I use is Touched, Navigation sounds turned off, no thumbnailing, No vertical blank sync, Audio output on Optical/Coax. Just everything you can imagine to let XBMC be minimalistic.

My theory is that because iOS 5.0.1 is also using some GPU resources now and hardware acceleration to make iOS run smooth, the video memory or whatever was used is partially taken and causes this lag.

So... I think the text was quite long, but I hope it will help you guys fix the problem. And for your information, I'm a 3rd year computer science student. And I'm quite new to development of video applications, so I doubt I can be of much help if I were to dive into your code.

Thanks in advance!

UPDATE:
So I was browsing cydia and saw that you can install "top".
I installed it and ssh'd from my computer to my ipad, ran top and on launched XBMC to play the video. The CPU info said ~57% around the lag while XBMC CPU said 95-101% XBMC-CPU usage. Maybe this is something that could be fixed too.
Reply
#36
hmm, this is weird but it seems like i'm having the same issue ONLY with sub/idx subs.
srt subs on same movie (actually, same tv series episode) work fine.

ios 4.1 /eden beta 3
Reply
#37
HAH biGdada! You have the answer!

It isn't perfect, but it points us at a workaround. I just pulled the .ass file out of the temp directory that the crunchyroll plugin builds and ran it through a python script I found elsewhere that converts from .ass to .srt. Then I hardcoded the crunchyroll app to point at the .srt file. After that I get solid 24fps (which is correct for the video) and I haven't seen the cpu-xbmc get above the mid 60% range and there is absolutely no lag anywhere.

Of course now EVERYTHING I watch through crunchyroll would have the same subtitles, but hey we are getting somewhere. Smile

So back to the development issue, I have no idea why srt would work and other formats would cause it to grind to an absolute halt. Might be something where we just have to kludge it together by converting to srt since it works,until we understand how to resolve the underlying issue.

I got the script from : http://doom10.org/index.php?topic=916.0
Reply
#38
tarjan Wrote:I have no idea why srt would work and other formats would cause it to grind to an absolute halt. Might be something where we just have to kludge it together by converting to srt since it works,until we understand how to resolve the underlying issue.

I got the script from : http://doom10.org/index.php?topic=916.0

This is what everybody used to do when the ssa/ass was not yet supported in XBMC, but then with aegisub. Because crunchyroll does not do special styling and other fancy stuff, this isn't a problem. For ass/ssa with decent styling, other fonts and manual signs it is. This is due to the fact that srt subtitles uses far less resources to be rendered, while ass/ssa is done by the library libass. (Or so I think)
Reply
#39
Subs work fine for me on my iPhone 4 with iOS 5.0.1 and XBMC v11 beta 3. The only difference between it and the iPad 1 is RAM.
Reply
#40
It's an iPad 2, so it should have the same RAM :O
Are you positive you can't see any drop in frames?

EDIT: When I thought about for it longer I let XBMC rescale the video
Normally it's 1280*720 to 1024*576
Then I tried going for 0.8, 0.7 and 0.5
at 0.5 it started playing lagless.

Might be that lower resolution gives the iDevice less load work.
Also, when I was monitoring the resources with top, it seems that XBMC was only running with 1 thread. If XBMC were running with 2 threads I think everything would be faster.
Reply
#41
Ned Scott Wrote:Subs work fine for me on my iPhone 4 with iOS 5.0.1 and XBMC v11 beta 3. The only difference between it and the iPad 1 is RAM.
what kind of subs ? srt work fine here too (atv2 4.1 eden beta3 and iPhone 4 4.1 eden beta3), its sub/idx subs that are problematic.
Reply
#42
biGdada Wrote:what kind of subs ? srt work fine here too (atv2 4.1 eden beta3 and iPhone 4 4.1 eden beta3), its sub/idx subs that are problematic.

different issue
Reply
#43
Th3avatar Wrote:Also, when I was monitoring the resources with top, it seems that XBMC was only running with 1 thread. If XBMC were running with 2 threads I think everything would be faster.

Top only show all threads combined. XBMC has always been multi-threaded.
Reply
#44
Ned Scott Wrote:different issue
what's the difference ?
Reply
#45
Hmm then any idea why the XBMC cpu level are higher than the overall cpu level?
For now the way I play is play it scaled at 50%.
Is there any way to fix this or did we just lose to apple?

EDIT: Seems like top also shows the combines CPU, so CPU0 + CPU1 etc. But then it only shows about 110% at max while the iPad 2 should be able to handle up to 200% minus Springboard.
Reply

Logout Mark Read Team Forum Stats Members Help
ATV2 with subtitles enabled causes lag0