k0.4.1 Android videoview cannot get video source's aspect ratio
我们有16:9、4:3、1:1等等比例的视频源。(Vitamio播放器getVideoAspectRatio()可以从视频源获取到此信息)我们以此信息来调整播放的Layout,调整播放器的比例尺寸。 但目前ijkPlayer没发现这样的API或获得方法,一直我们无从判断该设置成16:9还是4:3等等(不对应时画面肯定有拉伸)
请提供你的片源 这个可以获取得到的
你好,由于我们这里是广电机构,为了防止片源被盗链,我们做了防盗链的处理。也就是每条片源过一阵子就会失效。
源站的片源由于有版权等很多问题,故无法提供给外界。请见谅。
I think you can calculate it via videoWidth, videoHeight, and sample aspect ratio
The problem is we don't know how to get them. (In fact the Aspect-ratio is somewhat the same matter with videoWidth-videoHeight) Could ijkPlayer bring some Java layer API to get Aspect-ratio(or videoWidth-videoHeight) info of the video source(sample)
咱们的ijkPlayer能够提供Java层的API来获取视频源的AspectRatio或宽高吗? 另外片源的话,因为过一会儿会失效,如果可以的话,咱们约定个时间,我抓取一下链接发上来,咱们再分析可以吗?
public interface IMediaPlayer {
...
int getVideoWidth();
int getVideoHeight();
int getVideoSarNum();
int getVideoSarDen();
...
void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener);
...
}
好的,我们试试。多谢! 因为之前有些播放器,getVideoWidth()/getVideoHeight()得到的是你给他设置的宽和高,不是视频源的宽高比例。
添加监听就可以了,宽高都回调上来的
请问具体的监听API是什么呢?我们好像都加了,但没找到。谢谢
OnVideoSizeChangedListener VideoWidth,VideoHeight,VideoSarNum,VideoSarDen这些参数回调到你的应用层。
您说的是这个是Layout里的宽和高,我们把VideoView的宽高设成什么样,到时它回调也会返这个数。 我们需要的是视频源的宽和高。 您可以看看vitamio播放器。无论Layout里设置成什么宽高,他都会返回固定的,也就是视频源的宽高比,这个是视频的属性。这样我们才能以此为依据设置VideoView的宽高。
I don't think ijkplayer would change that values on layout change.
我们做过测试。对于播放同一个片源(16:9的片源),如果我们把VideoView的宽高设置成4:3的,比如400:300,ijkPlayer就会返回400,300;而如果我们设置成16:9的,如400:225,那么ijkPlayer就会返回400:255。不知您如何解释这个问题?
而Vitamio VideoView有单独的Api可以获得这个比例,我们用同样的测试发现这个比例确实是片源的。 当然Vitamio有他其他的问题,还是希望咱们能够支持这个,否则我也不会在这和您这么多。
Can't reproduce this problem in sample project, by click "SCALE" button. Could you provide some code piece or log?