Closed fanmm closed 11 years ago
Example of correct ratio.
I'm wondering if this is lg specific and version 3 specific. I'm not seeing the issue on v2 and the Vizio Costar. Will add some debugging info though so we can figure it out.
Alternative code to handling aspect ratio and setting the surfaceview layout params.
/*
* Handle aspect ratio
*/
int surfaceView_Width = surfaceView.getWidth();
int surfaceView_Height = surfaceView.getHeight();
float video_Width = mediaPlayer.getVideoWidth();
float video_Height = mediaPlayer.getVideoHeight();
float ratio_width = surfaceView_Width/video_Width;
float ratio_height = surfaceView_Height/video_Height;
float aspectratio = video_Width/video_Height;
LayoutParams layoutParams = surfaceView.getLayoutParams();
if (ratio_width > ratio_height){
layoutParams.width = (int) (surfaceView_Height * aspectratio);
layoutParams.height = surfaceView_Height;
}else{
layoutParams.width = surfaceView_Width;
layoutParams.height = (int) (surfaceView_Width / aspectratio);
}
surfaceView.setLayoutParams(layoutParams);
Currently I'm using something like the following:
int width = mediaPlayer.getVideoWidth();
int height = mediaPlayer.getVideoHeight();
int swidth = getWindowManager().getDefaultDisplay().getWidth();
android.view.ViewGroup.LayoutParams lp = surfaceView.getLayoutParams();
lp.width = swidth;
lp.height = (int) (((float)height / (float) width ) * (float) swidth );
surfaceView.setLayoutParams(lp);
There is a slight difference in the way these are calculated so, I'll try the alternative code and see how it works.
http://android-er.blogspot.com/2012/03/mediaplay-on-surfaceview-correct-aspect.html
fanmm I implemented the new method of calculating the aspect ratio. This should hopefully fix the issue. I've verified that that aspect ratio calculations are occurring correctly, but need you to verify with the latest 0.7.0-SNAPSHOT file I just pushed to the site.
Hi, I just downloaded new code and compiled and put it on.
It didn't fix Aspect Ratio Issue I am having.
not sure how i can debug this on my side to help you out.
Let me know
Thanks
On Sun, Feb 10, 2013 at 12:22 PM, David Carver notifications@github.comwrote:
fanmm I implemented the new method of calculating the aspect ratio. This should hopefully fix the issue. I've verified that that aspect ratio calculations are occurring correctly, but need you to verify with the latest 0.7.0-SNAPSHOT file I just pushed to the site.
— Reply to this email directly or view it on GitHubhttps://github.com/kingargyle/plexapp-client/issues/12#issuecomment-13356144..
For the video in question. Can you go to the following urls:
http://ip.address.for.pms:32400/library/sections
Find the directory that contains the movie (for example mine are in key 4)
http://ip.address.for.pms:32400/library/sections/4/all
Replace the "4" with the number that corresponds to your video.
You will get a bunch of XML back. Do a search on the movie, and then I just need the XML staring with the video entry along with the Media and Part entries that represents that movie.
I'll also do put some Logging information in a build later in the week that you can then use aLogCat to grab some information and provide it back. How we adjust the video surface is all based on information currently provide by the Android media player API, if for some reason it is giving us bad information, we may have to give an option to ignore it and prefer the information coming from Plex instead.
One more thing that might help. If you can encode a small 10 second video that is reproducing the problem. I can take a look at it as well. Just provide a link where I can download it.
I don't think its single video problem, it happens on ALL my 2.35:1 movies.
<Video ratingKey="3483" key="/library/metadata/3483" studio="Mutual Film"
type="movie" title="The Patriot" titleSort="Patriot" contentRating="R"
summary="The Patriot is a 2000 American historical war film directed by
Roland Emmerich, written by Robert Rodat, and starring Mel Gibson, Chris
Cooper, and Heath Ledger. It was produced by the Mutual Film Company and
Centropolis Entertainment and was distributed by Columbia Pictures. The
film mainly takes place in rural York County, South Carolina and depicts
the story of an American swept into the American Revolutionary War when his
family is threatened. The protagonist, Benjamin Martin, is a composite
figure based on four real American Revolutionary War heroes: Joseph Plumb
Martin, Francis Marion, Daniel Morgan and Thomas Sumter. The film attracted
controversy, with competing claims made about its relative historical
accuracy. Professor Mark Glancy, teacher of film history at Queen Mary
University of London has said: “It’s horrendously inaccurate and attributes
crimes committed by the Nazis in the 1940s to the British in the 1770s.” In
contrast, Australian film critic David Edwards asserts that "this fictional
story is set around actual events, but it is not a history of what America
was, or even an image of what it has become - it's a dream of what it
should be....The Patriot is a grand epic full of action and emotion....But
it's also surprisingly insightful in its evaluation of the American ideal -
if not the reality."" rating="7.5999999046325701" viewCount="1" year="2000"
tagline="Some things are worth fighting for."thumb="
/library/metadata/3483/thumb/1360301788" art="
/library/metadata/3483/art/1360301788" duration="9480000"
originallyAvailableAt="2000-06-27" addedAt="1360301641" updatedAt="
1360301788">
<Media id="3393" duration="10506750" bitrate="1704" width="1920" height="800
" aspectRatio="2.35" audioChannels="2" audioCodec="aac" videoCodec="h264"
videoResolution="1080" container="mp4" videoFrameRate="24p"
optimizedForStreaming="1">
On Mon, Feb 11, 2013 at 6:10 PM, David Carver notifications@github.comwrote:
One more thing that might help. If you can encode a small 10 second video that is reproducing the problem. I can take a look at it as well. Just provide a link where I can download it.
— Reply to this email directly or view it on GitHubhttps://github.com/kingargyle/plexapp-client/issues/12#issuecomment-13409093.
Thanks this will help. I'm going to in 0.7.1 add a preference setting that will be something like. Prefer Plex Aspect Ratio. If set, it will use the information from plex instead of the media player info that Google TV is providing. I also add some Warning based logging to hopefully us determine where the problem occurs.
Here is one potentional problem. A movie encoded with 1920 x 800 actually comes out to an aspect ratio of 2.40, which is supposed to be anamorphic. So in this case we need to compress the video from 2.40 down to 2.35 instead of trying to stretch the height out. I managed to get the same file you have, and will do some testing on it later tonight. I suspect I should be able to replicate the issue. It is a similar issue I was having with a DVD backup of the avengers I had done in my own collection.
Do you know why does plex mark 2.40 as 2.35? Or they are actually the same aspect ratio.
The best explanation is here:
http://en.wikipedia.org/wiki/Anamorphic_format#2.35.2C_2.39_or_2.40.3F
They basically mean the same it is just the type of lense that was used and how it is stored in video content. Anyways, I did test the file on Vizio Costar with V3 of Google TV and it played back correctly (i.e. it had the black bars at the top and bottom). Now that leaves just figuring out what numbers and aspect ratios are being calculated on the LG TV, at this point I'm almost expecting a codec error there reporting back the wrong dimensions. Also do you have your TV set to Wide Screen, or Zoom? I just want to eliminate the possibility that the TV is doing something itself. How do 4:3 videos display on it, or videos in 2:20 aspect ratio. Is everything always being stretched out to 16:9?
Regardless I'll try to get a debugging build out later today or tomorrow for you to do some testing with.
first of all, i don't have setting in LG for Wide screen or zoom, its not a TV box so LG must set it as 16:9. some media player like aVia allow me to set Aspect Ratio on its UI.(kind of workaround) I believe all Anamorphic format are being stretched.
I will try 4:3 tonight
fanmm the setting should also be in your TV Set. My Curtis TV has a setting where I can set it to Normal, Wide, Cinema. Cinema always stretches everything, I leave it set to Wide normally. Anyways, I'll add a setting to force get the aspect ratio from Plex and see if that fixes things. Probably be a couple of days.
I was finally able to reproduce the issue, but surprisingly enough not on the Google TV, but on Android 4.2.1 on my Nexus 7 (yeah, I got Serenity to run there as well). Anyways, I at least have a way to reproduce the issue now.
@kingargyle The problem is in the MediaPlayer API on some devices (like our LG). I encode all my movies in anamorphic to save room on my server. Here is an example:
Media id="26723" duration="9872905" bitrate="5482" width="1360" height="800" aspectRatio="2.35" audioChannels="6" audioCodec="dca" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p"
The media player thinks the AR is 1.7 because the 1360x800 resolution but you'll notice that plex has read the correct AR from the file 2.35. We really need Google, LG, Sony, Netgear, etc to fix this bug in their libraries.
However, your workaround to respect the Plex AR should fix the problem.
Another example of a 4:3 movie
Media id="26597" duration="13995296" bitrate="4876" width="992" height="720" aspectRatio="1.33" audioChannels="6" audioCodec="ac3" videoCodec="h264" videoResolution="720" container="mkv" videoFrameRate="24p"
@jarrettv and @fanmm I think I have a fix for this now. The testing apk with the fix can be found here:
http://kingargyle.github.com/googletv/serenity/alpha/Serenity-0.7.1-SNAPSHOT.apk
There were a couple of problems.
As an added bonus this 0.7.1-SNAPSHOT release does support running Serenity on Tablets. It isn't optimized for that environment, but it is a nice little side benefit. If run on a Tablet is is recommended to use an External player like MX Player that has better codec support.
Anyways, please test this APK out, and if it is good. I can do a point release tomorrow,
just tried out, AR works now, Thanks!
Excellent.
Not so fast. I just tried it and it now takes up the whole screen but the AR doesn't match the Plex reported AR. I'll post a logcat.
https://dl.dropbox.com/u/6142956/forums/serenitylog2.txt
The expected output resolution is 1920x800. The input resolution is 1360x800.
where is the log located on google TV?
Did you check the preference setting it is turned off by default.
If you install aLogCat from the play store your can get the logs.
Patches are welcome, on this as it is very difficult to debug without a device that can reproduce the issue.
I turned it on in the settings. @kingargyle did my log above help any? I'll work on a patch and do a pull request.
Also, can you two @kingargyle and @fanmm star the issue so Google takes notice? http://code.google.com/p/googletv-issues/issues/detail?id=62
Thanks!
The only info I'm seeing in the log that comes close is the following:
I/LGMD_VREND( 1047): KADP_DE_SetInputWin(): x, y, w, h = (0, 0, 1360, 800)
So it doesn't necessarily stretch the video height, but should have Black Bars at the top and bottom of the screen.
I've also posted a question on StackOverflow about this as well.
http://stackoverflow.com/questions/14857156/calculating-display-aspect-ratio-for-anamorphic-video
@jarrettv you'll want to take a look at the following code:
It is where all the display resizing happens for video playback.
internal player always fix aspect ratio at 16:9, so does ViMu. 2.35:1 are compressed, everything look thinner and top and buttom black boxes are gone.